DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (6863f516ba38)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# /!\ Use js_option() instead of option() in this file. /!\
# =========================================================

@depends(build_project)
def building_js(build_project):
    return build_project == 'js'

# Exception to the rule above: JS_STANDALONE is a special option that doesn't
# want the js_option treatment. When we're done merging js/src/configure and
# top-level configure, it can go away, although the JS_STANDALONE config
# will still need to be set depending on building_js above.
option(env='JS_STANDALONE', default=building_js,
       help='Reserved for internal use')

include('../build/moz.configure/rust.configure',
        when='--enable-compile-environment')
include('../build/moz.configure/bindgen.configure',
        when='--enable-compile-environment')

@depends('JS_STANDALONE')
def js_standalone(value):
    if value:
        return True
set_config('JS_STANDALONE', js_standalone)
set_define('JS_STANDALONE', js_standalone)
add_old_configure_assignment('JS_STANDALONE', js_standalone)
js_option('--disable-js-shell', default=building_js,
          help='{Build|Do not build} the JS shell')

@depends('--disable-js-shell')
def js_disable_shell(value):
    if not value:
        return True

set_config('JS_DISABLE_SHELL', js_disable_shell)

set_define('JS_64BIT', depends(target)(lambda t: t.bitness == 64 or None))

set_define('JS_PUNBOX64', depends(target)(lambda t: t.bitness == 64 or None))
set_define('JS_NUNBOX32', depends(target)(lambda t: t.bitness == 32 or None))


# SpiderMonkey as a shared library, and how its symbols are exported
# ==================================================================
js_option('--disable-shared-js', default=building_js,
          help='{Create|Do not create} a shared library')

js_option('--disable-export-js', default=building_js,
          help='{Mark|Do not mark} JS symbols as DLL exported/visible')

@depends('--disable-shared-js', '--disable-export-js')
def shared_js(shared_js, export_js):
    if shared_js:
        if not export_js:
            die('Must export JS symbols when building a shared library.')
        return True

set_config('JS_SHARED_LIBRARY', shared_js)
add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)

@depends('--disable-shared-js', '--disable-export-js')
def exportable_js_api(shared_js, export_js):
    if not shared_js and export_js:
        return True

set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)

@depends('--disable-shared-js', '--disable-export-js')
def static_js_api(shared_js, export_js):
    if not shared_js and not export_js:
        return True

set_define('STATIC_JS_API', static_js_api)

@depends('--disable-shared-js')
def static_js(value):
    if not value:
        return True

set_define('MOZ_STATIC_JS', static_js)

@deprecated_option(env='DISABLE_SHARED_JS', nargs='?')
def disable_shared_js(value):
    # DISABLE_SHARED_JS=1 gets us an empty PositiveOptionValue
    if value and not len(value):
        suggestion = '--disable-shared-js'
    else:
        suggestion = '--enable-shared-js'

    die('Setting %s is deprecated, use %s instead.',
        value.format('DISABLE_SHARED_JS'), suggestion)

@deprecated_option(env='DISABLE_EXPORT_JS', nargs='?')
def disable_export_js(value):
    # DISABLE_EXPORT_JS=1 gets us an empty PositiveOptionValue
    if value and not len(value):
        suggestion = '--disable-export-js'
    else:
        suggestion = '--enable-export-js'

    die('Setting %s is deprecated, use %s instead.',
        value.format('DISABLE_EXPORT_JS'), suggestion)

# JIT support
# =======================================================
@depends(target)
def ion_default(target):
    if target.cpu in ('x86', 'x86_64', 'arm', 'aarch64', 'mips32', 'mips64'):
        return True
    return False

js_option('--enable-ion',
          default=ion_default,
          help='{Enable|Disable} use of the IonMonkey JIT')

set_config('ENABLE_ION', depends_if('--enable-ion')(lambda x: True))

# JIT code simulator for cross compiles
# =======================================================
js_option('--enable-simulator', choices=('arm', 'arm64', 'mips32', 'mips64'),
          nargs=1,
          help='Enable a JIT code simulator for the specified architecture')

