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/AllocationLogging.h",
123 "../public/AllocationRecording.h",
124 "../public/AllocPolicy.h",
126 "../public/ArrayBuffer.h",
127 "../public/ArrayBufferMaybeShared.h",
128 "../public/BigInt.h",
129 "../public/BuildId.h",
130 "../public/CallAndConstruct.h",
131 "../public/CallArgs.h",
132 "../public/CallNonGenericMethod.h",
133 "../public/CharacterEncoding.h",
135 "../public/ColumnNumber.h",
136 "../public/ComparisonOperators.h",
137 "../public/CompilationAndEvaluation.h",
138 "../public/CompileOptions.h",
139 "../public/Context.h",
140 "../public/ContextOptions.h",
141 "../public/Conversions.h",
144 "../public/Equality.h",
145 "../public/ErrorInterceptor.h",
146 "../public/ErrorReport.h",
147 "../public/Exception.h",
148 "../public/ForOfIterator.h",
149 "../public/GCAnnotations.h",
151 "../public/GCHashTable.h",
152 "../public/GCPolicyAPI.h",
153 "../public/GCTypeMacros.h",
154 "../public/GCVariant.h",
155 "../public/GCVector.h",
156 "../public/GlobalObject.h",
157 "../public/HashTable.h",
158 "../public/HeapAPI.h",
159 "../public/HelperThreadAPI.h",
161 "../public/Initialization.h",
162 "../public/Interrupt.h",
163 "../public/Iterator.h",
164 "../public/JitCodeAPI.h",
166 "../public/LocaleSensitive.h",
167 "../public/MapAndSet.h",
168 "../public/MemoryCallbacks.h",
169 "../public/MemoryFunctions.h",
170 "../public/MemoryMetrics.h",
171 "../public/Modules.h",
172 "../public/Object.h",
173 "../public/Principals.h",
174 "../public/Printer.h",
175 "../public/Printf.h",
176 "../public/ProfilingCategory.h",
177 "../public/ProfilingFrameIterator.h",
178 "../public/ProfilingStack.h",
179 "../public/Promise.h",
180 "../public/PropertyAndElement.h",
181 "../public/PropertyDescriptor.h",
182 "../public/PropertySpec.h",
183 "../public/ProtoKey.h",
186 "../public/RealmIterators.h",
187 "../public/RealmOptions.h",
188 "../public/RefCounted.h",
189 "../public/RegExp.h",
190 "../public/RegExpFlags.h",
191 "../public/Result.h",
192 "../public/RootingAPI.h",
193 "../public/SavedFrameAPI.h",
194 "../public/ScalarType.h",
195 "../public/ScriptPrivate.h",
196 "../public/ShadowRealmCallbacks.h",
197 "../public/SharedArrayBuffer.h",
198 "../public/SliceBudget.h",
199 "../public/SourceText.h",
200 "../public/StableStringChars.h",
202 "../public/StreamConsumer.h",
203 "../public/String.h",
204 "../public/StructuredClone.h",
205 "../public/Symbol.h",
206 "../public/TelemetryTimers.h",
207 "../public/TraceKind.h",
208 "../public/TracingAPI.h",
209 "../public/Transcoding.h",
210 "../public/TypeDecls.h",
211 "../public/UbiNode.h",
212 "../public/UbiNodeBreadthFirst.h",
213 "../public/UbiNodeCensus.h",
214 "../public/UbiNodeDominatorTree.h",
215 "../public/UbiNodePostOrder.h",
216 "../public/UbiNodeShortestPaths.h",
217 "../public/UbiNodeUtils.h",
218 "../public/UniquePtr.h",
219 "../public/Utility.h",
221 "../public/ValueArray.h",
222 "../public/Vector.h",
223 "../public/WaitCallbacks.h",
224 "../public/Warnings.h",
225 "../public/WasmFeatures.h",
226 "../public/WasmModule.h",
227 "../public/WeakMap.h",
228 "../public/WeakMapPtr.h",
229 "../public/Wrapper.h",
230 "../public/WrapperCallbacks.h",
234 # This lives in mozglue/baseprofiler but we re-publish ourselves to support
235 # standalone SpiderMonkey configurations.
237 "!/mozglue/baseprofiler/public/ProfilingCategoryList.h",
240 # Public APIs that are experimental: the precise contour of the APIs may still
241 # change, but they're at least plausible first passes at designing something.
242 # We expose them as-is, buyer beware.
243 EXPORTS.js.experimental += [
244 "../public/experimental/CodeCoverage.h",
245 "../public/experimental/CompileScript.h",
246 "../public/experimental/CTypes.h",
247 "../public/experimental/Intl.h",
248 "../public/experimental/JitInfo.h",
249 "../public/experimental/JSStencil.h",
250 "../public/experimental/PCCountProfiling.h",
251 "../public/experimental/SourceHook.h",
252 "../public/experimental/TypedData.h",
255 # Friend APIs are APIs that either basically SpiderMonkey-internal, or their
256 # contours are gross and terrible -- but the functionality is too important to
257 # some embedder (often, Gecko) to just not expose anything or to agonize through
258 # a clean design. Use this only if you absolutely must, and feel free to
259 # propose clean APIs to replace what's here!
260 EXPORTS.js.friend += [
261 "../public/friend/DOMProxy.h",
262 "../public/friend/DumpFunctions.h",
263 "../public/friend/ErrorMessages.h",
264 "../public/friend/ErrorNumbers.msg",
265 "../public/friend/JSMEnvironment.h",
266 "../public/friend/PerformanceHint.h",
267 "../public/friend/StackLimits.h",
268 "../public/friend/UsageStatistics.h",
269 "../public/friend/WindowProxy.h",
270 "../public/friend/XrayJitInfo.h",
273 # "Shadow" API defines the internal layout of public JSAPI types like |JSObject|
274 # and |JSString|, so that other *inline* public functions can efficiently access
275 # their internal fields.
277 # Embedders must never include these headers themselves or use their contents.
278 # These internal layout details are publicly exposed for access *only* so that
279 # other public API definitions may use them.
281 # When adding new shadow structure definitions (or new fields/static constants
282 # to existing structures) for access by inline methods, make sure to add static
283 # asserts to the original header file to ensure that offsets and duplicated
284 # constants are consistent. (Long term, it might be worth figuring out some way
285 # to back actual implementations *with* these shadow definitions to eliminate
287 EXPORTS.js.shadow += [
288 "../public/shadow/Function.h",
289 "../public/shadow/Object.h",
290 "../public/shadow/Realm.h",
291 "../public/shadow/Shape.h",
292 "../public/shadow/String.h",
293 "../public/shadow/Symbol.h",
294 "../public/shadow/Zone.h",
299 "builtin/AtomicsObject.cpp",
300 "builtin/BigInt.cpp",
301 "builtin/Boolean.cpp",
302 "builtin/DataViewObject.cpp",
304 "builtin/FinalizationRegistryObject.cpp",
306 "builtin/MapObject.cpp",
307 "builtin/ModuleObject.cpp",
308 "builtin/Object.cpp",
309 "builtin/Profilers.cpp",
310 "builtin/Promise.cpp",
311 "builtin/Reflect.cpp",
312 "builtin/ReflectParse.cpp",
313 "builtin/ShadowRealm.cpp",
314 "builtin/String.cpp",
315 "builtin/Symbol.cpp",
316 "builtin/TestingFunctions.cpp",
317 "builtin/TestingUtility.cpp",
318 "builtin/WeakMapObject.cpp",
319 "builtin/WeakRefObject.cpp",
320 "builtin/WeakSetObject.cpp",
321 "builtin/WrappedFunctionObject.cpp",
329 "proxy/BaseProxyHandler.cpp",
330 "proxy/CrossCompartmentWrapper.cpp",
331 "proxy/DeadObjectProxy.cpp",
332 "proxy/DOMProxy.cpp",
333 "proxy/OpaqueCrossCompartmentWrapper.cpp",
335 "proxy/ScriptedProxyHandler.cpp",
336 "proxy/SecurityWrapper.cpp",
338 "threading/Mutex.cpp",
339 "threading/ProtectedData.cpp",
340 "threading/Thread.cpp",
342 "vm/ArgumentsObject.cpp",
343 "vm/ArrayBufferObject.cpp",
344 "vm/ArrayBufferObjectMaybeShared.cpp",
345 "vm/ArrayBufferViewObject.cpp",
346 "vm/AsyncFunction.cpp",
347 "vm/AsyncIteration.cpp",
349 "vm/BoundFunctionObject.cpp",
351 "vm/BuiltinObjectKind.cpp",
352 "vm/BytecodeLocation.cpp",
353 "vm/BytecodeUtil.cpp",
354 "vm/CallAndConstruct.cpp",
355 "vm/CallNonGenericMethod.cpp",
356 "vm/CharacterEncoding.cpp",
357 "vm/CodeCoverage.cpp",
358 "vm/Compartment.cpp",
359 "vm/CompilationAndEvaluation.cpp",
360 "vm/Compression.cpp",
361 "vm/ConcurrentDelazification.cpp",
363 "vm/EnvironmentObject.cpp",
364 "vm/EqualityOperations.cpp",
365 "vm/ErrorMessages.cpp",
366 "vm/ErrorObject.cpp",
367 "vm/ErrorReporting.cpp",
369 "vm/ForOfIterator.cpp",
371 "vm/FunctionFlags.cpp",
372 "vm/GeckoProfiler.cpp",
373 "vm/GeneratorObject.cpp",
374 "vm/GetterSetter.cpp",
375 "vm/GlobalObject.cpp",
376 "vm/HelperThreads.cpp",
378 "vm/Initialization.cpp",
379 "vm/InternalThreadPool.cpp",
382 "vm/JitActivation.cpp",
383 "vm/JSAtomUtils.cpp",
388 "vm/JSONPrinter.cpp",
391 "vm/MemoryMetrics.cpp",
393 "vm/NativeObject.cpp",
394 "vm/OffThreadPromiseRuntimeState.cpp",
396 "vm/PlainObject.cpp",
399 "vm/PromiseLookup.cpp",
400 "vm/PropertyAndElement.cpp",
401 "vm/PropertyDescriptor.cpp",
403 "vm/ProxyObject.cpp",
406 "vm/RegExpObject.cpp",
407 "vm/RegExpStatics.cpp",
409 "vm/SavedStacks.cpp",
411 "vm/SelfHosting.cpp",
414 "vm/SharedArrayObject.cpp",
415 "vm/SharedImmutableStringsCache.cpp",
416 "vm/SharedScriptDataTableHolder.cpp",
419 "vm/StaticStrings.cpp",
420 "vm/StencilCache.cpp",
421 "vm/StencilObject.cpp",
424 "vm/TaggedProto.cpp",
425 "vm/ThrowMsgKind.cpp",
428 "vm/TypedArrayObject.cpp",
430 "vm/UbiNodeCensus.cpp",
431 "vm/UbiNodeShortestPaths.cpp",
432 "vm/UsageStatistics.cpp",
436 "vm/WellKnownAtom.cpp",
437 "vm/WindowProxy.cpp",
441 # builtin/RegExp.cpp cannot be built in unified mode because it causes huge
442 # win32 test slowdowns
443 # jsmath.cpp cannot be built in unified mode because it needs to re-#define the
444 # RtlGenRandom declaration's calling convention in <ntsecapi.h> on Windows.
445 # vm/Interpreter.cpp is gigantic and destroys incremental build times for any
446 # files unlucky enough to be unified with it.
448 "builtin/RegExp.cpp",
450 "vm/Interpreter.cpp",
451 "vm/ProfilingStack.cpp",
454 if CONFIG["ENABLE_PORTABLE_BASELINE_INTERP"]:
456 "vm/PortableBaselineInterpret.cpp",
459 if CONFIG["ENABLE_RECORD_TUPLE"]:
461 "builtin/RecordObject.cpp",
462 "builtin/TupleObject.cpp",
463 "vm/RecordTupleShared.cpp",
468 if CONFIG["JS_HAS_INTL_API"]:
470 "builtin/intl/Collator.cpp",
471 "builtin/intl/CommonFunctions.cpp",
472 "builtin/intl/DateTimeFormat.cpp",
473 "builtin/intl/DisplayNames.cpp",
474 "builtin/intl/IntlObject.cpp",
475 "builtin/intl/LanguageTag.cpp",
476 "builtin/intl/ListFormat.cpp",
477 "builtin/intl/Locale.cpp",
478 "builtin/intl/NumberFormat.cpp",
479 "builtin/intl/PluralRules.cpp",
480 "builtin/intl/RelativeTimeFormat.cpp",
481 "builtin/intl/Segmenter.cpp",
482 "builtin/intl/SharedIntlData.cpp",
485 if CONFIG["MOZ_INSTRUMENTS"]:
487 "devtools/Instruments.cpp",
490 if CONFIG["OS_ARCH"] == "WINNT":
495 "threading/windows/CpuCount.cpp",
496 "threading/windows/WindowsThread.cpp",
498 # WASI hasn't supported thread yet so noop implementation is used.
499 elif CONFIG["OS_ARCH"] == "WASI":
501 "threading/noop/CpuCount.cpp",
502 "threading/noop/NoopThread.cpp",
506 "threading/posix/CpuCount.cpp",
507 "threading/posix/PosixThread.cpp",
510 if CONFIG["JS_HAS_INTL_API"] and CONFIG["MOZ_ICU4X"]:
512 "/intl/icu_capi/c/include",
515 if CONFIG["JS_HAS_CTYPES"]:
518 "ctypes/Library.cpp",
520 if not CONFIG["MOZ_SYSTEM_FFI"]:
522 "!ctypes/libffi/include",
523 "ctypes/libffi/src/%s" % CONFIG["FFI_TARGET_DIR"],
526 if CONFIG["MOZ_VTUNE"]:
528 "vtune/ittnotify_static.c",
529 "vtune/jitprofiling.c",
530 "vtune/VTuneWrapper.cpp",
532 SOURCES["vtune/ittnotify_static.c"].flags += [
535 "-Wno-unknown-pragmas",
537 if CONFIG["CC_TYPE"] == "gcc":
538 SOURCES["vtune/ittnotify_static.c"].flags += ["-Wno-stringop-overflow"]
539 if int(CONFIG["CC_VERSION"].split(".")[0]) >= 8:
540 SOURCES["vtune/ittnotify_static.c"].flags += ["-Wno-stringop-truncation"]
542 DIRS += ["build", "debugger", "frontend", "gc", "irregexp", "jit", "util", "wasm"]
544 if CONFIG["JS_HAS_TEMPORAL_API"]:
545 DIRS += ["builtin/temporal"]
547 # Bug 1739321 - clang 13+ only emits debuginfo for classes that are actually
548 # constructed, and we cheat in a number of cases. The flag exists at least
550 if CONFIG["CC_TYPE"] == "clang":
551 CXXFLAGS += ["-fstandalone-debug"]
553 # Bug 1722102 - This should never be enabled in Release without explicit
554 # security and SpiderMonkey review.
555 # See https://bugzilla.mozilla.org/show_bug.cgi?id=1722102#c16
556 if CONFIG["ENABLE_WASM_MOZ_INTGEMM"]:
559 if CONFIG["JS_JITSPEW"]:
564 selfhosted_inputs = [
565 "../public/friend/ErrorNumbers.msg",
566 # ProfilingCategoryList.h is being indirectly included, and it must be passed
567 # here as an input, so it's generated before this self-hosted JS code
568 # generation. Otherwise, it will intermittently fail to build.
569 "!/mozglue/baseprofiler/public/ProfilingCategoryList.h",
570 "builtin/TypedArrayConstants.h",
571 "builtin/SelfHostingDefines.h",
572 "builtin/Utilities.js",
574 "builtin/AsyncFunction.js",
575 "builtin/AsyncIteration.js",
579 "builtin/Generator.js",
580 "builtin/Iterator.js",
584 "builtin/Promise.js",
585 "builtin/Reflect.js",
587 "builtin/RegExpGlobalReplaceOpt.h.js",
588 "builtin/RegExpLocalReplaceOpt.h.js",
591 "builtin/Sorting.js",
592 "builtin/TypedArray.js",
593 "builtin/WeakMap.js",
594 "builtin/WeakSet.js",
597 "builtin/intl/NumberingSystemsGenerated.h",
598 "builtin/intl/Collator.js",
599 "builtin/intl/CommonFunctions.js",
600 "builtin/intl/CurrencyDataGenerated.js",
601 "builtin/intl/DateTimeFormat.js",
602 "builtin/intl/DisplayNames.js",
603 "builtin/intl/IntlObject.js",
604 "builtin/intl/ListFormat.js",
605 "builtin/intl/NumberFormat.js",
606 "builtin/intl/PluralRules.js",
607 "builtin/intl/RelativeTimeFormat.js",
608 "builtin/intl/SanctionedSimpleUnitIdentifiersGenerated.js",
609 "builtin/intl/Segmenter.js",
611 if CONFIG["JS_HAS_INTL_API"]
615 if CONFIG["ENABLE_RECORD_TUPLE"]:
616 selfhosted_inputs += ["builtin/Tuple.js"]
618 # Prepare self-hosted JS code for embedding
622 script="builtin/embedjs.py",
623 entry_point="generate_selfhosted",
624 inputs=selfhosted_inputs,
627 if CONFIG["JS_HAS_CTYPES"]:
628 if CONFIG["MOZ_SYSTEM_FFI"]:
629 CXXFLAGS += CONFIG["MOZ_FFI_CFLAGS"]
631 if CONFIG["JS_HAS_INTL_API"]:
633 "../../intl/components",
636 USE_LIBS += ["intlcomponents"]