1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 include("js-config.mozbuild")
8 include("js-cxxflags.mozbuild")
11 component_engine = ("Core", "JavaScript Engine")
12 component_gc = ("Core", "JavaScript: GC")
13 component_intl = ("Core", "JavaScript: Internationalization API")
14 component_jit = ("Core", "JavaScript Engine: JIT")
15 component_stl = ("Core", "JavaScript: Standard Library")
16 component_wasm = ("Core", "Javascript: Web Assembly")
18 FILES_PER_UNIFIED_FILE = 6
20 # Prevent redefining FILES_PER_UNIFIED_FILE in each sub-directory of js. This
21 # will not escape this directory.
22 export("FILES_PER_UNIFIED_FILE")
25 BUG_COMPONENT = component_engine
27 with Files("wasm/**"):
28 BUG_COMPONENT = component_wasm
29 with Files("builtin/**"):
30 BUG_COMPONENT = component_stl
31 with Files("ctypes/**"):
32 BUG_COMPONENT = ("Core", "js-ctypes")
34 BUG_COMPONENT = component_gc
36 BUG_COMPONENT = component_jit
38 # File-specific metadata
39 for gcfile in ["devtools/rootAnalysis", "devtools/gc-ubench", "devtools/gctrace"]:
41 BUG_COMPONENT = component_gc
43 for stlfile in ["jsdate.*", "jsnum.*"]:
45 BUG_COMPONENT = component_stl
47 with Files("builtin/intl/*"):
48 BUG_COMPONENT = component_intl
50 if not CONFIG["JS_DISABLE_SHELL"]:
62 if CONFIG["FUZZING_INTERFACES"]:
67 if CONFIG["FUZZING_INTERFACES"] and CONFIG["LIBFUZZER"]:
68 # In addition to regular coverage provided by trace-pc-guard,
69 # LibFuzzer can use trace-cmp to instrument various compare instructions.
70 # Only use this feature on source files that do a lot of constant
71 # comparisons that would otherwise be hard to guess by LibFuzzer,
72 # as it comes with a larger overhead (requires -use_value_profile=1).
73 include("/tools/fuzzing/libfuzzer-flags.mozbuild")
75 # Any files that are targeted by LibFuzzer should be added here so they can
76 # be built with the necessary instrumentation flags, rather than just building
77 # the whole JS engine with instrumentation, to reduce the amount of noise.
79 "vm/StructuredClone.cpp",
81 SOURCES["vm/StructuredClone.cpp"].flags += libfuzzer_flags
84 "vm/StructuredClone.cpp",
87 if CONFIG["FUZZING_JS_FUZZILLI"]:
88 # When building for Fuzzilli, we instrument everything with standard
89 # trace-pc instrumentation.
90 include("/tools/fuzzing/libfuzzer-config.mozbuild")
92 CONFIGURE_DEFINE_FILES += [
96 if not CONFIG["JS_STANDALONE"]:
97 CONFIGURE_SUBST_FILES += [
98 "../../config/autoconf-js.mk",
99 "../../config/emptyvars-js.mk",
102 CONFIGURE_DEFINE_FILES += [
106 if CONFIG["HAVE_DTRACE"]:
107 GeneratedFile("javascript-trace.h")
108 EXPORTS += ["!javascript-trace.h"]
110 # Changes to internal header files, used externally, massively slow down
111 # browser builds. Don't add new files here unless you know what you're
122 "!../public/PrefsGenerated.h",
123 "../public/AllocationLogging.h",
124 "../public/AllocationRecording.h",
125 "../public/AllocPolicy.h",
127 "../public/ArrayBuffer.h",
128 "../public/ArrayBufferMaybeShared.h",
129 "../public/BigInt.h",
130 "../public/BuildId.h",
131 "../public/CallAndConstruct.h",
132 "../public/CallArgs.h",
133 "../public/CallNonGenericMethod.h",
134 "../public/CharacterEncoding.h",
136 "../public/ColumnNumber.h",
137 "../public/ComparisonOperators.h",
138 "../public/CompilationAndEvaluation.h",
139 "../public/CompileOptions.h",
140 "../public/Context.h",
141 "../public/ContextOptions.h",
142 "../public/Conversions.h",
145 "../public/Equality.h",
146 "../public/ErrorInterceptor.h",
147 "../public/ErrorReport.h",
148 "../public/Exception.h",
149 "../public/ForOfIterator.h",
150 "../public/GCAnnotations.h",
152 "../public/GCHashTable.h",
153 "../public/GCPolicyAPI.h",
154 "../public/GCTypeMacros.h",
155 "../public/GCVariant.h",
156 "../public/GCVector.h",
157 "../public/GlobalObject.h",
158 "../public/HashTable.h",
159 "../public/HeapAPI.h",
160 "../public/HelperThreadAPI.h",
162 "../public/Initialization.h",
163 "../public/Interrupt.h",
164 "../public/Iterator.h",
165 "../public/JitCodeAPI.h",
167 "../public/LocaleSensitive.h",
168 "../public/MapAndSet.h",
169 "../public/MemoryCallbacks.h",
170 "../public/MemoryFunctions.h",
171 "../public/MemoryMetrics.h",
172 "../public/Modules.h",
173 "../public/Object.h",
175 "../public/Principals.h",
176 "../public/Printer.h",
177 "../public/Printf.h",
178 "../public/ProfilingCategory.h",
179 "../public/ProfilingFrameIterator.h",
180 "../public/ProfilingStack.h",
181 "../public/Promise.h",
182 "../public/PropertyAndElement.h",
183 "../public/PropertyDescriptor.h",
184 "../public/PropertySpec.h",
185 "../public/ProtoKey.h",
188 "../public/RealmIterators.h",
189 "../public/RealmOptions.h",
190 "../public/RefCounted.h",
191 "../public/RegExp.h",
192 "../public/RegExpFlags.h",
193 "../public/Result.h",
194 "../public/RootingAPI.h",
195 "../public/SavedFrameAPI.h",
196 "../public/ScalarType.h",
197 "../public/ScriptPrivate.h",
198 "../public/ShadowRealmCallbacks.h",
199 "../public/SharedArrayBuffer.h",
200 "../public/SliceBudget.h",
201 "../public/SourceText.h",
202 "../public/StableStringChars.h",
204 "../public/StreamConsumer.h",
205 "../public/String.h",
206 "../public/StructuredClone.h",
207 "../public/Symbol.h",
208 "../public/TelemetryTimers.h",
209 "../public/TraceKind.h",
210 "../public/TracingAPI.h",
211 "../public/Transcoding.h",
212 "../public/TypeDecls.h",
213 "../public/UbiNode.h",
214 "../public/UbiNodeBreadthFirst.h",
215 "../public/UbiNodeCensus.h",
216 "../public/UbiNodeDominatorTree.h",
217 "../public/UbiNodePostOrder.h",
218 "../public/UbiNodeShortestPaths.h",
219 "../public/UbiNodeUtils.h",
220 "../public/UniquePtr.h",
221 "../public/Utility.h",
223 "../public/ValueArray.h",
224 "../public/Vector.h",
225 "../public/WaitCallbacks.h",
226 "../public/Warnings.h",
227 "../public/WasmFeatures.h",
228 "../public/WasmModule.h",
229 "../public/WeakMap.h",
230 "../public/WeakMapPtr.h",
231 "../public/Wrapper.h",
232 "../public/WrapperCallbacks.h",
236 # This lives in mozglue/baseprofiler but we re-publish ourselves to support
237 # standalone SpiderMonkey configurations.
239 "!/mozglue/baseprofiler/public/ProfilingCategoryList.h",
242 # Public APIs that are experimental: the precise contour of the APIs may still
243 # change, but they're at least plausible first passes at designing something.
244 # We expose them as-is, buyer beware.
245 EXPORTS.js.experimental += [
246 "../public/experimental/CodeCoverage.h",
247 "../public/experimental/CompileScript.h",
248 "../public/experimental/CTypes.h",
249 "../public/experimental/Intl.h",
250 "../public/experimental/JitInfo.h",
251 "../public/experimental/JSStencil.h",
252 "../public/experimental/PCCountProfiling.h",
253 "../public/experimental/SourceHook.h",
254 "../public/experimental/TypedData.h",
257 # Friend APIs are APIs that either basically SpiderMonkey-internal, or their
258 # contours are gross and terrible -- but the functionality is too important to
259 # some embedder (often, Gecko) to just not expose anything or to agonize through
260 # a clean design. Use this only if you absolutely must, and feel free to
261 # propose clean APIs to replace what's here!
262 EXPORTS.js.friend += [
263 "../public/friend/DOMProxy.h",
264 "../public/friend/DumpFunctions.h",
265 "../public/friend/ErrorMessages.h",
266 "../public/friend/ErrorNumbers.msg",
267 "../public/friend/JSMEnvironment.h",
268 "../public/friend/PerformanceHint.h",
269 "../public/friend/StackLimits.h",
270 "../public/friend/UsageStatistics.h",
271 "../public/friend/WindowProxy.h",
272 "../public/friend/XrayJitInfo.h",
275 # "Shadow" API defines the internal layout of public JSAPI types like |JSObject|
276 # and |JSString|, so that other *inline* public functions can efficiently access
277 # their internal fields.
279 # Embedders must never include these headers themselves or use their contents.
280 # These internal layout details are publicly exposed for access *only* so that
281 # other public API definitions may use them.
283 # When adding new shadow structure definitions (or new fields/static constants
284 # to existing structures) for access by inline methods, make sure to add static
285 # asserts to the original header file to ensure that offsets and duplicated
286 # constants are consistent. (Long term, it might be worth figuring out some way
287 # to back actual implementations *with* these shadow definitions to eliminate
289 EXPORTS.js.shadow += [
290 "../public/shadow/Function.h",
291 "../public/shadow/Object.h",
292 "../public/shadow/Realm.h",
293 "../public/shadow/Shape.h",
294 "../public/shadow/String.h",
295 "../public/shadow/Symbol.h",
296 "../public/shadow/Zone.h",
301 "builtin/AtomicsObject.cpp",
302 "builtin/BigInt.cpp",
303 "builtin/Boolean.cpp",
304 "builtin/DataViewObject.cpp",
306 "builtin/FinalizationRegistryObject.cpp",
308 "builtin/MapObject.cpp",
309 "builtin/ModuleObject.cpp",
310 "builtin/Object.cpp",
311 "builtin/ParseRecordObject.cpp",
312 "builtin/Profilers.cpp",
313 "builtin/Promise.cpp",
314 "builtin/RawJSONObject.cpp",
315 "builtin/Reflect.cpp",
316 "builtin/ReflectParse.cpp",
317 "builtin/ShadowRealm.cpp",
318 "builtin/String.cpp",
319 "builtin/Symbol.cpp",
320 "builtin/TestingFunctions.cpp",
321 "builtin/TestingUtility.cpp",
322 "builtin/WeakMapObject.cpp",
323 "builtin/WeakRefObject.cpp",
324 "builtin/WeakSetObject.cpp",
325 "builtin/WrappedFunctionObject.cpp",
333 "proxy/BaseProxyHandler.cpp",
334 "proxy/CrossCompartmentWrapper.cpp",
335 "proxy/DeadObjectProxy.cpp",
336 "proxy/DOMProxy.cpp",
337 "proxy/OpaqueCrossCompartmentWrapper.cpp",
339 "proxy/ScriptedProxyHandler.cpp",
340 "proxy/SecurityWrapper.cpp",
342 "threading/Mutex.cpp",
343 "threading/ProtectedData.cpp",
344 "threading/Thread.cpp",
346 "vm/ArgumentsObject.cpp",
347 "vm/ArrayBufferObject.cpp",
348 "vm/ArrayBufferObjectMaybeShared.cpp",
349 "vm/ArrayBufferViewObject.cpp",
350 "vm/AsyncFunction.cpp",
351 "vm/AsyncIteration.cpp",
353 "vm/BoundFunctionObject.cpp",
355 "vm/BuiltinObjectKind.cpp",
356 "vm/BytecodeLocation.cpp",
357 "vm/BytecodeUtil.cpp",
358 "vm/CallAndConstruct.cpp",
359 "vm/CallNonGenericMethod.cpp",
360 "vm/CharacterEncoding.cpp",
361 "vm/CodeCoverage.cpp",
362 "vm/Compartment.cpp",
363 "vm/CompilationAndEvaluation.cpp",
364 "vm/Compression.cpp",
365 "vm/ConcurrentDelazification.cpp",
367 "vm/EnvironmentObject.cpp",
368 "vm/EqualityOperations.cpp",
369 "vm/ErrorMessages.cpp",
370 "vm/ErrorObject.cpp",
371 "vm/ErrorReporting.cpp",
373 "vm/ForOfIterator.cpp",
375 "vm/FunctionFlags.cpp",
376 "vm/GeckoProfiler.cpp",
377 "vm/GeneratorObject.cpp",
378 "vm/GetterSetter.cpp",
379 "vm/GlobalObject.cpp",
380 "vm/HelperThreads.cpp",
382 "vm/Initialization.cpp",
383 "vm/InternalThreadPool.cpp",
384 "vm/InvalidatingFuse.cpp",
387 "vm/JitActivation.cpp",
388 "vm/JSAtomUtils.cpp",
393 "vm/JSONPrinter.cpp",
396 "vm/MemoryMetrics.cpp",
398 "vm/NativeObject.cpp",
399 "vm/OffThreadPromiseRuntimeState.cpp",
401 "vm/PlainObject.cpp",
405 "vm/PromiseLookup.cpp",
406 "vm/PropertyAndElement.cpp",
407 "vm/PropertyDescriptor.cpp",
409 "vm/ProxyObject.cpp",
412 "vm/RegExpObject.cpp",
413 "vm/RegExpStatics.cpp",
415 "vm/SavedStacks.cpp",
417 "vm/SelfHosting.cpp",
420 "vm/SharedArrayObject.cpp",
421 "vm/SharedImmutableStringsCache.cpp",
422 "vm/SharedScriptDataTableHolder.cpp",
425 "vm/StaticStrings.cpp",
426 "vm/StencilCache.cpp",
427 "vm/StencilObject.cpp",
430 "vm/TaggedProto.cpp",
431 "vm/ThrowMsgKind.cpp",
434 "vm/TypedArrayObject.cpp",
436 "vm/UbiNodeCensus.cpp",
437 "vm/UbiNodeShortestPaths.cpp",
438 "vm/UsageStatistics.cpp",
442 "vm/WellKnownAtom.cpp",
443 "vm/WindowProxy.cpp",
447 # builtin/RegExp.cpp cannot be built in unified mode because it causes huge
448 # win32 test slowdowns
449 # jsmath.cpp cannot be built in unified mode because it needs to re-#define the
450 # RtlGenRandom declaration's calling convention in <ntsecapi.h> on Windows.
451 # vm/Interpreter.cpp is gigantic and destroys incremental build times for any
452 # files unlucky enough to be unified with it.
454 "builtin/RegExp.cpp",
456 "vm/Interpreter.cpp",
457 "vm/ProfilingStack.cpp",
460 if CONFIG["ENABLE_PORTABLE_BASELINE_INTERP"]:
462 "vm/PortableBaselineInterpret.cpp",
465 if CONFIG["ENABLE_RECORD_TUPLE"]:
467 "builtin/RecordObject.cpp",
468 "builtin/TupleObject.cpp",
469 "vm/RecordTupleShared.cpp",
474 if CONFIG["JS_HAS_INTL_API"]:
476 "builtin/intl/Collator.cpp",
477 "builtin/intl/CommonFunctions.cpp",
478 "builtin/intl/DateTimeFormat.cpp",
479 "builtin/intl/DisplayNames.cpp",
480 "builtin/intl/IntlObject.cpp",
481 "builtin/intl/LanguageTag.cpp",
482 "builtin/intl/ListFormat.cpp",
483 "builtin/intl/Locale.cpp",
484 "builtin/intl/NumberFormat.cpp",
485 "builtin/intl/PluralRules.cpp",
486 "builtin/intl/RelativeTimeFormat.cpp",
487 "builtin/intl/Segmenter.cpp",
488 "builtin/intl/SharedIntlData.cpp",
491 if CONFIG["MOZ_INSTRUMENTS"]:
493 "devtools/Instruments.cpp",
496 if CONFIG["OS_ARCH"] == "WINNT":
501 "threading/windows/CpuCount.cpp",
502 "threading/windows/WindowsThread.cpp",
504 # WASI hasn't supported thread yet so noop implementation is used.
505 elif CONFIG["OS_ARCH"] == "WASI":
507 "threading/noop/CpuCount.cpp",
508 "threading/noop/NoopThread.cpp",
512 "threading/posix/CpuCount.cpp",
513 "threading/posix/PosixThread.cpp",
516 if CONFIG["JS_HAS_INTL_API"] and CONFIG["MOZ_ICU4X"]:
518 "/intl/icu_capi/c/include",
521 if CONFIG["JS_HAS_CTYPES"]:
524 "ctypes/Library.cpp",
526 if not CONFIG["MOZ_SYSTEM_FFI"]:
528 "!ctypes/libffi/include",
529 "ctypes/libffi/src/%s" % CONFIG["FFI_TARGET_DIR"],
532 if CONFIG["MOZ_VTUNE"]:
534 "vtune/ittnotify_static.c",
535 "vtune/jitprofiling.c",
536 "vtune/VTuneWrapper.cpp",
538 SOURCES["vtune/ittnotify_static.c"].flags += [
541 "-Wno-unknown-pragmas",
543 if CONFIG["CC_TYPE"] == "gcc":
544 SOURCES["vtune/ittnotify_static.c"].flags += ["-Wno-stringop-overflow"]
545 if int(CONFIG["CC_VERSION"].split(".")[0]) >= 8:
546 SOURCES["vtune/ittnotify_static.c"].flags += ["-Wno-stringop-truncation"]
548 DIRS += ["build", "debugger", "frontend", "gc", "irregexp", "jit", "util", "wasm"]
550 if CONFIG["JS_HAS_TEMPORAL_API"]:
551 DIRS += ["builtin/temporal"]
553 # Bug 1739321 - clang 13+ only emits debuginfo for classes that are actually
554 # constructed, and we cheat in a number of cases. The flag exists at least
556 if CONFIG["CC_TYPE"] == "clang":
557 CXXFLAGS += ["-fstandalone-debug"]
559 # Bug 1722102 - This should never be enabled in Release without explicit
560 # security and SpiderMonkey review.
561 # See https://bugzilla.mozilla.org/show_bug.cgi?id=1722102#c16
562 if CONFIG["ENABLE_WASM_MOZ_INTGEMM"]:
565 if CONFIG["JS_JITSPEW"]:
570 selfhosted_inputs = [
571 "../public/friend/ErrorNumbers.msg",
572 # ProfilingCategoryList.h is being indirectly included, and it must be passed
573 # here as an input, so it's generated before this self-hosted JS code
574 # generation. Otherwise, it will intermittently fail to build.
575 "!/mozglue/baseprofiler/public/ProfilingCategoryList.h",
576 "builtin/TypedArrayConstants.h",
577 "builtin/SelfHostingDefines.h",
578 "builtin/Utilities.js",
580 "builtin/AsyncFunction.js",
581 "builtin/AsyncIteration.js",
585 "builtin/Generator.js",
586 "builtin/Iterator.js",
590 "builtin/Promise.js",
591 "builtin/Reflect.js",
593 "builtin/RegExpGlobalReplaceOpt.h.js",
594 "builtin/RegExpLocalReplaceOpt.h.js",
597 "builtin/Sorting.js",
598 "builtin/TypedArray.js",
599 "builtin/WeakMap.js",
600 "builtin/WeakSet.js",
603 "builtin/intl/NumberingSystemsGenerated.h",
604 "builtin/intl/Collator.js",
605 "builtin/intl/CommonFunctions.js",
606 "builtin/intl/CurrencyDataGenerated.js",
607 "builtin/intl/DateTimeFormat.js",
608 "builtin/intl/DisplayNames.js",
609 "builtin/intl/IntlObject.js",
610 "builtin/intl/ListFormat.js",
611 "builtin/intl/NumberFormat.js",
612 "builtin/intl/PluralRules.js",
613 "builtin/intl/RelativeTimeFormat.js",
614 "builtin/intl/SanctionedSimpleUnitIdentifiersGenerated.js",
615 "builtin/intl/Segmenter.js",
617 if CONFIG["JS_HAS_INTL_API"]
621 if CONFIG["ENABLE_RECORD_TUPLE"]:
622 selfhosted_inputs += ["builtin/Tuple.js"]
624 # Prepare self-hosted JS code for embedding
628 script="builtin/embedjs.py",
629 entry_point="generate_selfhosted",
630 inputs=selfhosted_inputs,
634 "../public/PrefsGenerated.h",
635 script="GeneratePrefs.py",
636 entry_point="generate_prefs_header",
637 inputs=["../../modules/libpref/init/StaticPrefList.yaml"],
640 if CONFIG["JS_HAS_CTYPES"]:
641 if CONFIG["MOZ_SYSTEM_FFI"]:
642 CXXFLAGS += CONFIG["MOZ_FFI_CFLAGS"]
644 if CONFIG["JS_HAS_INTL_API"]:
645 if CONFIG["JS_STANDALONE"]:
648 "../../intl/components",
651 USE_LIBS += ["intlcomponents"]