@depends('--enable-ion', '--enable-simulator', target)
def simulator(ion_enabled, simulator_enabled, target):
    if not ion_enabled or not simulator_enabled:
        return

    sim_cpu = simulator_enabled[0]

    if sim_cpu in ('arm', 'mips32'):
        if target.cpu != 'x86':
            die('The %s simulator only works on x86.' % sim_cpu)

    if sim_cpu in ('arm64', 'mips64'):
        if target.cpu != 'x86_64':
            die('The %s simulator only works on x86-64.' % sim_cpu)

    return namespace(**{sim_cpu: True})

set_config('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
set_config('JS_SIMULATOR_ARM', simulator.arm)
set_config('JS_SIMULATOR_ARM64', simulator.arm64)
set_config('JS_SIMULATOR_MIPS32', simulator.mips32)
set_config('JS_SIMULATOR_MIPS64', simulator.mips64)
set_define('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
set_define('JS_SIMULATOR_ARM', simulator.arm)
set_define('JS_SIMULATOR_ARM64', simulator.arm64)
set_define('JS_SIMULATOR_MIPS32', simulator.mips32)
set_define('JS_SIMULATOR_MIPS64', simulator.mips64)

@depends('--enable-ion', simulator, target)
def jit_codegen(ion_enabled, simulator, target):
    if not ion_enabled:
        return namespace(none=True)

    if simulator:
        return simulator

    if target.cpu == 'aarch64':
        return namespace(arm64=True)
    elif target.cpu == 'x86_64':
        return namespace(x64=True)

    return namespace(**{str(target.cpu): True})

set_config('JS_CODEGEN_NONE', jit_codegen.none)
set_config('JS_CODEGEN_ARM', jit_codegen.arm)
set_config('JS_CODEGEN_ARM64', jit_codegen.arm64)
set_config('JS_CODEGEN_MIPS32', jit_codegen.mips32)
set_config('JS_CODEGEN_MIPS64', jit_codegen.mips64)
set_config('JS_CODEGEN_X86', jit_codegen.x86)
set_config('JS_CODEGEN_X64', jit_codegen.x64)
set_define('JS_CODEGEN_NONE', jit_codegen.none)
set_define('JS_CODEGEN_ARM', jit_codegen.arm)
set_define('JS_CODEGEN_ARM64', jit_codegen.arm64)
set_define('JS_CODEGEN_MIPS32', jit_codegen.mips32)
set_define('JS_CODEGEN_MIPS64', jit_codegen.mips64)
set_define('JS_CODEGEN_X86', jit_codegen.x86)
set_define('JS_CODEGEN_X64', jit_codegen.x64)

# Profiling
# =======================================================
js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
          help='Enable instruments remote profiling')

@depends('--enable-instruments', target)
def instruments(value, target):
    if value and target.os != 'OSX':
        die('--enable-instruments cannot be used when targeting %s',
            target.os)
    if value:
        return True

set_config('MOZ_INSTRUMENTS', instruments)
set_define('MOZ_INSTRUMENTS', instruments)
add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
imply_option('--enable-profiling', instruments, reason='--enable-instruments')

js_option('--enable-callgrind', env='MOZ_CALLGRIND',
          help='Enable callgrind profiling')

@depends('--enable-callgrind')
def callgrind(value):
    if value:
        return True

set_define('MOZ_CALLGRIND', callgrind)
imply_option('--enable-profiling', callgrind)

@depends(milestone)
def enable_profiling(milestone):
    return milestone.is_nightly

js_option('--enable-profiling', env='MOZ_PROFILING', default=enable_profiling,
          help='{Set|Do not set} compile flags necessary for using sampling '
                'profilers (e.g. shark, perf)')

@depends('--enable-profiling')
def profiling(value):
    if value:
        return True

add_old_configure_assignment('MOZ_PROFILING', profiling)

@depends(profiling, target)
def imply_vtune(value, target):
    ok_cpu    = target.cpu in ['x86', 'x86_64']
    ok_kernel = target.kernel == 'WINNT' or \
                (target.kernel == 'Linux' and target.os == 'GNU')

    if value and ok_cpu and ok_kernel:
        return True

set_config('MOZ_PROFILING', profiling)
set_define('MOZ_PROFILING', profiling)
imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')


js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable VTune profiling')

@depends('--enable-vtune')
def vtune(value):
    if value:
        return True

set_config('MOZ_VTUNE', vtune)
set_define('MOZ_VTUNE', vtune)


js_option('--enable-gc-trace', env='JS_GC_TRACE',
          help='Enable tracing of allocation and finalization')

@depends('--enable-gc-trace')
def gc_trace(value):
    if value:
        return True

set_define('JS_GC_TRACE', gc_trace)


js_option('--enable-gczeal',
          default=depends(when=moz_debug)(lambda: True),
          help='{Enable|Disable} zealous GCing')

set_define('JS_GC_ZEAL',
           depends_if('--enable-gczeal')(lambda _: True))


# Use a smaller chunk size for GC chunks
# ========================================================
# Use large (1MB) chunks by default.  This option can be used to give
# smaller (currently 256K) chunks.
js_option('--enable-small-chunk-size',
          help='Allocate memory for JS GC things in smaller chunks')

set_define('JS_GC_SMALL_CHUNK_SIZE',
           depends(when='--enable-small-chunk-size')(lambda: True))


# Trace logging.
# =======================================================
@depends(milestone)
def default_trace_logging(milestone):
    return milestone.is_nightly


js_option('--enable-trace-logging',
          default=default_trace_logging,
          help='{Enable|Disable} trace logging')

set_config('ENABLE_TRACE_LOGGING',
           depends_if('--enable-trace-logging')(lambda x: True))
set_define('JS_TRACE_LOGGING',
           depends_if('--enable-trace-logging')(lambda x: True))


# Enable breakpoint for artificial OOMs
# =======================================================
js_option('--enable-oom-breakpoint',
          help='Enable a breakpoint function for artificial OOMs')

set_define('JS_OOM_BREAKPOINT',
           depends_if('--enable-oom-breakpoint')(lambda _: True))


js_option('--enable-perf', env='JS_ION_PERF',
          help='Enable Linux perf integration')

@depends('--enable-perf')
def ion_perf(value):
    if value:
        return True

set_define('JS_ION_PERF', ion_perf)


js_option('--enable-jitspew',
          default=depends(when=moz_debug)(lambda: True),
          help='{Enable|Disable} the Jit spew and IONFLAGS environment '
               'variable')

set_define('JS_JITSPEW',
           depends_if('--enable-jitspew')(lambda _: True))
set_config('JS_JITSPEW',
           depends_if('--enable-jitspew')(lambda _: True))

# Also enable the structured spewer
set_define('JS_STRUCTURED_SPEW',
           depends_if('--enable-jitspew')(lambda _: True))
set_config('JS_STRUCTURED_SPEW',
           depends_if('--enable-jitspew')(lambda _: True))

@depends('--enable-ion', '--enable-jitspew', simulator, target, moz_debug)
def jit_disasm_arm(ion_enabled, spew, simulator, target, debug):
    if not ion_enabled:
        return

    if simulator and (debug or spew):
        if getattr(simulator, 'arm', None):
            return True

    if target.cpu == 'arm' and (debug or spew):
        return True

set_config('JS_DISASM_ARM', jit_disasm_arm)
set_define('JS_DISASM_ARM', jit_disasm_arm)

@depends('--enable-ion', '--enable-jitspew', simulator, target, moz_debug)
def jit_disasm_arm64(ion_enabled, spew, simulator, target, debug):
    if not ion_enabled:
        return

    if simulator and (debug or spew):
        if getattr(simulator, 'arm64', None):
            return True

    if target.cpu == 'aarch64' and (debug or spew):
        return True

set_config('JS_DISASM_ARM64', jit_disasm_arm64)
set_define('JS_DISASM_ARM64', jit_disasm_arm64)

# When enabled, masm will generate assumeUnreachable calls that act as
# assertions in the generated code. This option is worth disabling when you
# have to track mutated values through the generated code, to avoid constantly
# dumping registers on and off the stack.
js_option('--enable-masm-verbose',
          default=depends(when=moz_debug)(lambda: True),
          help='{Enable|Disable} MacroAssembler verbosity of generated code.')
set_define('JS_MASM_VERBOSE',
           depends_if('--enable-masm-verbose')(lambda _: True))
set_config('JS_MASM_VERBOSE',
           depends_if('--enable-masm-verbose')(lambda _: True))


js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
          help='Enable changes that make the shell more deterministic')

