From 0fd98011d63fb93a7c4921e3c747030934f1bdfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Fri, 12 Aug 2022 18:25:51 +0200 Subject: [PATCH] [build] Add Meson build system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Håvard Sørbø --- .gitignore | 1 + include/cppgc/internal/meson.build | 18 + include/cppgc/meson.build | 34 + include/libplatform/meson.build | 7 + include/meson.build | 88 ++ meson.build | 566 +++++++++ meson_options.txt | 108 ++ src/base/meson.build | 98 ++ src/generated/builtins-generated/meson.build | 7 + src/generated/meson.build | 2 + src/generated/torque-generated/meson.build | 330 +++++ src/inspector/meson.build | 95 ++ src/libplatform/meson.build | 41 + src/meson.build | 1061 +++++++++++++++++ src/snapshot/meson.build | 40 + src/torque/meson.build | 38 + subprojects/zlib.wrap | 7 + .../inspector_protocol/crdtp/meson.build | 11 + third_party/inspector_protocol/meson.build | 17 + third_party/meson.build | 4 + third_party/zlib/google/meson.build | 30 + third_party/zlib/meson.build | 1 + tools/meson-commit-codegen.py | 26 + tools/meson-post-process-executable.py | 50 + tools/meson-prepare-codegen.py | 28 + tools/meson-run-codegen.py | 38 + tools/meson_post_processor.py | 33 + 27 files changed, 2779 insertions(+) create mode 100644 include/cppgc/internal/meson.build create mode 100644 include/cppgc/meson.build create mode 100644 include/libplatform/meson.build create mode 100644 include/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/base/meson.build create mode 100644 src/generated/builtins-generated/meson.build create mode 100644 src/generated/meson.build create mode 100644 src/generated/torque-generated/meson.build create mode 100644 src/inspector/meson.build create mode 100644 src/libplatform/meson.build create mode 100644 src/meson.build create mode 100644 src/snapshot/meson.build create mode 100644 src/torque/meson.build create mode 100644 subprojects/zlib.wrap create mode 100644 third_party/inspector_protocol/crdtp/meson.build create mode 100644 third_party/inspector_protocol/meson.build create mode 100644 third_party/meson.build create mode 100644 third_party/zlib/google/meson.build create mode 100644 third_party/zlib/meson.build create mode 100755 tools/meson-commit-codegen.py create mode 100755 tools/meson-post-process-executable.py create mode 100755 tools/meson-prepare-codegen.py create mode 100755 tools/meson-run-codegen.py create mode 100644 tools/meson_post_processor.py diff --git a/.gitignore b/.gitignore index bd324948e5..5fbd546df4 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,7 @@ /perf.data.old /src/inspector/build/closure-compiler /src/inspector/build/closure-compiler.tar.gz +/subprojects/zlib /test/benchmarks/data /test/fuzzer/wasm_corpus /test/fuzzer/wasm_corpus.tar.gz diff --git a/include/cppgc/internal/meson.build b/include/cppgc/internal/meson.build new file mode 100644 index 0000000000..4d70740c00 --- /dev/null +++ b/include/cppgc/internal/meson.build @@ -0,0 +1,18 @@ +cppgc_internal_headers = [ + 'write-barrier.h', + 'gc-info.h', + 'persistent-node.h', + 'name-trait.h', + 'pointer-policies.h', + 'logging.h', + 'api-constants.h', + 'atomic-entry-flag.h', + 'member-storage.h', + 'compiler-specific.h', + 'finalizer-trait.h', + 'caged-heap-local-data.h', + 'base-page-handle.h', + 'caged-heap.h', +] + +install_headers(cppgc_internal_headers, subdir: install_header_subdir / 'cppgc' / 'internal') diff --git a/include/cppgc/meson.build b/include/cppgc/meson.build new file mode 100644 index 0000000000..c00cd4c626 --- /dev/null +++ b/include/cppgc/meson.build @@ -0,0 +1,34 @@ +cppgc_headers = [ + 'testing.h', + 'cross-thread-persistent.h', + 'name-provider.h', + 'persistent.h', + 'prefinalizer.h', + 'allocation.h', + 'process-heap-statistics.h', + 'ephemeron-pair.h', + 'custom-space.h', + 'type-traits.h', + 'heap-state.h', + 'default-platform.h', + 'heap-statistics.h', + 'heap-handle.h', + 'visitor.h', + 'garbage-collected.h', + 'trace-trait.h', + 'object-size-trait.h', + 'common.h', + 'heap-consistency.h', + 'macros.h', + 'heap.h', + 'sentinel-pointer.h', + 'liveness-broker.h', + 'member.h', + 'platform.h', + 'source-location.h', + 'explicit-management.h', +] + +install_headers(cppgc_headers, subdir: install_header_subdir / 'cppgc') + +subdir('internal') diff --git a/include/libplatform/meson.build b/include/libplatform/meson.build new file mode 100644 index 0000000000..9f74ea9af8 --- /dev/null +++ b/include/libplatform/meson.build @@ -0,0 +1,7 @@ +libplatform_headers = [ + 'libplatform-export.h', + 'libplatform.h', + 'v8-tracing.h', +] + +install_headers(libplatform_headers, subdir: install_header_subdir / 'libplatform') diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 0000000000..f9d574af5a --- /dev/null +++ b/include/meson.build @@ -0,0 +1,88 @@ +install_header_subdir = 'v8-' + api_version + +v8_inspector_js_protocol = files('js_protocol.pdl') + +v8_headers = [ + 'v8-array-buffer.h', + 'v8-callbacks.h', + 'v8-container.h', + 'v8-context.h', + 'v8-cppgc.h', + 'v8-data.h', + 'v8-date.h', + 'v8-debug.h', + 'v8-embedder-heap.h', + 'v8-embedder-state-scope.h', + 'v8-exception.h', + 'v8-extension.h', + 'v8-external.h', + 'v8-fast-api-calls.h', + 'v8-forward.h', + 'v8-function-callback.h', + 'v8-function.h', + 'v8-initialization.h', + 'v8-inspector-protocol.h', + 'v8-inspector.h', + 'v8-internal.h', + 'v8-isolate.h', + 'v8-json.h', + 'v8-local-handle.h', + 'v8-locker.h', + 'v8-maybe.h', + 'v8-memory-span.h', + 'v8-message.h', + 'v8-metrics.h', + 'v8-microtask-queue.h', + 'v8-microtask.h', + 'v8-object.h', + 'v8-persistent-handle.h', + 'v8-platform.h', + 'v8-primitive-object.h', + 'v8-primitive.h', + 'v8-profiler.h', + 'v8-promise.h', + 'v8-proxy.h', + 'v8-regexp.h', + 'v8-script.h', + 'v8-snapshot.h', + 'v8-statistics.h', + 'v8-template.h', + 'v8-traced-handle.h', + 'v8-typed-array.h', + 'v8-unwinder-state.h', + 'v8-unwinder.h', + 'v8-util.h', + 'v8-value-serializer-version.h', + 'v8-value-serializer.h', + 'v8-value.h', + 'v8-version-string.h', + 'v8-version.h', + 'v8-wasm-trap-handler-posix.h', + 'v8-wasm-trap-handler-win.h', + 'v8-wasm.h', + 'v8-weak-callback-info.h', + 'v8.h', + 'v8config.h', +] + +install_headers(v8_headers, subdir: install_header_subdir) + +command = [ + gen_v8_gn, + '-o', '@OUTPUT@', +] +foreach d : enabled_external_defines + command += ['-p', d] +endforeach +foreach d : disabled_external_defines + command += ['-n', d] +endforeach +v8_gn_h = custom_target('v8-gn-header', + output: 'v8-gn.h', + command: command, + install: true, + install_dir: get_option('includedir') / install_header_subdir, +) + +subdir('cppgc') +subdir('libplatform') diff --git a/meson.build b/meson.build new file mode 100644 index 0000000000..b85beb5280 --- /dev/null +++ b/meson.build @@ -0,0 +1,566 @@ +project('v8', 'cpp', + version: '10.9.27', +) + +api_version = '10.0' + +cpp = meson.get_compiler('cpp') +cpp_native = meson.get_compiler('cpp', native: true) +cpp_std = (cpp.get_id() == 'msvc') ? 'vc++17' : 'gnu++17' +cpp_options = [ + 'cpp_std=' + cpp_std, + 'cpp_eh=none', + 'cpp_rtti=false', +] + +python = import('python').find_installation().path() + +build_os = build_machine.system() +host_os = host_machine.system() + +target_conditionals_prefix = '#include ' +is_macos_src = target_conditionals_prefix + ''' +#if !TARGET_OS_OSX +# error Not macOS +#endif +''' +is_ios_src = target_conditionals_prefix + ''' +#if !TARGET_OS_IOS +# error Not iOS +#endif +''' + +if build_os == 'windows' + build_os = 'win' +elif build_os == 'darwin' + if cpp_native.compiles(is_macos_src, name: 'compiling on macOS') + build_os = 'macos' + elif cpp_native.compiles(is_ios_src, name: 'compiling on iOS') + build_os = 'ios' + endif +elif build_os == 'linux' and cpp_native.has_header('android/api-level.h') + build_os = 'android' +endif +if host_os == 'windows' + host_os = 'win' +elif host_os == 'darwin' + if cpp.compiles(is_macos_src, name: 'compiling for macOS') + host_os = 'macos' + elif cpp.compiles(is_ios_src, name: 'compiling for iOS') + host_os = 'ios' + endif +elif host_os == 'linux' and cpp.has_header('android/api-level.h') + host_os = 'android' +endif +host_os_nick = (host_os == 'macos') ? 'mac' : host_os + +v8_arch_from_cpu_family = { + 'x86': 'ia32', + 'x86_64': 'x64', + 'arm': 'arm', + 'aarch64': 'arm64', +} +build_arch = v8_arch_from_cpu_family[build_machine.cpu_family()] +host_arch = v8_arch_from_cpu_family[host_machine.cpu_family()] + +build_os_frida = (build_os == 'win') ? 'windows' : build_os +host_os_frida = (host_os == 'win') ? 'windows' : host_os +build_arch_frida = build_arch.startswith('arm') ? build_arch : build_machine.cpu_family() +if build_arch_frida == 'arm' and cpp_native.get_define('__ARM_PCS_VFP') != '' + build_arch_frida = 'armhf' +endif +host_arch_frida = host_arch.startswith('arm') ? host_arch : host_machine.cpu_family() +if host_arch_frida == 'arm' and cpp.get_define('__ARM_PCS_VFP') != '' + host_arch_frida = 'armhf' +endif + +build_ptrsize = cpp_native.sizeof('void *') +host_ptrsize = cpp.sizeof('void *') + +host_is_64bit = host_ptrsize == 8 + +if not meson.can_run_host_binaries() and build_ptrsize != host_ptrsize + error('''Unable to generate a V8 snapshot for @0@-@1@ on this machine. + +This is because the build machine pointer size (@3@) does not match the host machine pointer size (@2@). + +Possible solutions: +A) Use a matching build machine. +B) Define a Meson exe_wrapper for the host, such as wine, qemu-user, etc. +C) Configure qemu-user-binfmt and set needs_exe_wrapper to false.'''.format(host_os, host_arch, host_ptrsize, build_ptrsize)) +endif + +if host_os in ['macos', 'ios'] and host_arch == 'arm64' + have_ptrauth_src = '''#ifdef __clang__ +# if __has_feature (ptrauth_calls) +# define HAVE_PTRAUTH 1 +# endif +#endif + +#ifndef HAVE_PTRAUTH +# error Pointer authentication not supported +#endif +''' + have_ptrauth = cpp.compiles(have_ptrauth_src, name: 'pointer authentication') +else + have_ptrauth = false +endif + +is_clang_or_non_windows = cpp.get_id() == 'clang' or host_os != 'win' +if not is_clang_or_non_windows + msvc_asm_tool_specs = { + 'ia32': { + 'tool': 'ml', + 'args': ['/nologo', '/Fo', '@OUTPUT@', '/c', '/safeseh', '@INPUT@'], + }, + 'x64': { + 'tool': 'ml64', + 'args': ['/nologo', '/Fo', '@OUTPUT@', '/c', '@INPUT@'], + }, + 'arm64': { + 'tool': 'armasm64', + 'args': ['-nologo', '-o', '@OUTPUT@', '@INPUT@'], + }, + } + msvc_required_archs = [host_arch] + if not meson.can_run_host_binaries() + msvc_required_archs += build_arch + endif + msvc_asm_commands = {} + foreach arch : msvc_required_archs + spec = msvc_asm_tool_specs[arch] + tool = find_program(spec['tool']) + args = spec['args'] + msvc_asm_commands += { arch: [tool] + args } + endforeach +endif + +system_lib_names = { + 'win': [ + 'winmm', + 'ws2_32', + ], + 'android': [ + 'log', + ], + 'freebsd': [ + 'execinfo', + ], +} + +system_deps = [ + dependency('threads'), + dependency('dl', required: false), +] +foreach name : system_lib_names.get(host_os, []) + system_deps += cpp.find_library(name) +endforeach +if host_os == 'linux' and not cpp.has_function('clock_gettime') + system_deps += cpp.find_library('rt') +endif +zlib_dep = dependency('zlib') + +if not meson.can_run_host_binaries() + system_native_deps = [ + dependency('threads', native: true), + dependency('dl', native: true, required: false), + ] + foreach name : system_lib_names.get(build_os, []) + system_native_deps += cpp_native.find_library(name) + endforeach + if build_os == 'linux' and not cpp_native.has_function('clock_gettime') + system_native_deps += cpp_native.find_library('rt') + endif + zlib_native_dep = dependency('zlib', native: true) +endif + +public_incdirs = include_directories('include') +internal_incdirs = include_directories( + 'src' / 'generated', + '.', + 'include', +) + +config_args = [ + '-DV8_HAVE_TARGET_OS', + '-DV8_TARGET_OS_' + host_os.to_upper(), + '-DV8_TARGET_ARCH_' + host_arch.to_upper(), + '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64', + '-DV8_ATOMIC_OBJECT_FIELD_WRITES', + '-DV8_ENABLE_LAZY_SOURCE_POSITIONS', + '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH', + '-DV8_ALLOCATION_FOLDING', + '-DV8_ALLOCATION_SITE_TRACKING', + '-DV8_DEPRECATION_WARNINGS', + '-DV8_IMMINENT_DEPRECATION_WARNINGS', + '-DV8_DISABLE_TESTS', + '-DDYNAMIC_ANNOTATIONS_ENABLED=0', + '-DOFFICIAL_BUILD', + '-DV8_USE_ZLIB', + '-DUSE_SYSTEM_ZLIB', + '-DNVALGRIND', +] + +if get_option('default_library') != 'static' + config_args += [ + '-DBUILDING_V8_SHARED', + '-DBUILDING_V8_PLATFORM_SHARED', + ] +endif + +embedder_string = get_option('embedder_string') +if embedder_string != '' + config_args += f'-DV8_EMBEDDER_STRING="@embedder_string@"' +endif + +ndebug = get_option('b_ndebug') +optimize_for_prod = ndebug == 'true' or (ndebug == 'if-release' and not get_option('debug')) + +if get_option('debugging_features').auto() + enable_debugging_features = not optimize_for_prod +else + enable_debugging_features = get_option('debugging_features').enabled() +endif + +if get_option('checks').auto() + enable_checks = not optimize_for_prod +else + enable_checks = get_option('checks').enabled() +endif + +if get_option('slow_dchecks').auto() + enable_slow_dchecks = not optimize_for_prod +else + enable_slow_dchecks = get_option('slow_dchecks').enabled() +endif + +if enable_checks + config_args += '-DV8_ENABLE_CHECKS' +endif +if enable_debugging_features + config_args += '-DDEBUG' + if enable_slow_dchecks + config_args += '-DENABLE_SLOW_DCHECKS' + endif +endif + +enable_disassembler = enable_debugging_features +if enable_disassembler + config_args += '-DENABLE_DISASSEMBLER' +endif + +enable_object_print = enable_debugging_features +if enable_object_print + config_args += '-DOBJECT_PRINT' +endif + +enable_verify_heap = enable_debugging_features +if enable_verify_heap + config_args += '-DVERIFY_HEAP' +endif + +enable_cppgc_verify_heap = enable_debugging_features +if enable_cppgc_verify_heap + config_args += '-DCPPGC_VERIFY_HEAP' +endif + +enable_trace_maps = enable_debugging_features +if enable_trace_maps + config_args += '-DV8_TRACE_MAPS' +endif + +enable_test_features = enable_debugging_features +if enable_test_features + config_args += [ + '-DV8_ENABLE_ALLOCATION_TIMEOUT', + '-DV8_ENABLE_FORCE_SLOW_PATH', + '-DV8_ENABLE_DOUBLE_CONST_STORE_CHECK', + ] +endif + +if have_ptrauth + config_args += '-DV8_TARGET_PTRAUTH' +endif + +enable_advanced_bigint_algorithms = get_option('advanced_bigint_algorithms').allowed() +if enable_advanced_bigint_algorithms + config_args += '-DV8_ADVANCED_BIGINT_ALGORITHMS' +endif + +enable_snapshot_compression = get_option('snapshot_compression').allowed() +if enable_snapshot_compression + config_args += '-DV8_SNAPSHOT_COMPRESSION' +endif + +if get_option('pointer_compression').auto() + enable_pointer_compression = host_is_64bit and host_os not in ['macos', 'ios'] +else + enable_pointer_compression = get_option('pointer_compression').enabled() +endif + +if get_option('pointer_compression_shared_cage').auto() + enable_pointer_compression_shared_cage = enable_pointer_compression +else + enable_pointer_compression_shared_cage = get_option('pointer_compression_shared_cage').enabled() +endif + +enable_31bit_smis_on_64bit_arch = get_option('31bit_smis_on_64bit_arch').allowed() + +if enable_pointer_compression + config_args += '-DV8_COMPRESS_POINTERS' + if enable_pointer_compression_shared_cage + config_args += '-DV8_COMPRESS_POINTERS_IN_SHARED_CAGE' + else + config_args += '-DV8_COMPRESS_POINTERS_IN_ISOLATE_CAGE' + endif +endif + +if enable_pointer_compression or enable_31bit_smis_on_64bit_arch + config_args += '-DV8_31BIT_SMIS_ON_64BIT_ARCH' +endif + +if get_option('shared_ro_heap').auto() + enable_shared_ro_heap = not enable_pointer_compression or enable_pointer_compression_shared_cage +else + enable_shared_ro_heap = get_option('shared_ro_heap').enabled() +endif +if enable_shared_ro_heap and enable_pointer_compression and not enable_pointer_compression_shared_cage + if host_os not in ['linux', 'android'] + error('Sharing read-only heap with pointer compression is only supported on Linux or Android') + endif +endif +if enable_shared_ro_heap + config_args += '-DV8_SHARED_RO_HEAP' +endif + +if get_option('cppgc_caged_heap').auto() + enable_cppgc_caged_heap = host_is_64bit +else + enable_cppgc_caged_heap = get_option('cppgc_caged_heap').enabled() +endif + +if get_option('cppgc_young_generation').auto() + enable_cppgc_young_generation = enable_cppgc_caged_heap +else + enable_cppgc_young_generation = get_option('cppgc_young_generation').enabled() +endif + +if get_option('cppgc_pointer_compression').auto() + enable_cppgc_pointer_compression = enable_cppgc_caged_heap and host_os in ['win', 'macos', 'linux'] +else + enable_cppgc_pointer_compression = get_option('cppgc_pointer_compression').enabled() +endif + +if enable_pointer_compression_shared_cage and not enable_pointer_compression + error('Can\'t share a pointer compression cage if pointers aren\'t compressed') +endif + +if enable_pointer_compression_shared_cage and host_arch not in ['x64', 'arm64', 'riscv64'] + error('Sharing a pointer compression cage is only supported on x64, arm64, and riscv64') +endif + +if enable_cppgc_caged_heap and not host_is_64bit + error('CppGC caged heap requires 64-bit platforms') +endif + +if enable_cppgc_young_generation and not enable_cppgc_caged_heap + error('Young generation in CppGC requires caged heap') +endif + +if enable_cppgc_pointer_compression and not enable_cppgc_caged_heap + error('Pointer compression in CppGC requires caged heap') +endif + +if enable_cppgc_caged_heap + config_args += '-DCPPGC_CAGED_HEAP' +endif + +if enable_cppgc_young_generation + config_args += '-DCPPGC_YOUNG_GENERATION' +endif + +if enable_cppgc_pointer_compression + config_args += '-DCPPGC_POINTER_COMPRESSION' +endif + +enable_i18n = get_option('i18n').allowed() + +if get_option('maglev').auto() + enable_maglev = host_arch == 'x64' and enable_pointer_compression +else + enable_maglev = get_option('maglev').enabled() +endif + +enable_wasm = get_option('wasm').allowed() +if enable_wasm + config_args += '-DV8_ENABLE_WEBASSEMBLY' +endif + +if get_option('system_instrumentation').auto() + enable_system_instrumentation = host_os in ['win', 'macos'] +else + enable_system_instrumentation = get_option('system_instrumentation').enabled() +endif +if enable_system_instrumentation + config_args += '-DV8_ENABLE_SYSTEM_INSTRUMENTATION' +endif + +if host_os == 'win' + config_args += [ + '-DUNICODE', + '-D_UNICODE', + '-D_CRT_RAND_S', + '-DNOMINMAX', + '-D_ITERATOR_DEBUG_LEVEL=0', + ] + if cpp.get_define('_WIN32_WINNT') == '' + config_args += [ + '-DWINVER=0x0501', + '-D_WIN32_WINNT=0x0501', + ] + endif + if host_is_64bit + config_args += '-DV8_WIN64_UNWINDING_INFO' + endif +elif host_os == 'linux' + config_args += [ + # Needed for older versions of glibc + '-D__STDC_FORMAT_MACROS', + ] +endif + +if host_arch == 'arm' + if cpp.compiles('#if !(defined(__ARM_ARCH) && __ARM_ARCH >= 7)\n#error Pre-ARMv7\n#endif') + config_args += '-DCAN_USE_ARMV7_INSTRUCTIONS' + arm_version = 'seven-plus' + else + arm_version = 'six-minus' + endif + + arm_fpu = get_option('arm_fpu') + if arm_fpu == 'auto' + if cpp.get_define('__ARM_NEON') == '1' + arm_fpu = 'neon' + elif arm_version == 'seven-plus' + arm_fpu = 'vfpv3-d16' + else + arm_fpu = 'none-or-vfpv2' + endif + endif + + if arm_fpu == 'vfpv3-d16' + config_args += [ + '-DCAN_USE_VFP3_INSTRUCTIONS', + ] + elif arm_fpu == 'vfpv3' + config_args += [ + '-DCAN_USE_VFP3_INSTRUCTIONS', + '-DCAN_USE_VFP32DREGS', + ] + elif arm_fpu == 'neon' + config_args += [ + '-DCAN_USE_VFP3_INSTRUCTIONS', + '-DCAN_USE_VFP32DREGS', + '-DCAN_USE_NEON', + ] + endif + + config_args += '-DUSE_EABI_HARDFLOAT=' + (cpp.get_define('__ARM_PCS_VFP') != '' ? '1' : '0') +endif + +external_defines = [ + 'V8_ENABLE_CHECKS', + 'V8_COMPRESS_POINTERS', + 'V8_COMPRESS_POINTERS_IN_SHARED_CAGE', + 'V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE', + 'V8_31BIT_SMIS_ON_64BIT_ARCH', + 'V8_COMPRESS_ZONES', + 'V8_ENABLE_SANDBOX', + 'V8_DEPRECATION_WARNINGS', + 'V8_IMMINENT_DEPRECATION_WARNINGS', + 'V8_NO_ARGUMENTS_ADAPTOR', + 'V8_USE_PERFETTO', + 'V8_MAP_PACKING', + 'V8_IS_TSAN', + 'CPPGC_SUPPORTS_OBJECT_NAMES', + 'CPPGC_CAGED_HEAP', + 'CPPGC_YOUNG_GENERATION', + 'CPPGC_POINTER_COMPRESSION', +] +enabled_external_defines = [] +disabled_external_defines = [] +foreach d : external_defines + arg = '-D' + d + if config_args.contains(arg) + enabled_external_defines += d + else + disabled_external_defines += d + endif +endforeach + +compiler_args_generic = [ + '-Wno-builtin-assume-aligned-alignment', + '-Wno-non-virtual-dtor', +] +compiler_args_for_compiler = { + 'clang': [ + '-fno-aligned-allocation', + ], + 'gcc': [ + '-Wno-class-memaccess', + '-Wno-comment', + '-Wno-int-in-bool-context', + '-Wno-maybe-uninitialized', + '-Wno-nonnull', + '-Wno-psabi', + '-Wno-return-type', + '-Wno-strict-aliasing', + '-Wno-stringop-overflow', + '-Wno-uninitialized', + '-Wno-unused-variable', + ], + 'msvc': [ + '/wd4146', + '/wd4244', + '/wd4251', + '/wd4267', + '/wd4275', + '/wd4312', + '/wd4506', + '/wd4530', + '/wd4661', + '/wd4700', + '/wd4715', + '/wd4716', + '/wd4838', + ], +} + +host_compiler_args = cpp.get_supported_arguments(compiler_args_generic) + compiler_args_for_compiler.get(cpp.get_id(), []) +build_compiler_args = cpp_native.get_supported_arguments(compiler_args_generic) + compiler_args_for_compiler.get(cpp_native.get_id(), []) + +add_project_arguments( + config_args + host_compiler_args, + language: 'cpp' +) +add_project_arguments( + config_args + build_compiler_args, + language: 'cpp', + native: true +) + +gen_v8_gn = [python, files('tools' / 'gen-v8-gn.py')] +run_codegen = [python, files('tools' / 'meson-run-codegen.py')] +prepare_codegen = [python, files('tools' / 'meson-prepare-codegen.py')] +commit_codegen = [python, files('tools' / 'meson-commit-codegen.py')] +post_process_executable = [python, files('tools' / 'meson-post-process-executable.py')] + +if build_os != 'win' + strip = find_program('strip', native: true) +else + strip = '' +endif + +subdir('include') +subdir('third_party') +subdir('src') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000000..45db480479 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,108 @@ +option('embedder_string', + type: 'string', + value: '', + description: 'Embedder string' +) + +option('debugging_features', + type: 'feature', + value: 'disabled', + description: 'Enable debugging features' +) + +option('checks', + type: 'feature', + value: 'disabled', + description: 'Enable checks' +) + +option('slow_dchecks', + type: 'feature', + value: 'disabled', + description: 'Enable slow dchecks' +) + +option('advanced_bigint_algorithms', + type: 'feature', + value: 'auto', + description: 'Enable advanced BigInt algorithms, costing about 10-30 KB binary size depending on platform' +) + +option('snapshot_compression', + type: 'feature', + value: 'auto', + description: 'Enable snapshot compression' +) + +option('pointer_compression', + type: 'feature', + value: 'auto', + description: 'Enable pointer compression' +) + +option('pointer_compression_shared_cage', + type: 'feature', + value: 'auto', + description: 'Compress pointers in shared cage' +) + +option('31bit_smis_on_64bit_arch', + type: 'feature', + value: 'disabled', + description: 'Use 31-bit SMIs on 64-bit architectures' +) + +option('shared_ro_heap', + type: 'feature', + value: 'auto', + description: 'Enable sharing read-only space across isolates' +) + +option('cppgc_caged_heap', + type: 'feature', + value: 'auto', + description: 'Enable heap reservation of size 4GB' +) + +option('cppgc_young_generation', + type: 'feature', + value: 'auto', + description: 'Enable young generation in cppgc' +) + +option('cppgc_pointer_compression', + type: 'feature', + value: 'auto', + description: 'Enable pointer compression in cppgc' +) + +option('i18n', + type: 'feature', + value: 'disabled', + description: 'Internationalization support' +) + +option('maglev', + type: 'feature', + value: 'disabled', + description: 'Maglev mid-tier optimizing compiler' +) + +option('wasm', + type: 'feature', + value: 'auto', + description: 'WebAssembly' +) + +option('system_instrumentation', + type: 'feature', + value: 'disabled', + description: 'Enable OS-dependent event tracing' +) + +option('arm_fpu', + type: 'combo', + choices: ['auto', 'none-or-vfpv2', 'vfpv3-d16', 'vfpv3', 'neon'], + value: 'auto', + description: 'ARM FPU flavor' +) diff --git a/src/base/meson.build b/src/base/meson.build new file mode 100644 index 0000000000..f39c2f7019 --- /dev/null +++ b/src/base/meson.build @@ -0,0 +1,98 @@ +libbase_common_sources = [ + 'bits.cc', + 'bounded-page-allocator.cc', + 'cpu.cc', + 'debug' / 'stack_trace.cc', + 'division-by-constant.cc', + 'emulated-virtual-address-subspace.cc', + 'file-utils.cc', + 'ieee754.cc', + 'lazy-instance.cc', + 'logging.cc', + 'numbers' / 'bignum-dtoa.cc', + 'numbers' / 'bignum.cc', + 'numbers' / 'cached-powers.cc', + 'numbers' / 'diy-fp.cc', + 'numbers' / 'dtoa.cc', + 'numbers' / 'fast-dtoa.cc', + 'numbers' / 'fixed-dtoa.cc', + 'numbers' / 'strtod.cc', + 'once.cc', + 'page-allocator.cc', + 'platform' / 'threading-backend.cc', + 'platform' / 'condition-variable.cc', + 'platform' / 'memory-protection-key.cc', + 'platform' / 'mutex.cc', + 'platform' / 'semaphore.cc', + 'platform' / 'time.cc', + 'region-allocator.cc', + 'sanitizer' / 'lsan-page-allocator.cc', + 'sanitizer' / 'lsan-virtual-address-space.cc', + 'strings.cc', + 'sys-info.cc', + 'utils' / 'random-number-generator.cc', + 'virtual-address-space-page-allocator.cc', + 'virtual-address-space.cc', + 'vlq-base64.cc', +] + +libbase_posix_sources = [ + 'platform' / 'platform-posix.cc', + 'platform' / 'platform-posix-time.cc', +] + +libbase_os_sources = { + 'win': [ + 'debug' / 'stack_trace_win.cc', + 'platform' / 'platform-win32.cc', + ], + 'macos': libbase_posix_sources + [ + 'debug' / 'stack_trace_posix.cc', + 'platform' / 'platform-darwin.cc', + 'platform' / 'platform-macos.cc', + ], + 'linux': libbase_posix_sources + [ + 'debug' / 'stack_trace_posix.cc', + 'platform' / 'platform-linux.cc', + ], + 'ios': libbase_posix_sources + [ + 'debug' / 'stack_trace_posix.cc', + 'platform' / 'platform-darwin.cc', + ], + 'android': libbase_posix_sources + [ + 'debug' / 'stack_trace_android.cc', + 'platform' / 'platform-linux.cc', + ], + 'freebsd': libbase_posix_sources + [ + 'debug' / 'stack_trace_posix.cc', + 'platform' / 'platform-freebsd.cc', + ], +} + +v8_libbase = static_library('v8-libbase', libbase_common_sources + libbase_os_sources.get(host_os, []), + override_options: cpp_options, + include_directories: internal_incdirs, + implicit_include_directories: false, + dependencies: system_deps, +) + +if meson.can_run_host_binaries() + v8_libbase_runnable = v8_libbase +else + v8_libbase_runnable = static_library('v8-libbase-native', libbase_common_sources + libbase_os_sources.get(build_os, []), + override_options: cpp_options, + include_directories: internal_incdirs, + implicit_include_directories: false, + dependencies: system_native_deps, + native: true, + ) +endif + +v8_libbase_dep = declare_dependency( + include_directories: internal_incdirs, + link_with: v8_libbase, +) +v8_libbase_runnable_dep = declare_dependency( + include_directories: internal_incdirs, + link_with: v8_libbase_runnable, +) diff --git a/src/generated/builtins-generated/meson.build b/src/generated/builtins-generated/meson.build new file mode 100644 index 0000000000..2fc05a3e64 --- /dev/null +++ b/src/generated/builtins-generated/meson.build @@ -0,0 +1,7 @@ +bytecodes_builtins_list_h = custom_target('v8-bytecode-builtins-list', + output: 'bytecodes-builtins-list.h', + command: [ + bytecode_builtins_list_generator, + '@OUTPUT@' + ], +) diff --git a/src/generated/meson.build b/src/generated/meson.build new file mode 100644 index 0000000000..b9db34326a --- /dev/null +++ b/src/generated/meson.build @@ -0,0 +1,2 @@ +subdir('builtins-generated') +subdir('torque-generated') diff --git a/src/generated/torque-generated/meson.build b/src/generated/torque-generated/meson.build new file mode 100644 index 0000000000..6ec62aa664 --- /dev/null +++ b/src/generated/torque-generated/meson.build @@ -0,0 +1,330 @@ +torque_files = [ + 'src' / 'builtins' / 'aggregate-error.tq', + 'src' / 'builtins' / 'array-at.tq', + 'src' / 'builtins' / 'array-concat.tq', + 'src' / 'builtins' / 'array-copywithin.tq', + 'src' / 'builtins' / 'array-every.tq', + 'src' / 'builtins' / 'array-filter.tq', + 'src' / 'builtins' / 'array-find.tq', + 'src' / 'builtins' / 'array-findindex.tq', + 'src' / 'builtins' / 'array-findlast.tq', + 'src' / 'builtins' / 'array-findlastindex.tq', + 'src' / 'builtins' / 'array-foreach.tq', + 'src' / 'builtins' / 'array-from.tq', + 'src' / 'builtins' / 'array-isarray.tq', + 'src' / 'builtins' / 'array-join.tq', + 'src' / 'builtins' / 'array-lastindexof.tq', + 'src' / 'builtins' / 'array-map.tq', + 'src' / 'builtins' / 'array-of.tq', + 'src' / 'builtins' / 'array-reduce-right.tq', + 'src' / 'builtins' / 'array-reduce.tq', + 'src' / 'builtins' / 'array-reverse.tq', + 'src' / 'builtins' / 'array-shift.tq', + 'src' / 'builtins' / 'array-slice.tq', + 'src' / 'builtins' / 'array-some.tq', + 'src' / 'builtins' / 'array-splice.tq', + 'src' / 'builtins' / 'array-to-reversed.tq', + 'src' / 'builtins' / 'array-to-sorted.tq', + 'src' / 'builtins' / 'array-to-spliced.tq', + 'src' / 'builtins' / 'array-unshift.tq', + 'src' / 'builtins' / 'array-with.tq', + 'src' / 'builtins' / 'array.tq', + 'src' / 'builtins' / 'arraybuffer.tq', + 'src' / 'builtins' / 'base.tq', + 'src' / 'builtins' / 'boolean.tq', + 'src' / 'builtins' / 'builtins-bigint.tq', + 'src' / 'builtins' / 'builtins-string.tq', + 'src' / 'builtins' / 'cast.tq', + 'src' / 'builtins' / 'collections.tq', + 'src' / 'builtins' / 'constructor.tq', + 'src' / 'builtins' / 'conversion.tq', + 'src' / 'builtins' / 'convert.tq', + 'src' / 'builtins' / 'console.tq', + 'src' / 'builtins' / 'data-view.tq', + 'src' / 'builtins' / 'finalization-registry.tq', + 'src' / 'builtins' / 'frames.tq', + 'src' / 'builtins' / 'frame-arguments.tq', + 'src' / 'builtins' / 'function.tq', + 'src' / 'builtins' / 'growable-fixed-array.tq', + 'src' / 'builtins' / 'ic-callable.tq', + 'src' / 'builtins' / 'ic.tq', + 'src' / 'builtins' / 'internal-coverage.tq', + 'src' / 'builtins' / 'internal.tq', + 'src' / 'builtins' / 'iterator.tq', + 'src' / 'builtins' / 'math.tq', + 'src' / 'builtins' / 'number.tq', + 'src' / 'builtins' / 'object-fromentries.tq', + 'src' / 'builtins' / 'object.tq', + 'src' / 'builtins' / 'promise-abstract-operations.tq', + 'src' / 'builtins' / 'promise-all.tq', + 'src' / 'builtins' / 'promise-all-element-closure.tq', + 'src' / 'builtins' / 'promise-any.tq', + 'src' / 'builtins' / 'promise-constructor.tq', + 'src' / 'builtins' / 'promise-finally.tq', + 'src' / 'builtins' / 'promise-misc.tq', + 'src' / 'builtins' / 'promise-race.tq', + 'src' / 'builtins' / 'promise-reaction-job.tq', + 'src' / 'builtins' / 'promise-resolve.tq', + 'src' / 'builtins' / 'promise-then.tq', + 'src' / 'builtins' / 'promise-jobs.tq', + 'src' / 'builtins' / 'proxy-constructor.tq', + 'src' / 'builtins' / 'proxy-delete-property.tq', + 'src' / 'builtins' / 'proxy-get-property.tq', + 'src' / 'builtins' / 'proxy-get-prototype-of.tq', + 'src' / 'builtins' / 'proxy-has-property.tq', + 'src' / 'builtins' / 'proxy-is-extensible.tq', + 'src' / 'builtins' / 'proxy-prevent-extensions.tq', + 'src' / 'builtins' / 'proxy-revocable.tq', + 'src' / 'builtins' / 'proxy-revoke.tq', + 'src' / 'builtins' / 'proxy-set-property.tq', + 'src' / 'builtins' / 'proxy-set-prototype-of.tq', + 'src' / 'builtins' / 'proxy.tq', + 'src' / 'builtins' / 'reflect.tq', + 'src' / 'builtins' / 'regexp-exec.tq', + 'src' / 'builtins' / 'regexp-match-all.tq', + 'src' / 'builtins' / 'regexp-match.tq', + 'src' / 'builtins' / 'regexp-replace.tq', + 'src' / 'builtins' / 'regexp-search.tq', + 'src' / 'builtins' / 'regexp-source.tq', + 'src' / 'builtins' / 'regexp-split.tq', + 'src' / 'builtins' / 'regexp-test.tq', + 'src' / 'builtins' / 'regexp.tq', + 'src' / 'builtins' / 'string-at.tq', + 'src' / 'builtins' / 'string-endswith.tq', + 'src' / 'builtins' / 'string-html.tq', + 'src' / 'builtins' / 'string-includes.tq', + 'src' / 'builtins' / 'string-indexof.tq', + 'src' / 'builtins' / 'string-iterator.tq', + 'src' / 'builtins' / 'string-match-search.tq', + 'src' / 'builtins' / 'string-pad.tq', + 'src' / 'builtins' / 'string-repeat.tq', + 'src' / 'builtins' / 'string-replaceall.tq', + 'src' / 'builtins' / 'string-slice.tq', + 'src' / 'builtins' / 'string-startswith.tq', + 'src' / 'builtins' / 'string-substr.tq', + 'src' / 'builtins' / 'string-substring.tq', + 'src' / 'builtins' / 'string-trim.tq', + 'src' / 'builtins' / 'symbol.tq', + 'src' / 'builtins' / 'torque-internal.tq', + 'src' / 'builtins' / 'typed-array-at.tq', + 'src' / 'builtins' / 'typed-array-createtypedarray.tq', + 'src' / 'builtins' / 'typed-array-every.tq', + 'src' / 'builtins' / 'typed-array-entries.tq', + 'src' / 'builtins' / 'typed-array-filter.tq', + 'src' / 'builtins' / 'typed-array-find.tq', + 'src' / 'builtins' / 'typed-array-findindex.tq', + 'src' / 'builtins' / 'typed-array-findlast.tq', + 'src' / 'builtins' / 'typed-array-findlastindex.tq', + 'src' / 'builtins' / 'typed-array-foreach.tq', + 'src' / 'builtins' / 'typed-array-from.tq', + 'src' / 'builtins' / 'typed-array-keys.tq', + 'src' / 'builtins' / 'typed-array-of.tq', + 'src' / 'builtins' / 'typed-array-reduce.tq', + 'src' / 'builtins' / 'typed-array-reduceright.tq', + 'src' / 'builtins' / 'typed-array-set.tq', + 'src' / 'builtins' / 'typed-array-slice.tq', + 'src' / 'builtins' / 'typed-array-some.tq', + 'src' / 'builtins' / 'typed-array-sort.tq', + 'src' / 'builtins' / 'typed-array-subarray.tq', + 'src' / 'builtins' / 'typed-array-to-reversed.tq', + 'src' / 'builtins' / 'typed-array-to-sorted.tq', + 'src' / 'builtins' / 'typed-array-values.tq', + 'src' / 'builtins' / 'typed-array-with.tq', + 'src' / 'builtins' / 'typed-array.tq', + 'src' / 'builtins' / 'weak-ref.tq', + 'src' / 'ic' / 'handler-configuration.tq', + 'src' / 'objects' / 'allocation-site.tq', + 'src' / 'objects' / 'api-callbacks.tq', + 'src' / 'objects' / 'arguments.tq', + 'src' / 'objects' / 'bigint.tq', + 'src' / 'objects' / 'call-site-info.tq', + 'src' / 'objects' / 'cell.tq', + 'src' / 'objects' / 'code.tq', + 'src' / 'objects' / 'contexts.tq', + 'src' / 'objects' / 'data-handler.tq', + 'src' / 'objects' / 'debug-objects.tq', + 'src' / 'objects' / 'descriptor-array.tq', + 'src' / 'objects' / 'embedder-data-array.tq', + 'src' / 'objects' / 'feedback-cell.tq', + 'src' / 'objects' / 'feedback-vector.tq', + 'src' / 'objects' / 'fixed-array.tq', + 'src' / 'objects' / 'foreign.tq', + 'src' / 'objects' / 'free-space.tq', + 'src' / 'objects' / 'heap-number.tq', + 'src' / 'objects' / 'heap-object.tq', + 'src' / 'objects' / 'js-array-buffer.tq', + 'src' / 'objects' / 'js-array.tq', + 'src' / 'objects' / 'js-atomics-synchronization.tq', + 'src' / 'objects' / 'js-collection-iterator.tq', + 'src' / 'objects' / 'js-collection.tq', + 'src' / 'objects' / 'js-function.tq', + 'src' / 'objects' / 'js-generator.tq', + 'src' / 'objects' / 'js-objects.tq', + 'src' / 'objects' / 'js-promise.tq', + 'src' / 'objects' / 'js-proxy.tq', + 'src' / 'objects' / 'js-raw-json.tq', + 'src' / 'objects' / 'js-regexp-string-iterator.tq', + 'src' / 'objects' / 'js-regexp.tq', + 'src' / 'objects' / 'js-shadow-realm.tq', + 'src' / 'objects' / 'js-shared-array.tq', + 'src' / 'objects' / 'js-struct.tq', + 'src' / 'objects' / 'js-temporal-objects.tq', + 'src' / 'objects' / 'js-weak-refs.tq', + 'src' / 'objects' / 'literal-objects.tq', + 'src' / 'objects' / 'map.tq', + 'src' / 'objects' / 'megadom-handler.tq', + 'src' / 'objects' / 'microtask.tq', + 'src' / 'objects' / 'module.tq', + 'src' / 'objects' / 'name.tq', + 'src' / 'objects' / 'oddball.tq', + 'src' / 'objects' / 'ordered-hash-table.tq', + 'src' / 'objects' / 'primitive-heap-object.tq', + 'src' / 'objects' / 'promise.tq', + 'src' / 'objects' / 'property-array.tq', + 'src' / 'objects' / 'property-cell.tq', + 'src' / 'objects' / 'property-descriptor-object.tq', + 'src' / 'objects' / 'prototype-info.tq', + 'src' / 'objects' / 'regexp-match-info.tq', + 'src' / 'objects' / 'scope-info.tq', + 'src' / 'objects' / 'script.tq', + 'src' / 'objects' / 'shared-function-info.tq', + 'src' / 'objects' / 'source-text-module.tq', + 'src' / 'objects' / 'string.tq', + 'src' / 'objects' / 'struct.tq', + 'src' / 'objects' / 'swiss-hash-table-helpers.tq', + 'src' / 'objects' / 'swiss-name-dictionary.tq', + 'src' / 'objects' / 'synthetic-module.tq', + 'src' / 'objects' / 'template-objects.tq', + 'src' / 'objects' / 'templates.tq', + 'src' / 'objects' / 'torque-defined-classes.tq', + 'src' / 'objects' / 'turbofan-types.tq', + 'test' / 'torque' / 'test-torque.tq', + 'third_party' / 'v8' / 'builtins' / 'array-sort.tq', +] + +if enable_i18n + torque_files += [ + 'src' / 'objects' / 'intl-objects.tq', + 'src' / 'objects' / 'js-break-iterator.tq', + 'src' / 'objects' / 'js-collator.tq', + 'src' / 'objects' / 'js-date-time-format.tq', + 'src' / 'objects' / 'js-display-names.tq', + 'src' / 'objects' / 'js-duration-format.tq', + 'src' / 'objects' / 'js-list-format.tq', + 'src' / 'objects' / 'js-locale.tq', + 'src' / 'objects' / 'js-number-format.tq', + 'src' / 'objects' / 'js-plural-rules.tq', + 'src' / 'objects' / 'js-relative-time-format.tq', + 'src' / 'objects' / 'js-segment-iterator.tq', + 'src' / 'objects' / 'js-segmenter.tq', + 'src' / 'objects' / 'js-segments.tq', + ] +endif + +if enable_wasm + torque_files += [ + 'src' / 'builtins' / 'wasm.tq', + 'src' / 'debug' / 'debug-wasm-objects.tq', + 'src' / 'wasm' / 'wasm-objects.tq', + ] +endif + +torque_inputs = [] +foreach file : torque_files + torque_inputs += meson.project_source_root() / file +endforeach + +torque_outputs_in_root = [ + 'bit-fields.h', + 'builtin-definitions.h', + # 'class-debug-readers.cc', + # 'class-debug-readers.h', + 'class-forward-declarations.h', + 'class-verifiers.cc', + 'class-verifiers.h', + 'csa-types.h', + # 'debug-macros.cc', + # 'debug-macros.h', + 'enum-verifiers.cc', + 'exported-macros-assembler.cc', + 'exported-macros-assembler.h', + 'factory.cc', + 'factory.inc', + 'instance-types.h', + 'interface-descriptors.inc', + 'objects-body-descriptors-inl.inc', + 'objects-printer.cc', + 'visitor-lists.h', +] +torque_outputs_in_subdirs = [] +foreach file : torque_files + filetq = file.replace('/', '_').replace('.tq', '-tq') + torque_outputs_in_subdirs += [ + filetq + '-csa.cc', + filetq + '-csa.h', + filetq + '-inl.inc', + filetq + '.cc', + filetq + '.inc', + ] +endforeach + +torque_dirs = custom_target('v8-torque-dirs', + output: 'torque-dirs.stamp', + command: [ + prepare_codegen, + '--output-directory', '@OUTDIR@', + '--prepare-subdir', 'src' / 'builtins', + '--prepare-subdir', 'src' / 'debug', + '--prepare-subdir', 'src' / 'ic', + '--prepare-subdir', 'src' / 'objects', + '--prepare-subdir', 'src' / 'wasm', + '--prepare-subdir', 'test' / 'torque', + '--prepare-subdir', 'third_party' / 'v8' / 'builtins', + '--touch-stamp-file', '@OUTPUT@', + ], +) + +torque_generated_files_in_root = custom_target('v8-torque-code', + input: [torque_dirs, torque_inputs], + output: torque_outputs_in_root, + command: [ + torque, + '-o', '@OUTDIR@', + '-v8-root', meson.project_source_root(), + torque_files, + ], +) + +torque_generated_files_in_subdirs = custom_target('v8-torque-links', + input: torque_generated_files_in_root, + output: torque_outputs_in_subdirs, + command: [ + commit_codegen, + '--output-directory', '@OUTDIR@', + '--flatten-subdir', 'src' / 'builtins', + '--flatten-subdir', 'src' / 'debug', + '--flatten-subdir', 'src' / 'ic', + '--flatten-subdir', 'src' / 'objects', + '--flatten-subdir', 'src' / 'wasm', + '--flatten-subdir', 'test' / 'torque', + '--flatten-subdir', 'third_party' / 'v8' / 'builtins', + ], +) + +torque_generated_files = torque_generated_files_in_root.to_list() + torque_generated_files_in_subdirs.to_list() + +torque_generated_headers = [] +torque_generated_initializers = [] +torque_generated_definitions = [] +foreach file : torque_generated_files + path = file.full_path() + if path.endswith('.h') + torque_generated_headers += file + elif path.endswith('enum-verifiers.cc') or \ + path.endswith('exported-macros-assembler.cc') or \ + path.endswith('-csa.cc') + torque_generated_initializers += file + elif path.endswith('.cc') + torque_generated_definitions += file + endif +endforeach diff --git a/src/inspector/meson.build b/src/inspector/meson.build new file mode 100644 index 0000000000..9672c69ef0 --- /dev/null +++ b/src/inspector/meson.build @@ -0,0 +1,95 @@ +v8_inspector_sources = [ + 'custom-preview.cc', + 'injected-script.cc', + 'inspected-context.cc', + 'remote-object-id.cc', + 'search-util.cc', + 'string-16.cc', + 'string-util.cc', + 'test-interface.cc', + 'v8-console-agent-impl.cc', + 'v8-console-message.cc', + 'v8-console.cc', + 'v8-debugger-agent-impl.cc', + 'v8-debugger-id.cc', + 'v8-debugger-script.cc', + 'v8-debugger.cc', + 'v8-heap-profiler-agent-impl.cc', + 'v8-inspector-impl.cc', + 'v8-inspector-session-impl.cc', + 'v8-profiler-agent-impl.cc', + 'v8-regex.cc', + 'v8-runtime-agent-impl.cc', + 'v8-schema-agent-impl.cc', + 'v8-stack-trace-impl.cc', + 'v8-value-utils.cc', + 'v8-webdriver-serializer.cc', + 'value-mirror.cc', + 'v8-string-conversions.cc', +] + +v8_inspector_protocol_generated_outputs = [ + 'Debugger.h', + 'Runtime.h', + 'Schema.h', + 'protocol_Forward.h', + 'protocol_Protocol.cpp', + 'protocol_Protocol.h', + 'protocol_Console.cpp', + 'protocol_Console.h', + 'protocol_Debugger.cpp', + 'protocol_Debugger.h', + 'protocol_HeapProfiler.cpp', + 'protocol_HeapProfiler.h', + 'protocol_Profiler.cpp', + 'protocol_Profiler.h', + 'protocol_Runtime.cpp', + 'protocol_Runtime.h', + 'protocol_Schema.cpp', + 'protocol_Schema.h', +] + +v8_inspector_header_install_dir = get_option('includedir') / install_header_subdir / 'inspector' + +v8_inspector_protocol_generated_install_dir = [] +foreach i : range(v8_inspector_protocol_generated_outputs.length()) + if i < 3 + dir = v8_inspector_header_install_dir + else + dir = false + endif + v8_inspector_protocol_generated_install_dir += dir +endforeach + +v8_inspector_protocol_generated_sources = custom_target('v8-inspector-protocol-generated-sources', + input: [ + 'inspector_protocol_config.json', + v8_inspector_js_protocol, + v8_inspector_protocol_templates, + ], + output: v8_inspector_protocol_generated_outputs, + command: [ + run_codegen, + '--output-directory', '@OUTDIR@', + '--link-subdir', '..' / '..' / 'include' / 'inspector', + '--flatten-subdir', 'protocol', + '--', + v8_inspector_protocol_generator, + '--jinja_dir', jinja_dir, + '--output_base', '@OUTDIR@', + '--config', '@INPUT0@', + '--inspector_protocol_dir', v8_inspector_protocol_dir, + '--config_value', 'protocol.path=@INPUT1@', + ], + install: true, + install_dir: v8_inspector_protocol_generated_install_dir, +) + +v8_inspector = static_library('v8-inspector', [ + v8_inspector_sources, + v8_inspector_protocol_generated_sources, + crdtp_sources, + ], + override_options: cpp_options, + dependencies: [v8_libbase_dep], +) diff --git a/src/libplatform/meson.build b/src/libplatform/meson.build new file mode 100644 index 0000000000..099b846c34 --- /dev/null +++ b/src/libplatform/meson.build @@ -0,0 +1,41 @@ +libplatform_sources = [ + 'default-foreground-task-runner.cc', + 'default-job.cc', + 'default-platform.cc', + 'default-worker-threads-task-runner.cc', + 'delayed-task-queue.cc', + 'task-queue.cc', + 'tracing' / 'trace-buffer.cc', + 'tracing' / 'trace-config.cc', + 'tracing' / 'trace-object.cc', + 'tracing' / 'trace-writer.cc', + 'tracing' / 'tracing-controller.cc', + 'worker-thread.cc', +] + +if enable_system_instrumentation + libplatform_sources += 'tracing' / f'recorder-@host_os_nick@.cc' +endif + +v8_libplatform = static_library('v8-libplatform', libplatform_sources, + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_libbase_dep], +) +if meson.can_run_host_binaries() + v8_libplatform_runnable = v8_libplatform +else + v8_libplatform_runnable = static_library('v8-libplatform-native', libplatform_sources, + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_libbase_runnable_dep], + native: true, + ) +endif + +v8_libplatform_dep = declare_dependency( + link_with: v8_libplatform, +) +v8_libplatform_runnable_dep = declare_dependency( + link_with: v8_libplatform_runnable, +) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000000..53662f4d71 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,1061 @@ +subdir('base') + +base_sources = [ + 'api' / 'api-arguments.cc', + 'api' / 'api-natives.cc', + 'api' / 'api.cc', + 'ast' / 'ast-function-literal-id-reindexer.cc', + 'ast' / 'ast-value-factory.cc', + 'ast' / 'ast.cc', + 'ast' / 'modules.cc', + 'ast' / 'prettyprinter.cc', + 'ast' / 'scopes.cc', + 'ast' / 'source-range-ast-visitor.cc', + 'ast' / 'variables.cc', + 'baseline' / 'baseline-batch-compiler.cc', + 'baseline' / 'baseline-compiler.cc', + 'baseline' / 'baseline.cc', + 'baseline' / 'bytecode-offset-iterator.cc', + 'builtins' / 'accessors.cc', + 'builtins' / 'builtins-api.cc', + 'builtins' / 'builtins-array.cc', + 'builtins' / 'builtins-arraybuffer.cc', + 'builtins' / 'builtins-async-module.cc', + 'builtins' / 'builtins-atomics-synchronization.cc', + 'builtins' / 'builtins-bigint.cc', + 'builtins' / 'builtins-callsite.cc', + 'builtins' / 'builtins-collections.cc', + 'builtins' / 'builtins-console.cc', + 'builtins' / 'builtins-dataview.cc', + 'builtins' / 'builtins-date.cc', + 'builtins' / 'builtins-error.cc', + 'builtins' / 'builtins-function.cc', + 'builtins' / 'builtins-global.cc', + 'builtins' / 'builtins-internal.cc', + 'builtins' / 'builtins-json.cc', + 'builtins' / 'builtins-number.cc', + 'builtins' / 'builtins-object.cc', + 'builtins' / 'builtins-reflect.cc', + 'builtins' / 'builtins-regexp.cc', + 'builtins' / 'builtins-shadow-realm.cc', + 'builtins' / 'builtins-shared-array.cc', + 'builtins' / 'builtins-sharedarraybuffer.cc', + 'builtins' / 'builtins-string.cc', + 'builtins' / 'builtins-struct.cc', + 'builtins' / 'builtins-symbol.cc', + 'builtins' / 'builtins-temporal.cc', + 'builtins' / 'builtins-trace.cc', + 'builtins' / 'builtins-typed-array.cc', + 'builtins' / 'builtins-weak-refs.cc', + 'builtins' / 'builtins-web-snapshots.cc', + 'builtins' / 'builtins.cc', + 'builtins' / 'constants-table-builder.cc', + 'codegen' / 'aligned-slot-allocator.cc', + 'codegen' / 'assembler.cc', + 'codegen' / 'bailout-reason.cc', + 'codegen' / 'code-comments.cc', + 'codegen' / 'code-desc.cc', + 'codegen' / 'code-factory.cc', + 'codegen' / 'code-reference.cc', + 'codegen' / 'compilation-cache.cc', + 'codegen' / 'compiler.cc', + 'codegen' / 'constant-pool.cc', + 'codegen' / 'external-reference-encoder.cc', + 'codegen' / 'external-reference-table.cc', + 'codegen' / 'external-reference.cc', + 'codegen' / 'flush-instruction-cache.cc', + 'codegen' / 'handler-table.cc', + 'codegen' / 'interface-descriptors.cc', + 'codegen' / 'machine-type.cc', + 'codegen' / 'maglev-safepoint-table.cc', + 'codegen' / 'optimized-compilation-info.cc', + 'codegen' / 'pending-optimization-table.cc', + 'codegen' / 'register-configuration.cc', + 'codegen' / 'reloc-info.cc', + 'codegen' / 'safepoint-table.cc', + 'codegen' / 'source-position-table.cc', + 'codegen' / 'source-position.cc', + 'codegen' / 'tick-counter.cc', + 'codegen' / 'tnode.cc', + 'codegen' / 'turbo-assembler.cc', + 'codegen' / 'unoptimized-compilation-info.cc', + 'common' / 'assert-scope.cc', + 'common' / 'code-memory-access.cc', + 'compiler-dispatcher' / 'lazy-compile-dispatcher.cc', + 'compiler-dispatcher' / 'optimizing-compile-dispatcher.cc', + 'date' / 'date.cc', + 'date' / 'dateparser.cc', + 'debug' / 'debug-coverage.cc', + 'debug' / 'debug-evaluate.cc', + 'debug' / 'debug-frames.cc', + 'debug' / 'debug-interface.cc', + 'debug' / 'debug-property-iterator.cc', + 'debug' / 'debug-scope-iterator.cc', + 'debug' / 'debug-scopes.cc', + 'debug' / 'debug-stack-trace-iterator.cc', + 'debug' / 'debug.cc', + 'debug' / 'liveedit-diff.cc', + 'debug' / 'liveedit.cc', + 'deoptimizer' / 'deoptimize-reason.cc', + 'deoptimizer' / 'deoptimized-frame-info.cc', + 'deoptimizer' / 'deoptimizer.cc', + 'deoptimizer' / 'materialized-object-store.cc', + 'deoptimizer' / 'translated-state.cc', + 'deoptimizer' / 'translation-array.cc', + 'diagnostics' / 'basic-block-profiler.cc', + 'diagnostics' / 'compilation-statistics.cc', + 'diagnostics' / 'disassembler.cc', + 'diagnostics' / 'eh-frame.cc', + 'diagnostics' / 'gdb-jit.cc', + 'diagnostics' / 'objects-debug.cc', + 'diagnostics' / 'objects-printer.cc', + 'diagnostics' / 'perf-jit.cc', + 'diagnostics' / 'unwinder.cc', + 'execution' / 'arguments.cc', + 'execution' / 'clobber-registers.cc', + 'execution' / 'embedder-state.cc', + 'execution' / 'encoded-c-signature.cc', + 'execution' / 'execution.cc', + 'execution' / 'frames.cc', + 'execution' / 'futex-emulation.cc', + 'execution' / 'interrupts-scope.cc', + 'execution' / 'isolate.cc', + 'execution' / 'local-isolate.cc', + 'execution' / 'messages.cc', + 'execution' / 'microtask-queue.cc', + 'execution' / 'protectors.cc', + 'execution' / 'simulator-base.cc', + 'execution' / 'stack-guard.cc', + 'execution' / 'thread-id.cc', + 'execution' / 'thread-local-top.cc', + 'execution' / 'tiering-manager.cc', + 'execution' / 'v8threads.cc', + 'extensions' / 'cputracemark-extension.cc', + 'extensions' / 'externalize-string-extension.cc', + 'extensions' / 'gc-extension.cc', + 'extensions' / 'ignition-statistics-extension.cc', + 'extensions' / 'statistics-extension.cc', + 'extensions' / 'trigger-failure-extension.cc', + 'flags' / 'flags.cc', + 'handles' / 'global-handles.cc', + 'handles' / 'handles.cc', + 'handles' / 'local-handles.cc', + 'handles' / 'persistent-handles.cc', + 'handles' / 'shared-object-conveyor-handles.cc', + 'bigint' / 'bigint-internal.cc', + 'bigint' / 'bitwise.cc', + 'bigint' / 'div-burnikel.cc', + 'bigint' / 'div-helpers.cc', + 'bigint' / 'div-schoolbook.cc', + 'bigint' / 'fromstring.cc', + 'bigint' / 'mul-karatsuba.cc', + 'bigint' / 'mul-schoolbook.cc', + 'bigint' / 'tostring.cc', + 'bigint' / 'vector-arithmetic.cc', + 'heap' / 'allocation-observer.cc', + 'heap' / 'array-buffer-sweeper.cc', + 'heap' / 'base-space.cc', + 'heap' / 'basic-memory-chunk.cc', + 'heap' / 'code-object-registry.cc', + 'heap' / 'code-range.cc', + 'heap' / 'code-stats.cc', + 'heap' / 'collection-barrier.cc', + 'heap' / 'combined-heap.cc', + 'heap' / 'concurrent-allocator.cc', + 'heap' / 'concurrent-marking.cc', + 'heap' / 'cppgc-js' / 'cpp-heap.cc', + 'heap' / 'cppgc-js' / 'cpp-snapshot.cc', + 'heap' / 'cppgc-js' / 'unified-heap-marking-state.cc', + 'heap' / 'cppgc-js' / 'unified-heap-marking-verifier.cc', + 'heap' / 'cppgc-js' / 'unified-heap-marking-visitor.cc', + 'heap' / 'embedder-tracing.cc', + 'heap' / 'evacuation-verifier.cc', + 'heap' / 'factory-base.cc', + 'heap' / 'factory.cc', + 'heap' / 'finalization-registry-cleanup-task.cc', + 'heap' / 'free-list.cc', + 'heap' / 'gc-idle-time-handler.cc', + 'heap' / 'gc-tracer.cc', + 'heap' / 'global-handle-marking-visitor.cc', + 'heap' / 'heap-allocator.cc', + 'heap' / 'heap-controller.cc', + 'heap' / 'heap-layout-tracer.cc', + 'heap' / 'heap-verifier.cc', + 'heap' / 'heap-write-barrier.cc', + 'heap' / 'heap.cc', + 'heap' / 'incremental-marking-job.cc', + 'heap' / 'incremental-marking.cc', + 'heap' / 'index-generator.cc', + 'heap' / 'invalidated-slots.cc', + 'heap' / 'large-spaces.cc', + 'heap' / 'local-factory.cc', + 'heap' / 'local-heap.cc', + 'heap' / 'mark-compact.cc', + 'heap' / 'marking-barrier.cc', + 'heap' / 'marking-worklist.cc', + 'heap' / 'marking.cc', + 'heap' / 'memory-allocator.cc', + 'heap' / 'memory-chunk-layout.cc', + 'heap' / 'memory-chunk.cc', + 'heap' / 'memory-measurement.cc', + 'heap' / 'memory-reducer.cc', + 'heap' / 'new-spaces.cc', + 'heap' / 'object-stats.cc', + 'heap' / 'objects-visiting.cc', + 'heap' / 'paged-spaces.cc', + 'heap' / 'pretenuring-handler.cc', + 'heap' / 'read-only-heap.cc', + 'heap' / 'read-only-spaces.cc', + 'heap' / 'safepoint.cc', + 'heap' / 'scavenge-job.cc', + 'heap' / 'scavenger.cc', + 'heap' / 'slot-set.cc', + 'heap' / 'spaces.cc', + 'heap' / 'stress-marking-observer.cc', + 'heap' / 'stress-scavenge-observer.cc', + 'heap' / 'sweeper.cc', + 'heap' / 'weak-object-worklists.cc', + 'heap' / 'third-party' / 'heap-api-stub.cc', + 'heap' / 'base' / 'active-system-pages.cc', + 'heap' / 'base' / 'stack.cc', + 'heap' / 'base' / 'worklist.cc', + 'heap' / 'cppgc' / 'allocation.cc', + 'heap' / 'cppgc' / 'compaction-worklists.cc', + 'heap' / 'cppgc' / 'compactor.cc', + 'heap' / 'cppgc' / 'concurrent-marker.cc', + 'heap' / 'cppgc' / 'explicit-management.cc', + 'heap' / 'cppgc' / 'free-list.cc', + 'heap' / 'cppgc' / 'gc-info-table.cc', + 'heap' / 'cppgc' / 'gc-info.cc', + 'heap' / 'cppgc' / 'gc-invoker.cc', + 'heap' / 'cppgc' / 'heap-base.cc', + 'heap' / 'cppgc' / 'heap-consistency.cc', + 'heap' / 'cppgc' / 'heap-growing.cc', + 'heap' / 'cppgc' / 'heap-object-header.cc', + 'heap' / 'cppgc' / 'heap-page.cc', + 'heap' / 'cppgc' / 'heap-space.cc', + 'heap' / 'cppgc' / 'heap-state.cc', + 'heap' / 'cppgc' / 'heap-statistics-collector.cc', + 'heap' / 'cppgc' / 'heap.cc', + 'heap' / 'cppgc' / 'incremental-marking-schedule.cc', + 'heap' / 'cppgc' / 'liveness-broker.cc', + 'heap' / 'cppgc' / 'logging.cc', + 'heap' / 'cppgc' / 'marker.cc', + 'heap' / 'cppgc' / 'marking-state.cc', + 'heap' / 'cppgc' / 'marking-verifier.cc', + 'heap' / 'cppgc' / 'marking-visitor.cc', + 'heap' / 'cppgc' / 'marking-worklists.cc', + 'heap' / 'cppgc' / 'member-storage.cc', + 'heap' / 'cppgc' / 'memory.cc', + 'heap' / 'cppgc' / 'name-trait.cc', + 'heap' / 'cppgc' / 'object-allocator.cc', + 'heap' / 'cppgc' / 'object-size-trait.cc', + 'heap' / 'cppgc' / 'page-memory.cc', + 'heap' / 'cppgc' / 'persistent-node.cc', + 'heap' / 'cppgc' / 'platform.cc', + 'heap' / 'cppgc' / 'pointer-policies.cc', + 'heap' / 'cppgc' / 'prefinalizer-handler.cc', + 'heap' / 'cppgc' / 'process-heap-statistics.cc', + 'heap' / 'cppgc' / 'process-heap.cc', + 'heap' / 'cppgc' / 'raw-heap.cc', + 'heap' / 'cppgc' / 'remembered-set.cc', + 'heap' / 'cppgc' / 'source-location.cc', + 'heap' / 'cppgc' / 'stats-collector.cc', + 'heap' / 'cppgc' / 'sweeper.cc', + 'heap' / 'cppgc' / 'testing.cc', + 'heap' / 'cppgc' / 'trace-trait.cc', + 'heap' / 'cppgc' / 'virtual-memory.cc', + 'heap' / 'cppgc' / 'visitor.cc', + 'heap' / 'cppgc' / 'write-barrier.cc', + 'ic' / 'call-optimization.cc', + 'ic' / 'handler-configuration.cc', + 'ic' / 'ic-stats.cc', + 'ic' / 'ic.cc', + 'ic' / 'stub-cache.cc', + 'init' / 'bootstrapper.cc', + 'init' / 'icu_util.cc', + 'init' / 'isolate-allocator.cc', + 'init' / 'startup-data-util.cc', + 'init' / 'v8.cc', + 'interpreter' / 'bytecode-array-builder.cc', + 'interpreter' / 'bytecode-array-iterator.cc', + 'interpreter' / 'bytecode-array-random-iterator.cc', + 'interpreter' / 'bytecode-array-writer.cc', + 'interpreter' / 'bytecode-decoder.cc', + 'interpreter' / 'bytecode-flags.cc', + 'interpreter' / 'bytecode-generator.cc', + 'interpreter' / 'bytecode-label.cc', + 'interpreter' / 'bytecode-node.cc', + 'interpreter' / 'bytecode-operands.cc', + 'interpreter' / 'bytecode-register-optimizer.cc', + 'interpreter' / 'bytecode-register.cc', + 'interpreter' / 'bytecode-source-info.cc', + 'interpreter' / 'bytecodes.cc', + 'interpreter' / 'constant-array-builder.cc', + 'interpreter' / 'control-flow-builders.cc', + 'interpreter' / 'handler-table-builder.cc', + 'interpreter' / 'interpreter-intrinsics.cc', + 'interpreter' / 'interpreter.cc', + 'json' / 'json-parser.cc', + 'json' / 'json-stringifier.cc', + 'libsampler' / 'sampler.cc', + 'logging' / 'counters.cc', + 'logging' / 'local-logger.cc', + 'logging' / 'log-file.cc', + 'logging' / 'log.cc', + 'logging' / 'metrics.cc', + 'logging' / 'runtime-call-stats.cc', + 'logging' / 'tracing-flags.cc', + 'numbers' / 'conversions.cc', + 'numbers' / 'math-random.cc', + 'objects' / 'backing-store.cc', + 'objects' / 'bigint.cc', + 'objects' / 'call-site-info.cc', + 'objects' / 'code-kind.cc', + 'objects' / 'code.cc', + 'objects' / 'compilation-cache-table.cc', + 'objects' / 'contexts.cc', + 'objects' / 'debug-objects.cc', + 'objects' / 'elements-kind.cc', + 'objects' / 'elements.cc', + 'objects' / 'embedder-data-array.cc', + 'objects' / 'feedback-vector.cc', + 'objects' / 'field-type.cc', + 'objects' / 'js-array-buffer.cc', + 'objects' / 'js-atomics-synchronization.cc', + 'objects' / 'js-function.cc', + 'objects' / 'js-objects.cc', + 'objects' / 'js-raw-json.cc', + 'objects' / 'js-regexp.cc', + 'objects' / 'js-temporal-objects.cc', + 'objects' / 'keys.cc', + 'objects' / 'literal-objects.cc', + 'objects' / 'lookup-cache.cc', + 'objects' / 'lookup.cc', + 'objects' / 'managed.cc', + 'objects' / 'map-updater.cc', + 'objects' / 'map.cc', + 'objects' / 'module.cc', + 'objects' / 'object-type.cc', + 'objects' / 'objects.cc', + 'objects' / 'option-utils.cc', + 'objects' / 'ordered-hash-table.cc', + 'objects' / 'property-descriptor.cc', + 'objects' / 'property.cc', + 'objects' / 'scope-info.cc', + 'objects' / 'shared-function-info.cc', + 'objects' / 'simd.cc', + 'objects' / 'source-text-module.cc', + 'objects' / 'string-comparator.cc', + 'objects' / 'string-forwarding-table.cc', + 'objects' / 'string-table.cc', + 'objects' / 'string.cc', + 'objects' / 'swiss-name-dictionary.cc', + 'objects' / 'symbol-table.cc', + 'objects' / 'synthetic-module.cc', + 'objects' / 'tagged-impl.cc', + 'objects' / 'template-objects.cc', + 'objects' / 'templates.cc', + 'objects' / 'transitions.cc', + 'objects' / 'type-hints.cc', + 'objects' / 'value-serializer.cc', + 'objects' / 'visitors.cc', + 'parsing' / 'func-name-inferrer.cc', + 'parsing' / 'import-assertions.cc', + 'parsing' / 'literal-buffer.cc', + 'parsing' / 'parse-info.cc', + 'parsing' / 'parser.cc', + 'parsing' / 'parsing.cc', + 'parsing' / 'pending-compilation-error-handler.cc', + 'parsing' / 'preparse-data.cc', + 'parsing' / 'preparser.cc', + 'parsing' / 'rewriter.cc', + 'parsing' / 'scanner-character-streams.cc', + 'parsing' / 'scanner.cc', + 'parsing' / 'token.cc', + 'profiler' / 'allocation-tracker.cc', + 'profiler' / 'cpu-profiler.cc', + 'profiler' / 'heap-profiler.cc', + 'profiler' / 'heap-snapshot-generator.cc', + 'profiler' / 'profile-generator.cc', + 'profiler' / 'profiler-listener.cc', + 'profiler' / 'profiler-stats.cc', + 'profiler' / 'sampling-heap-profiler.cc', + 'profiler' / 'strings-storage.cc', + 'profiler' / 'symbolizer.cc', + 'profiler' / 'tick-sample.cc', + 'profiler' / 'tracing-cpu-profiler.cc', + 'profiler' / 'weak-code-registry.cc', + 'regexp' / 'experimental' / 'experimental-bytecode.cc', + 'regexp' / 'experimental' / 'experimental-compiler.cc', + 'regexp' / 'experimental' / 'experimental-interpreter.cc', + 'regexp' / 'experimental' / 'experimental.cc', + 'regexp' / 'regexp-ast.cc', + 'regexp' / 'regexp-bytecode-generator.cc', + 'regexp' / 'regexp-bytecode-peephole.cc', + 'regexp' / 'regexp-bytecodes.cc', + 'regexp' / 'regexp-compiler-tonode.cc', + 'regexp' / 'regexp-compiler.cc', + 'regexp' / 'regexp-dotprinter.cc', + 'regexp' / 'regexp-error.cc', + 'regexp' / 'regexp-interpreter.cc', + 'regexp' / 'regexp-macro-assembler-tracer.cc', + 'regexp' / 'regexp-macro-assembler.cc', + 'regexp' / 'regexp-parser.cc', + 'regexp' / 'regexp-stack.cc', + 'regexp' / 'regexp-utils.cc', + 'regexp' / 'regexp.cc', + 'roots' / 'roots.cc', + 'runtime' / 'runtime-array.cc', + 'runtime' / 'runtime-atomics.cc', + 'runtime' / 'runtime-bigint.cc', + 'runtime' / 'runtime-classes.cc', + 'runtime' / 'runtime-collections.cc', + 'runtime' / 'runtime-compiler.cc', + 'runtime' / 'runtime-date.cc', + 'runtime' / 'runtime-debug.cc', + 'runtime' / 'runtime-forin.cc', + 'runtime' / 'runtime-function.cc', + 'runtime' / 'runtime-futex.cc', + 'runtime' / 'runtime-generator.cc', + 'runtime' / 'runtime-internal.cc', + 'runtime' / 'runtime-literals.cc', + 'runtime' / 'runtime-module.cc', + 'runtime' / 'runtime-numbers.cc', + 'runtime' / 'runtime-object.cc', + 'runtime' / 'runtime-operators.cc', + 'runtime' / 'runtime-promise.cc', + 'runtime' / 'runtime-proxy.cc', + 'runtime' / 'runtime-regexp.cc', + 'runtime' / 'runtime-scopes.cc', + 'runtime' / 'runtime-shadow-realm.cc', + 'runtime' / 'runtime-strings.cc', + 'runtime' / 'runtime-symbol.cc', + 'runtime' / 'runtime-temporal.cc', + 'runtime' / 'runtime-test.cc', + 'runtime' / 'runtime-trace.cc', + 'runtime' / 'runtime-typedarray.cc', + 'runtime' / 'runtime-weak-refs.cc', + 'runtime' / 'runtime.cc', + 'sandbox' / 'external-pointer-table.cc', + 'sandbox' / 'sandbox.cc', + 'sandbox' / 'testing.cc', + 'snapshot' / 'code-serializer.cc', + 'snapshot' / 'context-deserializer.cc', + 'snapshot' / 'context-serializer.cc', + 'snapshot' / 'deserializer.cc', + 'snapshot' / 'embedded' / 'embedded-data.cc', + 'snapshot' / 'object-deserializer.cc', + 'snapshot' / 'read-only-deserializer.cc', + 'snapshot' / 'read-only-serializer.cc', + 'snapshot' / 'roots-serializer.cc', + 'snapshot' / 'serializer-deserializer.cc', + 'snapshot' / 'serializer.cc', + 'snapshot' / 'shared-heap-deserializer.cc', + 'snapshot' / 'shared-heap-serializer.cc', + 'snapshot' / 'snapshot-compression.cc', + 'snapshot' / 'snapshot-data.cc', + 'snapshot' / 'snapshot-source-sink.cc', + 'snapshot' / 'snapshot-utils.cc', + 'snapshot' / 'snapshot.cc', + 'snapshot' / 'startup-deserializer.cc', + 'snapshot' / 'startup-serializer.cc', + 'strings' / 'string-builder.cc', + 'strings' / 'string-case.cc', + 'strings' / 'string-stream.cc', + 'strings' / 'unicode-decoder.cc', + 'strings' / 'unicode.cc', + 'strings' / 'uri.cc', + 'tasks' / 'cancelable-task.cc', + 'tasks' / 'operations-barrier.cc', + 'tasks' / 'task-utils.cc', + 'temporal' / 'temporal-parser.cc', + 'third_party' / 'siphash' / 'halfsiphash.cc', + 'tracing' / 'trace-event.cc', + 'tracing' / 'traced-value.cc', + 'tracing' / 'tracing-category-observer.cc', + 'utils' / 'address-map.cc', + 'utils' / 'allocation.cc', + 'utils' / 'bit-vector.cc', + 'utils' / 'detachable-vector.cc', + 'utils' / 'identity-map.cc', + 'utils' / 'memcopy.cc', + 'utils' / 'ostreams.cc', + 'utils' / 'utils.cc', + 'utils' / 'version.cc', + 'web-snapshot' / 'web-snapshot.cc', + 'zone' / 'accounting-allocator.cc', + 'zone' / 'type-stats.cc', + 'zone' / 'zone-segment.cc', + 'zone' / 'zone.cc', + 'compiler' / 'access-builder.cc', + 'compiler' / 'access-info.cc', + 'compiler' / 'add-type-assertions-reducer.cc', + 'compiler' / 'all-nodes.cc', + 'compiler' / 'backend' / 'code-generator.cc', + 'compiler' / 'backend' / 'frame-elider.cc', + 'compiler' / 'backend' / 'gap-resolver.cc', + 'compiler' / 'backend' / 'instruction-scheduler.cc', + 'compiler' / 'backend' / 'instruction-selector.cc', + 'compiler' / 'backend' / 'instruction.cc', + 'compiler' / 'backend' / 'jump-threading.cc', + 'compiler' / 'backend' / 'mid-tier-register-allocator.cc', + 'compiler' / 'backend' / 'move-optimizer.cc', + 'compiler' / 'backend' / 'register-allocator-verifier.cc', + 'compiler' / 'backend' / 'register-allocator.cc', + 'compiler' / 'backend' / 'spill-placer.cc', + 'compiler' / 'basic-block-instrumentor.cc', + 'compiler' / 'branch-condition-duplicator.cc', + 'compiler' / 'branch-elimination.cc', + 'compiler' / 'bytecode-analysis.cc', + 'compiler' / 'bytecode-graph-builder.cc', + 'compiler' / 'bytecode-liveness-map.cc', + 'compiler' / 'c-linkage.cc', + 'compiler' / 'checkpoint-elimination.cc', + 'compiler' / 'code-assembler.cc', + 'compiler' / 'common-node-cache.cc', + 'compiler' / 'common-operator-reducer.cc', + 'compiler' / 'common-operator.cc', + 'compiler' / 'compilation-dependencies.cc', + 'compiler' / 'compiler-source-position-table.cc', + 'compiler' / 'constant-folding-reducer.cc', + 'compiler' / 'control-equivalence.cc', + 'compiler' / 'control-flow-optimizer.cc', + 'compiler' / 'csa-load-elimination.cc', + 'compiler' / 'dead-code-elimination.cc', + 'compiler' / 'decompression-optimizer.cc', + 'compiler' / 'effect-control-linearizer.cc', + 'compiler' / 'escape-analysis-reducer.cc', + 'compiler' / 'escape-analysis.cc', + 'compiler' / 'fast-api-calls.cc', + 'compiler' / 'feedback-source.cc', + 'compiler' / 'frame-states.cc', + 'compiler' / 'frame.cc', + 'compiler' / 'graph-assembler.cc', + 'compiler' / 'graph-reducer.cc', + 'compiler' / 'graph-trimmer.cc', + 'compiler' / 'graph-visualizer.cc', + 'compiler' / 'graph.cc', + 'compiler' / 'heap-refs.cc', + 'compiler' / 'js-call-reducer.cc', + 'compiler' / 'js-context-specialization.cc', + 'compiler' / 'js-create-lowering.cc', + 'compiler' / 'js-generic-lowering.cc', + 'compiler' / 'js-graph.cc', + 'compiler' / 'js-heap-broker.cc', + 'compiler' / 'js-inlining-heuristic.cc', + 'compiler' / 'js-inlining.cc', + 'compiler' / 'js-intrinsic-lowering.cc', + 'compiler' / 'js-native-context-specialization.cc', + 'compiler' / 'js-operator.cc', + 'compiler' / 'js-type-hint-lowering.cc', + 'compiler' / 'js-typed-lowering.cc', + 'compiler' / 'late-escape-analysis.cc', + 'compiler' / 'linkage.cc', + 'compiler' / 'load-elimination.cc', + 'compiler' / 'loop-analysis.cc', + 'compiler' / 'loop-peeling.cc', + 'compiler' / 'loop-unrolling.cc', + 'compiler' / 'loop-variable-optimizer.cc', + 'compiler' / 'machine-graph-verifier.cc', + 'compiler' / 'machine-graph.cc', + 'compiler' / 'machine-operator-reducer.cc', + 'compiler' / 'machine-operator.cc', + 'compiler' / 'map-inference.cc', + 'compiler' / 'memory-lowering.cc', + 'compiler' / 'memory-optimizer.cc', + 'compiler' / 'node-marker.cc', + 'compiler' / 'node-matchers.cc', + 'compiler' / 'node-observer.cc', + 'compiler' / 'node-origin-table.cc', + 'compiler' / 'node-properties.cc', + 'compiler' / 'node.cc', + 'compiler' / 'opcodes.cc', + 'compiler' / 'operation-typer.cc', + 'compiler' / 'operator-properties.cc', + 'compiler' / 'operator.cc', + 'compiler' / 'osr.cc', + 'compiler' / 'pipeline-statistics.cc', + 'compiler' / 'pipeline.cc', + 'compiler' / 'property-access-builder.cc', + 'compiler' / 'raw-machine-assembler.cc', + 'compiler' / 'redundancy-elimination.cc', + 'compiler' / 'refs-map.cc', + 'compiler' / 'representation-change.cc', + 'compiler' / 'schedule.cc', + 'compiler' / 'scheduler.cc', + 'compiler' / 'select-lowering.cc', + 'compiler' / 'simplified-lowering-verifier.cc', + 'compiler' / 'simplified-lowering.cc', + 'compiler' / 'simplified-operator-reducer.cc', + 'compiler' / 'simplified-operator.cc', + 'compiler' / 'state-values-utils.cc', + 'compiler' / 'store-store-elimination.cc', + 'compiler' / 'type-cache.cc', + 'compiler' / 'type-narrowing-reducer.cc', + 'compiler' / 'typed-optimization.cc', + 'compiler' / 'typer.cc', + 'compiler' / 'types.cc', + 'compiler' / 'value-numbering-reducer.cc', + 'compiler' / 'verifier.cc', + 'compiler' / 'zone-stats.cc', + 'compiler' / 'turboshaft' / 'decompression-optimization.cc', + 'compiler' / 'turboshaft' / 'graph-builder.cc', + 'compiler' / 'turboshaft' / 'graph-visualizer.cc', + 'compiler' / 'turboshaft' / 'graph.cc', + 'compiler' / 'turboshaft' / 'operations.cc', + 'compiler' / 'turboshaft' / 'optimization-phase.cc', + 'compiler' / 'turboshaft' / 'recreate-schedule.cc', + 'compiler' / 'turboshaft' / 'representations.cc', + 'compiler' / 'turboshaft' / 'simplify-tf-loops.cc', + 'compiler' / 'turboshaft' / 'utils.cc', + 'utils' / 'hex-format.cc', + 'utils' / 'sha-256.cc', +] + +if host_os == 'win' and host_is_64bit + base_sources += 'diagnostics' / 'unwinding-info-win64.cc' +endif + +if enable_advanced_bigint_algorithms + base_sources += [ + 'bigint' / 'div-barrett.cc', + 'bigint' / 'mul-fft.cc', + 'bigint' / 'mul-toom.cc', + ] +endif + +if enable_cppgc_caged_heap + base_sources += [ + 'heap' / 'cppgc' / 'caged-heap-local-data.cc', + 'heap' / 'cppgc' / 'caged-heap.cc', + ] +endif + +if enable_i18n + base_sources += [ + 'builtins' / 'builtins-intl.cc', + 'objects' / 'intl-objects.cc', + 'objects' / 'js-break-iterator.cc', + 'objects' / 'js-collator.cc', + 'objects' / 'js-date-time-format.cc', + 'objects' / 'js-display-names.cc', + 'objects' / 'js-duration-format.cc', + 'objects' / 'js-list-format.cc', + 'objects' / 'js-locale.cc', + 'objects' / 'js-number-format.cc', + 'objects' / 'js-plural-rules.cc', + 'objects' / 'js-relative-time-format.cc', + 'objects' / 'js-segment-iterator.cc', + 'objects' / 'js-segmenter.cc', + 'objects' / 'js-segments.cc', + 'runtime' / 'runtime-intl.cc', + 'strings' / 'char-predicates.cc', + ] +endif + +if enable_maglev + base_sources += [ + 'maglev' / 'maglev-code-generator.cc', + 'maglev' / 'maglev-compilation-info.cc', + 'maglev' / 'maglev-compilation-unit.cc', + 'maglev' / 'maglev-compiler.cc', + 'maglev' / 'maglev-concurrent-dispatcher.cc', + 'maglev' / 'maglev-graph-builder.cc', + 'maglev' / 'maglev-graph-printer.cc', + 'maglev' / 'maglev-interpreter-frame-state.cc', + 'maglev' / 'maglev-ir.cc', + 'maglev' / 'maglev-regalloc.cc', + 'maglev' / 'maglev.cc', + ] +endif + +if enable_wasm + base_sources += [ + 'asmjs' / 'asm-js.cc', + 'asmjs' / 'asm-parser.cc', + 'asmjs' / 'asm-scanner.cc', + 'asmjs' / 'asm-types.cc', + 'debug' / 'debug-wasm-objects.cc', + 'runtime' / 'runtime-test-wasm.cc', + 'runtime' / 'runtime-wasm.cc', + 'trap-handler' / 'handler-inside.cc', + 'trap-handler' / 'handler-outside.cc', + 'trap-handler' / 'handler-shared.cc', + 'wasm' / 'assembler-buffer-cache.cc', + 'wasm' / 'baseline' / 'liftoff-assembler.cc', + 'wasm' / 'baseline' / 'liftoff-compiler.cc', + 'wasm' / 'canonical-types.cc', + 'wasm' / 'code-space-access.cc', + 'wasm' / 'constant-expression-interface.cc', + 'wasm' / 'constant-expression.cc', + 'wasm' / 'function-body-decoder.cc', + 'wasm' / 'function-compiler.cc', + 'wasm' / 'graph-builder-interface.cc', + 'wasm' / 'jump-table-assembler.cc', + 'wasm' / 'local-decl-encoder.cc', + 'wasm' / 'memory-tracing.cc', + 'wasm' / 'module-compiler.cc', + 'wasm' / 'module-decoder.cc', + 'wasm' / 'module-instantiate.cc', + 'wasm' / 'names-provider.cc', + 'wasm' / 'pgo.cc', + 'wasm' / 'simd-shuffle.cc', + 'wasm' / 'stacks.cc', + 'wasm' / 'streaming-decoder.cc', + 'wasm' / 'sync-streaming-decoder.cc', + 'wasm' / 'value-type.cc', + 'wasm' / 'wasm-code-manager.cc', + 'wasm' / 'wasm-debug.cc', + 'wasm' / 'wasm-disassembler.cc', + 'wasm' / 'wasm-engine.cc', + 'wasm' / 'wasm-external-refs.cc', + 'wasm' / 'wasm-features.cc', + 'wasm' / 'wasm-import-wrapper-cache.cc', + 'wasm' / 'wasm-init-expr.cc', + 'wasm' / 'wasm-js.cc', + 'wasm' / 'wasm-module-builder.cc', + 'wasm' / 'wasm-module-sourcemap.cc', + 'wasm' / 'wasm-module.cc', + 'wasm' / 'wasm-objects.cc', + 'wasm' / 'wasm-opcodes.cc', + 'wasm' / 'wasm-result.cc', + 'wasm' / 'wasm-serialization.cc', + 'wasm' / 'wasm-subtyping.cc', + 'compiler' / 'int64-lowering.cc', + 'compiler' / 'wasm-compiler.cc', + 'compiler' / 'wasm-escape-analysis.cc', + 'compiler' / 'wasm-gc-lowering.cc', + 'compiler' / 'wasm-gc-operator-reducer.cc', + 'compiler' / 'wasm-graph-assembler.cc', + 'compiler' / 'wasm-inlining.cc', + 'compiler' / 'wasm-loop-peeling.cc', + 'compiler' / 'wasm-typer.cc', + ] +endif + +base_backend_sources = { + 'ia32': [ + 'codegen' / 'ia32' / 'assembler-ia32.cc', + 'codegen' / 'ia32' / 'cpu-ia32.cc', + 'codegen' / 'ia32' / 'macro-assembler-ia32.cc', + 'codegen' / 'shared-ia32-x64' / 'macro-assembler-shared-ia32-x64.cc', + 'compiler' / 'backend' / 'ia32' / 'code-generator-ia32.cc', + 'compiler' / 'backend' / 'ia32' / 'instruction-scheduler-ia32.cc', + 'compiler' / 'backend' / 'ia32' / 'instruction-selector-ia32.cc', + 'deoptimizer' / 'ia32' / 'deoptimizer-ia32.cc', + 'diagnostics' / 'ia32' / 'disasm-ia32.cc', + 'diagnostics' / 'ia32' / 'unwinder-ia32.cc', + 'execution' / 'ia32' / 'frame-constants-ia32.cc', + 'regexp' / 'ia32' / 'regexp-macro-assembler-ia32.cc', + ], + 'x64': [ + 'codegen' / 'shared-ia32-x64' / 'macro-assembler-shared-ia32-x64.cc', + 'codegen' / 'x64' / 'assembler-x64.cc', + 'codegen' / 'x64' / 'cpu-x64.cc', + 'codegen' / 'x64' / 'macro-assembler-x64.cc', + 'compiler' / 'backend' / 'x64' / 'code-generator-x64.cc', + 'compiler' / 'backend' / 'x64' / 'instruction-scheduler-x64.cc', + 'compiler' / 'backend' / 'x64' / 'instruction-selector-x64.cc', + 'compiler' / 'backend' / 'x64' / 'unwinding-info-writer-x64.cc', + 'deoptimizer' / 'x64' / 'deoptimizer-x64.cc', + 'diagnostics' / 'x64' / 'disasm-x64.cc', + 'diagnostics' / 'x64' / 'eh-frame-x64.cc', + 'diagnostics' / 'x64' / 'unwinder-x64.cc', + 'execution' / 'x64' / 'frame-constants-x64.cc', + 'regexp' / 'x64' / 'regexp-macro-assembler-x64.cc', + ], + 'arm': [ + 'codegen' / 'arm' / 'assembler-arm.cc', + 'codegen' / 'arm' / 'constants-arm.cc', + 'codegen' / 'arm' / 'cpu-arm.cc', + 'codegen' / 'arm' / 'macro-assembler-arm.cc', + 'compiler' / 'backend' / 'arm' / 'code-generator-arm.cc', + 'compiler' / 'backend' / 'arm' / 'instruction-scheduler-arm.cc', + 'compiler' / 'backend' / 'arm' / 'instruction-selector-arm.cc', + 'compiler' / 'backend' / 'arm' / 'unwinding-info-writer-arm.cc', + 'deoptimizer' / 'arm' / 'deoptimizer-arm.cc', + 'diagnostics' / 'arm' / 'disasm-arm.cc', + 'diagnostics' / 'arm' / 'eh-frame-arm.cc', + 'diagnostics' / 'arm' / 'unwinder-arm.cc', + 'execution' / 'arm' / 'frame-constants-arm.cc', + 'execution' / 'arm' / 'simulator-arm.cc', + 'regexp' / 'arm' / 'regexp-macro-assembler-arm.cc', + ], + 'arm64': [ + 'codegen' / 'arm64' / 'assembler-arm64.cc', + 'codegen' / 'arm64' / 'cpu-arm64.cc', + 'codegen' / 'arm64' / 'decoder-arm64.cc', + 'codegen' / 'arm64' / 'instructions-arm64-constants.cc', + 'codegen' / 'arm64' / 'instructions-arm64.cc', + 'codegen' / 'arm64' / 'macro-assembler-arm64.cc', + 'codegen' / 'arm64' / 'register-arm64.cc', + 'codegen' / 'arm64' / 'utils-arm64.cc', + 'compiler' / 'backend' / 'arm64' / 'code-generator-arm64.cc', + 'compiler' / 'backend' / 'arm64' / 'instruction-scheduler-arm64.cc', + 'compiler' / 'backend' / 'arm64' / 'instruction-selector-arm64.cc', + 'compiler' / 'backend' / 'arm64' / 'unwinding-info-writer-arm64.cc', + 'deoptimizer' / 'arm64' / 'deoptimizer-arm64.cc', + 'diagnostics' / 'arm64' / 'disasm-arm64.cc', + 'diagnostics' / 'arm64' / 'eh-frame-arm64.cc', + 'diagnostics' / 'arm64' / 'unwinder-arm64.cc', + 'execution' / 'arm64' / 'frame-constants-arm64.cc', + 'execution' / 'arm64' / 'pointer-auth-arm64.cc', + 'execution' / 'arm64' / 'simulator-arm64.cc', + 'execution' / 'arm64' / 'simulator-logic-arm64.cc', + 'regexp' / 'arm64' / 'regexp-macro-assembler-arm64.cc', + ], +} + +base_generic_asm_sources = { + 'ia32': [ + 'heap' / 'base' / 'asm' / 'ia32' / 'push_registers_asm.cc', + ], + 'x64': [ + 'heap' / 'base' / 'asm' / 'x64' / 'push_registers_asm.cc', + ], + 'arm': [ + 'heap' / 'base' / 'asm' / 'arm' / 'push_registers_asm.cc', + ], + 'arm64': [ + 'heap' / 'base' / 'asm' / 'arm64' / 'push_registers_asm.cc', + ], +} + +base_msvc_asm_sources = { + 'ia32': [ + 'heap' / 'base' / 'asm' / 'ia32' / 'push_registers_masm.asm', + ], + 'x64': [ + 'heap' / 'base' / 'asm' / 'x64' / 'push_registers_masm.asm', + ], + 'arm64': [ + 'heap' / 'base' / 'asm' / 'arm64' / 'push_registers_masm.S', + ], +} + +base_arch_sources = {} +if is_clang_or_non_windows + foreach arch : ['ia32', 'x64', 'arm', 'arm64'] + base_arch_sources += { arch: base_backend_sources[host_arch] + base_generic_asm_sources[arch] } + endforeach +else + foreach arch : msvc_required_archs + objects = [] + command = msvc_asm_commands[arch] + foreach source : base_msvc_asm_sources[arch] + name = source.underscorify() + '.obj' + objects += custom_target(name, + input: source, + output: name, + command: command, + ) + endforeach + base_arch_sources += { arch: base_backend_sources[host_arch] + objects } + endforeach +endif + +bytecode_builtins_list_generator = executable('bytecode-builtins-list-generator', [ + 'builtins' / 'generate-bytecodes-builtins-list.cc', + 'interpreter' / 'bytecode-operands.cc', + 'interpreter' / 'bytecodes.cc', + ], + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_libbase_runnable_dep], + native: not meson.can_run_host_binaries(), +) + +subdir('torque') + +subdir('generated') +base_sources += bytecodes_builtins_list_h +base_sources += torque_generated_definitions + +n = base_sources.length() +base_sources_part1 = [] +base_sources_part2 = [] +foreach i : range(n / 2) + base_sources_part1 += base_sources[i] +endforeach +foreach i : range(n / 2, n) + base_sources_part2 += base_sources[i] +endforeach + +base_sources_part1 += torque_generated_headers +base_sources_part2 += torque_generated_headers + +generated_headers = [bytecodes_builtins_list_h, torque_generated_headers] + +v8_base_part1 = static_library('v8-base-part1', base_sources_part1, + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_libbase_dep, compression_utils_portable_dep], +) +v8_base_part2 = static_library('v8-base-part2', base_sources_part2 + base_arch_sources[host_arch], + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_libbase_dep, compression_utils_portable_dep], +) +if meson.can_run_host_binaries() + v8_base_part1_runnable = v8_base_part1 + v8_base_part2_runnable = v8_base_part2 +else + v8_base_part1_runnable = static_library('v8-base-part1-native', base_sources_part1, + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_libbase_runnable_dep, compression_utils_portable_runnable_dep], + native: true, + ) + v8_base_part2_runnable = static_library('v8-base-part2-native', base_sources_part2 + base_arch_sources[build_arch], + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_libbase_runnable_dep, compression_utils_portable_runnable_dep], + native: true, + ) +endif + +v8_base_dep = declare_dependency( + sources: generated_headers, + include_directories: internal_incdirs, + link_with: [v8_base_part1, v8_base_part2], +) +v8_base_runnable_dep = declare_dependency( + sources: generated_headers, + include_directories: internal_incdirs, + link_with: [v8_base_part1_runnable, v8_base_part2_runnable], +) + +init_sources = [ + 'init' / 'setup-isolate-full.cc', + 'builtins' / 'builtins-array-gen.cc', + 'builtins' / 'builtins-async-function-gen.cc', + 'builtins' / 'builtins-async-gen.cc', + 'builtins' / 'builtins-async-generator-gen.cc', + 'builtins' / 'builtins-async-iterator-gen.cc', + 'builtins' / 'builtins-bigint-gen.cc', + 'builtins' / 'builtins-call-gen.cc', + 'builtins' / 'builtins-collections-gen.cc', + 'builtins' / 'builtins-constructor-gen.cc', + 'builtins' / 'builtins-conversion-gen.cc', + 'builtins' / 'builtins-date-gen.cc', + 'builtins' / 'builtins-generator-gen.cc', + 'builtins' / 'builtins-global-gen.cc', + 'builtins' / 'builtins-handler-gen.cc', + 'builtins' / 'builtins-ic-gen.cc', + 'builtins' / 'builtins-internal-gen.cc', + 'builtins' / 'builtins-interpreter-gen.cc', + 'builtins' / 'builtins-iterator-gen.cc', + 'builtins' / 'builtins-lazy-gen.cc', + 'builtins' / 'builtins-microtask-queue-gen.cc', + 'builtins' / 'builtins-number-gen.cc', + 'builtins' / 'builtins-object-gen.cc', + 'builtins' / 'builtins-promise-gen.cc', + 'builtins' / 'builtins-proxy-gen.cc', + 'builtins' / 'builtins-regexp-gen.cc', + 'builtins' / 'builtins-shadow-realm-gen.cc', + 'builtins' / 'builtins-sharedarraybuffer-gen.cc', + 'builtins' / 'builtins-string-gen.cc', + 'builtins' / 'builtins-temporal-gen.cc', + 'builtins' / 'builtins-typed-array-gen.cc', + 'builtins' / 'growable-fixed-array-gen.cc', + 'builtins' / 'profile-data-reader.cc', + 'builtins' / 'setup-builtins-internal.cc', + 'codegen' / 'code-stub-assembler.cc', + 'heap' / 'setup-heap-internal.cc', + 'ic' / 'accessor-assembler.cc', + 'ic' / 'binary-op-assembler.cc', + 'ic' / 'keyed-store-generic.cc', + 'ic' / 'unary-op-assembler.cc', + 'interpreter' / 'interpreter-assembler.cc', + 'interpreter' / 'interpreter-generator.cc', + 'interpreter' / 'interpreter-intrinsics-generator.cc', + 'builtins' / host_arch / 'builtins-' + host_arch + '.cc', +] +init_sources += torque_generated_initializers +if enable_i18n + init_sources += 'builtins' / 'builtins-intl-gen.cc' +endif +if enable_wasm + init_sources += 'builtins' / 'builtins-wasm-gen.cc' +endif + +v8_init = static_library('v8-init', init_sources, + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_base_runnable_dep], + native: not meson.can_run_host_binaries(), +) + +v8_init_dep = declare_dependency(link_with: v8_init) + +subdir('libplatform') +subdir('snapshot') + +v8_snapshot_sources = custom_target('v8-snapshot', + output: [ + 'embedded.S', + 'snapshot.cc', + ], + command: [ + mksnapshot, + '--turbo-instruction-scheduling', + '--target-os=' + host_os_nick, + '--target-arch=' + host_arch, + '--embedded-src', '@OUTPUT0@', + '--startup-src', '@OUTPUT1@', + ], +) +if not is_clang_or_non_windows + name = 'embedded.obj' + v8_snapshot_sources = [ + custom_target(name, + input: v8_snapshot_sources[0], + output: name, + command: msvc_asm_commands[host_arch], + ), + v8_snapshot_sources[1], + ] +endif + +subdir('inspector') + +v8 = library('v8-' + api_version, [ + 'utils' / 'v8dll-main.cc', + 'init' / 'setup-isolate-deserialize.cc', + v8_snapshot_sources, + ], + override_options: cpp_options, + include_directories: internal_incdirs, + implicit_include_directories: false, + link_whole: [v8_base_part1, v8_base_part2, v8_libbase, v8_libplatform, v8_inspector], + install: true, +) + +client_flags = [ + '-DV8_GN_HEADER', +] +if get_option('default_library') != 'static' + client_flags += [ + '-DUSING_V8_SHARED', + '-DUSING_V8_PLATFORM_SHARED', + ] +endif + +v8_dep = declare_dependency( + sources: [v8_gn_h], + compile_args: client_flags, + include_directories: public_incdirs, + link_with: v8, +) + +pkg = import('pkgconfig') +pkg.generate(v8, + filebase: 'v8-' + api_version, + name: 'V8', + description: 'V8 JavaScript Engine', + subdirs: 'v8-' + api_version, + extra_cflags: client_flags, +) + +meson.override_dependency('v8-' + api_version, v8_dep) diff --git a/src/snapshot/meson.build b/src/snapshot/meson.build new file mode 100644 index 0000000000..f5198dbc54 --- /dev/null +++ b/src/snapshot/meson.build @@ -0,0 +1,40 @@ +sources = [ + 'embedded' / 'embedded-empty.cc', + 'embedded' / 'embedded-file-writer.cc', + 'embedded' / 'platform-embedded-file-writer-aix.cc', + 'embedded' / 'platform-embedded-file-writer-base.cc', + 'embedded' / 'platform-embedded-file-writer-generic.cc', + 'embedded' / 'platform-embedded-file-writer-mac.cc', + 'embedded' / 'platform-embedded-file-writer-win.cc', + 'mksnapshot.cc', + 'snapshot-empty.cc', +] + +mksnapshot = executable('mksnapshot', sources, + override_options: cpp_options, + implicit_include_directories: false, + dependencies: [v8_base_runnable_dep, v8_libplatform_runnable_dep, v8_init_dep], + native: not meson.can_run_host_binaries(), +) + +bin_extension = (build_os == 'win') ? '.exe' : '' +if meson.can_run_host_binaries() + bin_subdir = f'@host_os_frida@-@host_arch_frida@' +else + bin_subdir = f'@build_os_frida@-@build_arch_frida@' +endif + +custom_target('mksnapshot-installed', + input: mksnapshot, + output: f'v8-mksnapshot-@host_os_frida@-@host_arch_frida@@bin_extension@', + command: [ + post_process_executable, + '--input-file', '@INPUT@', + '--output-file', '@OUTPUT@', + '--strip-tool', strip, + '--strip-option', get_option('strip').to_string(), + ], + install: true, + install_dir: get_option('bindir') / bin_subdir, + install_mode: 'rwxr-xr-x', +) diff --git a/src/torque/meson.build b/src/torque/meson.build new file mode 100644 index 0000000000..dcf268521d --- /dev/null +++ b/src/torque/meson.build @@ -0,0 +1,38 @@ +torque_compiler_sources = [ + 'torque.cc', + 'cc-generator.cc', + 'cfg.cc', + 'class-debug-reader-generator.cc', + 'cpp-builder.cc', + 'csa-generator.cc', + 'declarable.cc', + 'declaration-visitor.cc', + 'declarations.cc', + 'earley-parser.cc', + 'global-context.cc', + 'implementation-visitor.cc', + 'instance-type-generator.cc', + 'instructions.cc', + 'kythe-data.cc', + 'server-data.cc', + 'source-positions.cc', + 'torque-code-generator.cc', + 'torque-compiler.cc', + 'torque-parser.cc', + 'type-inference.cc', + 'type-oracle.cc', + 'type-visitor.cc', + 'types.cc', + 'utils.cc', +] + +torque = executable('torque', torque_compiler_sources, + override_options: [ + 'cpp_std=' + cpp_std, + 'cpp_eh=default', + 'cpp_rtti=false', + ], + implicit_include_directories: false, + dependencies: [v8_libbase_runnable_dep], + native: not meson.can_run_host_binaries(), +) diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap new file mode 100644 index 0000000000..2fe438a60b --- /dev/null +++ b/subprojects/zlib.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = https://github.com/frida/zlib.git +revision = main +depth = 1 + +[provide] +dependency_names = zlib diff --git a/third_party/inspector_protocol/crdtp/meson.build b/third_party/inspector_protocol/crdtp/meson.build new file mode 100644 index 0000000000..09025afa48 --- /dev/null +++ b/third_party/inspector_protocol/crdtp/meson.build @@ -0,0 +1,11 @@ +crdtp_sources = files( + 'cbor.cc', + 'dispatch.cc', + 'error_support.cc', + 'json.cc', + 'protocol_core.cc', + 'serializable.cc', + 'span.cc', + 'status.cc', + 'json_platform_v8.cc', +) diff --git a/third_party/inspector_protocol/meson.build b/third_party/inspector_protocol/meson.build new file mode 100644 index 0000000000..a42becf8f8 --- /dev/null +++ b/third_party/inspector_protocol/meson.build @@ -0,0 +1,17 @@ +subdir('crdtp') + +v8_inspector_protocol_dir = 'third_party' / 'inspector_protocol' +v8_inspector_protocol_generator = [python, files('code_generator.py')] +v8_inspector_protocol_templates = files( + 'lib' / 'Forward_h.template', + 'lib' / 'ValueConversions_cpp.template', + 'lib' / 'ValueConversions_h.template', + 'lib' / 'Values_cpp.template', + 'lib' / 'Values_h.template', + 'lib' / 'Object_cpp.template', + 'lib' / 'Object_h.template', + 'templates' / 'Exported_h.template', + 'templates' / 'Imported_h.template', + 'templates' / 'TypeBuilder_cpp.template', + 'templates' / 'TypeBuilder_h.template', +) diff --git a/third_party/meson.build b/third_party/meson.build new file mode 100644 index 0000000000..bacd92e22a --- /dev/null +++ b/third_party/meson.build @@ -0,0 +1,4 @@ +jinja_dir = meson.current_source_dir() + +subdir('inspector_protocol') +subdir('zlib') diff --git a/third_party/zlib/google/meson.build b/third_party/zlib/google/meson.build new file mode 100644 index 0000000000..2a9df7b953 --- /dev/null +++ b/third_party/zlib/google/meson.build @@ -0,0 +1,30 @@ +sources = [ + 'compression_utils_portable.cc', +] + +deps = [zlib_dep] + +compression_utils_portable = static_library('compression-utils-portable', sources, + override_options: cpp_options, + dependencies: deps, +) +if meson.can_run_host_binaries() + compression_utils_portable_runnable = compression_utils_portable + deps_runnable = deps +else + deps_runnable = [zlib_native_dep] + compression_utils_portable_runnable = static_library('compression-utils-portable-native', sources, + override_options: cpp_options, + dependencies: deps_runnable, + native: true, + ) +endif + +compression_utils_portable_dep = declare_dependency( + link_with: compression_utils_portable, + dependencies: deps, +) +compression_utils_portable_runnable_dep = declare_dependency( + link_with: compression_utils_portable_runnable, + dependencies: deps_runnable, +) diff --git a/third_party/zlib/meson.build b/third_party/zlib/meson.build new file mode 100644 index 0000000000..f322455606 --- /dev/null +++ b/third_party/zlib/meson.build @@ -0,0 +1 @@ +subdir('google') diff --git a/tools/meson-commit-codegen.py b/tools/meson-commit-codegen.py new file mode 100755 index 0000000000..90827878ae --- /dev/null +++ b/tools/meson-commit-codegen.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import argparse +from meson_post_processor import post_process +from pathlib import Path + + +def main(): + parser = argparse.ArgumentParser(description="Flatten/link files produced by code generator tool.") + parser.add_argument("--output-directory", dest="output_dir", required=True, + help="directory where output will be written") + parser.add_argument("--flatten-subdir", dest="flatten_dirs", default=[], action="append", + help="declare a single output directory to be flattened") + parser.add_argument("--link-subdir", dest="link_dirs", default=[], action="append", + help="declare a single output directory to be linked/copied") + args = parser.parse_args() + + output_dir = Path(args.output_dir) + output_subdirs = [(output_dir / Path(d), "flatten") for d in args.flatten_dirs] + output_subdirs += [(output_dir / Path(d), "link") for d in args.link_dirs] + + post_process(output_dir, output_subdirs) + + +if __name__ == "__main__": + main() diff --git a/tools/meson-post-process-executable.py b/tools/meson-post-process-executable.py new file mode 100755 index 0000000000..1b90d3ff3d --- /dev/null +++ b/tools/meson-post-process-executable.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 + +import argparse +from pathlib import Path +import shutil +import subprocess +import tempfile + + +def main(): + parser = argparse.ArgumentParser(description="Post-process executable to prepare it for installation.") + parser.add_argument("--input-file", dest="input_path", required=True, + help="executable to use as input") + parser.add_argument("--output-file", dest="output_path", required=True, + help="where to write the result") + parser.add_argument("--strip-tool", dest="strip_tool", required=True, + help="path to strip tool") + parser.add_argument("--strip-option", dest="strip_option", required=True, choices=["true", "false"], + help="whether to strip the executable") + args = parser.parse_args() + + input_path = Path(args.input_path) + output_path = Path(args.output_path) + + strip_tool = args.strip_tool + if strip_tool != "": + strip_tool = Path(strip_tool) + else: + strip_tool = None + + strip_requested = args.strip_option == "true" + + intermediate_path = None + with input_path.open(mode="rb") as input_file: + with tempfile.NamedTemporaryFile(delete=False) as temp_file: + shutil.copyfileobj(input_file, temp_file) + intermediate_path = Path(temp_file.name) + + try: + if strip_tool is not None and strip_requested: + subprocess.run([strip_tool, intermediate_path], check=True) + except: + intermediate_path.unlink() + raise + + shutil.move(intermediate_path, output_path) + + +if __name__ == "__main__": + main() diff --git a/tools/meson-prepare-codegen.py b/tools/meson-prepare-codegen.py new file mode 100755 index 0000000000..da576aa2e2 --- /dev/null +++ b/tools/meson-prepare-codegen.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import argparse +from pathlib import Path + + +def main(): + parser = argparse.ArgumentParser(description="Prepare output directories for code generator tool.") + parser.add_argument("--output-directory", dest="output_dir", required=True, + help="directory where output will be written") + parser.add_argument("--prepare-subdir", dest="output_subdirs", default=[], action="append", + help="prepare a specific output subdir") + parser.add_argument("--touch-stamp-file", dest="stamp_file", required=True, + help="stamp file to touch") + args = parser.parse_args() + + output_dir = Path(args.output_dir) + output_subdirs = [output_dir / Path(d) for d in args.output_subdirs] + stamp_file = Path(args.stamp_file) + + for d in output_subdirs: + d.mkdir(parents=True, exist_ok=True) + + stamp_file.touch() + + +if __name__ == "__main__": + main() diff --git a/tools/meson-run-codegen.py b/tools/meson-run-codegen.py new file mode 100755 index 0000000000..b27a20bfa6 --- /dev/null +++ b/tools/meson-run-codegen.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import argparse +from meson_post_processor import post_process +from pathlib import Path +import subprocess + + +def main(): + parser = argparse.ArgumentParser(description="Wrap code generator tool.") + parser.add_argument("--output-directory", dest="output_dir", required=True, + help="directory where output will be written") + parser.add_argument("--flatten-subdir", dest="flatten_dirs", default=[], action="append", + help="declare a single output directory to be flattened") + parser.add_argument("--link-subdir", dest="link_dirs", default=[], action="append", + help="declare a single output directory to be linked/copied") + parser.add_argument("generator_args", metavar="command", nargs="*", + help="generator and arguments") + args = parser.parse_args() + + output_dir = Path(args.output_dir) + output_subdirs = [(output_dir / Path(d), "flatten") for d in args.flatten_dirs] + output_subdirs += [(output_dir / Path(d), "link") for d in args.link_dirs] + + generator_args = args.generator_args + if len(generator_args) == 0: + parser.error("missing generator args") + + for d, _ in output_subdirs: + d.mkdir(parents=True, exist_ok=True) + + subprocess.run(generator_args, check=True) + + post_process(output_dir, output_subdirs) + + +if __name__ == "__main__": + main() diff --git a/tools/meson_post_processor.py b/tools/meson_post_processor.py new file mode 100644 index 0000000000..a253d2d968 --- /dev/null +++ b/tools/meson_post_processor.py @@ -0,0 +1,33 @@ +import platform +import shutil + + +def post_process(output_dir, output_subdirs): + output_globs = [ + "*.c", + "*.cc", + "*.cpp", + "*.h", + "*.inc", + ] + can_symlink = platform.system() != "Windows" + for d, action in output_subdirs: + for output_glob in output_globs: + for output_file in d.glob(output_glob): + subpath = output_file.relative_to(output_dir) + if action == "flatten": + alias = output_dir / "_".join(subpath.parts) + else: + alias = output_dir / output_file.name + if can_symlink: + if not alias.exists(): + alias.symlink_to(subpath) + else: + if alias.exists(): + old_contents = alias.read_bytes() + new_contents = output_file.read_bytes() + dirty = new_contents != old_contents + else: + dirty = True + if dirty: + shutil.copyfile(output_file, alias)