@depends('--enable-more-deterministic')
def more_deterministic(value):
    if value:
        return True

set_define('JS_MORE_DETERMINISTIC', more_deterministic)


# CTypes
# =======================================================
@depends(building_js)
def ctypes_default(building_js):
    return not building_js

js_option('--enable-ctypes',
          default=ctypes_default,
          help='{Enable|Disable} js-ctypes')

build_ctypes = depends_if('--enable-ctypes')(lambda _: True)

set_config('BUILD_CTYPES', build_ctypes)
set_define('BUILD_CTYPES', build_ctypes)

@depends(build_ctypes, building_js)
def js_has_ctypes(ctypes, js):
    if ctypes and js:
        return True

set_config('JS_HAS_CTYPES', js_has_ctypes)
set_define('JS_HAS_CTYPES', js_has_ctypes)

@depends('--enable-ctypes', '--enable-compile-environment')
def ctypes_and_compile_environment(ctypes, compile_environment):
    return ctypes and compile_environment

include('ffi.configure', when=ctypes_and_compile_environment)


# Enable pipeline operator
# ===================================================
js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')

@depends('--enable-pipeline-operator')
def enable_pipeline_operator(value):
    if value:
        return True

set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)



# Experimental support for BinAST
# ==============================================================

@depends(milestone.is_nightly)
def default_binast(is_nightly):
    return is_nightly

js_option('--enable-binast',
          default=default_binast,
          help="{Enable|Disable} BinAST support")

set_config('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))
set_define('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))


# Experimental support for wasm code generation with Cranelift
# ==============================================================

@depends(milestone.is_nightly)
def default_cranelift(is_nightly):
    return is_nightly

js_option('--enable-cranelift',
          default=default_cranelift,
          help='{Enable|Disable} Cranelift code generator for wasm')

set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
set_define('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))


# Support for debugging code generated by wasm backends
# =====================================================

js_option('--enable-wasm-codegen-debug',
          default=depends(when=moz_debug)(lambda: True),
          help='{Enable|Disable} debugging for wasm codegen')

set_config('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
set_define('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))


# Support for typed objects.
# =====================================================

@depends(milestone.is_nightly)
def default_typed_objects(is_nightly):
    return is_nightly

js_option('--enable-typed-objects',
          default=default_typed_objects,
          help='{Enable|Disable} typed objects')

set_config('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
set_define('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))


# Support for WebAssembly bulk memory operations.
# =====================================================

@depends(milestone.is_nightly)
def default_wasm_bulk_memory(is_nightly):
    return is_nightly

js_option('--enable-wasm-bulk-memory',
          default=default_wasm_bulk_memory,
          help='{Enable|Disable} WebAssembly bulk memory operators')

set_config('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
set_define('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))


# Support for WebAssembly reference types.
# =====================================================

@depends(milestone.is_nightly)
def default_wasm_reftypes(is_nightly):
    return is_nightly

js_option('--enable-wasm-reftypes',
          default=default_wasm_reftypes,
          help='{Enable|Disable} WebAssembly reference types')

set_config('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
set_define('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))


# Support for WebAssembly GC.
# ===========================

@depends(milestone.is_nightly, '--enable-wasm-reftypes')
def default_wasm_gc(is_nightly, reftypes):
    if reftypes and is_nightly:
        return True

js_option('--enable-wasm-gc',
          default=default_wasm_gc,
          help='{Enable|Disable} WebAssembly GC')

set_config('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
set_define('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))


# Support for WebAssembly private ref types.
# Prevent (ref T) types from being exposed to JS content so that wasm need do
# no typechecking at the JS/wasm boundary
# ===========================================================================

@depends(milestone.is_nightly, '--enable-wasm-gc')
def default_wasm_private_reftypes(is_nightly, gc):
    if gc and is_nightly:
        return True

js_option('--enable-wasm-private-reftypes',
          default=default_wasm_private_reftypes,
          help='{Enable|Disable} WebAssembly private reference types')

set_config('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
set_define('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))

# Support for unaligned private values.
# This is the default in Firefox 70. It is backported to ESR68 under a compile
# option for the use of embedders. It is not part of the standard Firefox build.
# ==============================================================================

js_option('--enable-unaligned-private-values',
          default=False,
          help='{Enable|disable} unaligned private pointers in JS values')

set_define('JS_UNALIGNED_PRIVATE_VALUES',
           depends_if('--enable-unaligned-private-values')(lambda x: True))