Debian Codegraph @

js/src/jit/JitSpewer.cpp

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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/. */
6
7 #ifdef JS_JITSPEW
8
9 # include "jit/JitSpewer.h"
10
11 # include "mozilla/Atomics.h"
12 # include "mozilla/Sprintf.h"
13
14 # include "jit/MIR.h"
15 # include "jit/MIRGenerator.h"
16 # include "jit/MIRGraph.h"
17 # include "threading/LockGuard.h"
18 # include "util/GetPidProvider.h" // getpid()
19 # include "vm/MutexIDs.h"
20
21 # ifndef JIT_SPEW_DIR
22 # if defined(_WIN32)
23 # define JIT_SPEW_DIR "."
24 # elif defined(__ANDROID__)
25 # define JIT_SPEW_DIR "/data/local/tmp"
26 # else
27 # define JIT_SPEW_DIR "/tmp"
28 # endif
29 # endif
30
31 using namespace js;
32 using namespace js::jit;
33 using namespace js::jitspew::detail;
34
35 class IonSpewer {
36 private:
37 Mutex outputLock_ MOZ_UNANNOTATED;
38 Fprinter jsonOutput_;
39 bool firstFunction_;
40 bool asyncLogging_;
41 bool inited_;
42
43 void release();
44
45 public:
46 IonSpewer()
47 : outputLock_(mutexid::IonSpewer),
48 firstFunction_(false),
49 asyncLogging_(false),
50 inited_(false) {}
51
52 // File output is terminated safely upon destruction.
53 ~IonSpewer();
54
55 bool init();
56 bool isEnabled() { return inited_; }
57 void setAsyncLogging(bool incremental) { asyncLogging_ = incremental; }
58 bool getAsyncLogging() { return asyncLogging_; }
59
60 void beginFunction();
61 void spewPass(GraphSpewer* gs);
62 void endFunction(GraphSpewer* gs);
63 };
64
65 // IonSpewer singleton.
66 MOZ_RUNINIT static IonSpewer ionspewer;
67
68 bool jitspew::detail::LoggingChecked = false;
69 static_assert(JitSpew_Terminator <= 64,
70 "Increase the size of the LoggingBits global.");
71 uint64_t jitspew::detail::LoggingBits = 0;
72 mozilla::Atomic<uint32_t, mozilla::Relaxed>
73 jitspew::detail::filteredOutCompilations(0);
74
75 static const char* const ChannelNames[] = {
76 # define JITSPEW_CHANNEL(name) #name,
77 JITSPEW_CHANNEL_LIST(JITSPEW_CHANNEL)
78 # undef JITSPEW_CHANNEL
79 };
80
81 static size_t ChannelIndentLevel[] = {
82 # define JITSPEW_CHANNEL(name) 0,
83 JITSPEW_CHANNEL_LIST(JITSPEW_CHANNEL)
84 # undef JITSPEW_CHANNEL
85 };
86
87 // The IONFILTER environment variable specifies an expression to select only
88 // certain functions for spewing to reduce amount of log data generated.
89 static const char* gSpewFilter = nullptr;
90
91 static bool FilterContainsLocation(JSScript* function) {
92 // If there is no filter we accept all outputs.
93 if (!gSpewFilter || !gSpewFilter[0]) {
94 return true;
95 }
96
97 // Disable wasm output when filter is set.
98 if (!function) {
99 return false;
100 }
101
102 const char* filename = function->filename();
103 const size_t line = function->lineno();
104 const size_t filelen = strlen(filename);
105 const char* index = strstr(gSpewFilter, filename);
106 while (index) {
107 if (index == gSpewFilter || index[-1] == ',') {
108 if (index[filelen] == 0 || index[filelen] == ',') {
109 return true;
110 }
111 if (index[filelen] == ':' && line != size_t(-1)) {
112 size_t read_line = strtoul(&index[filelen + 1], nullptr, 10);
113 if (read_line == line) {
114 return true;
115 }
116 }
117 }
118 index = strstr(index + filelen, filename);
119 }
120 return false;
121 }
122
123 void jit::EnableIonDebugSyncLogging() {
124 ionspewer.init();
125 ionspewer.setAsyncLogging(false);
126 EnableChannel(JitSpew_IonSyncLogs);
127 }
128
129 void jit::EnableIonDebugAsyncLogging() {
130 ionspewer.init();
131 ionspewer.setAsyncLogging(true);
132 }
133
134 void IonSpewer::release() {
135 if (jsonOutput_.isInitialized()) {
136 jsonOutput_.finish();
137 }
138 inited_ = false;
139 }
140
141 bool IonSpewer::init() {
142 if (inited_) {
143 return true;
144 }
145
146 // Filter expression for spewing
147 gSpewFilter = getenv("IONFILTER");
148
149 const size_t bufferLength = 256;
150 char jsonBuffer[bufferLength];
151 const char* jsonFilename = JIT_SPEW_DIR "/ion.json";
152
153 const char* usePid = getenv("ION_SPEW_BY_PID");
154 if (usePid && *usePid != 0) {
155 uint32_t pid = getpid();
156 size_t len;
157 len = SprintfLiteral(jsonBuffer, JIT_SPEW_DIR "/ion%" PRIu32 ".json", pid);
158 if (bufferLength <= len) {
159 fprintf(stderr, "Warning: IonSpewer::init: Cannot serialize file name.");
160 return false;
161 }
162 jsonFilename = jsonBuffer;
163 }
164
165 if (!jsonOutput_.init(jsonFilename)) {
166 release();
167 return false;
168 }
169
170 jsonOutput_.printf("{\n \"functions\": [\n");
171 firstFunction_ = true;
172
173 inited_ = true;
174 return true;
175 }
176
177 void IonSpewer::beginFunction() {
178 // If we are doing a synchronous logging then we spew everything as we go,
179 // as this is useful in case of failure during the compilation. On the other
180 // hand, it is recommended to disable off thread compilation.
181 if (!getAsyncLogging() && !firstFunction_) {
182 LockGuard<Mutex> guard(outputLock_);
183 jsonOutput_.put(","); // separate functions
184 }
185 }
186
187 void IonSpewer::spewPass(GraphSpewer* gs) {
188 if (!getAsyncLogging()) {
189 LockGuard<Mutex> guard(outputLock_);
190 gs->dump(jsonOutput_);
191 }
192 }
193
194 void IonSpewer::endFunction(GraphSpewer* gs) {
195 LockGuard<Mutex> guard(outputLock_);
196 if (getAsyncLogging() && !firstFunction_) {
197 jsonOutput_.put(","); // separate functions
198 }
199
200 gs->dump(jsonOutput_);
201 firstFunction_ = false;
202 }
203
204 IonSpewer::~IonSpewer() {
205 if (!inited_) {
206 return;
207 }
208
209 jsonOutput_.printf("\n]}\n");
210 release();
211 }
212
213 GraphSpewer::GraphSpewer(TempAllocator* alloc,
214 const wasm::CodeMetadata* wasmCodeMeta)
215 : graph_(nullptr),
216 jsonPrinter_(alloc->lifoAlloc()),
217 jsonSpewer_(jsonPrinter_, wasmCodeMeta) {}
218
219 void GraphSpewer::init(MIRGraph* graph, JSScript* function) {
220 MOZ_ASSERT(!isSpewing());
221 if (!ionspewer.isEnabled()) {
222 return;
223 }
224
225 if (!FilterContainsLocation(function)) {
226 // filter out logs during the compilation.
227 filteredOutCompilations++;
228 MOZ_ASSERT(!isSpewing());
229 return;
230 }
231
232 graph_ = graph;
233 MOZ_ASSERT(isSpewing());
234 }
235
236 void GraphSpewer::beginFunction(JSScript* function) {
237 if (!isSpewing()) {
238 return;
239 }
240 jsonSpewer_.beginFunction(function);
241 ionspewer.beginFunction();
242 }
243
244 void GraphSpewer::beginWasmFunction(unsigned funcIndex) {
245 if (!isSpewing()) {
246 return;
247 }
248 jsonSpewer_.beginWasmFunction(funcIndex);
249 ionspewer.beginFunction();
250 }
251
252 void GraphSpewer::spewPass(const char* pass) {
253 if (!isSpewing()) {
254 return;
255 }
256
257 jsonSpewer_.beginPass(pass);
258 jsonSpewer_.spewMIR(graph_);
259 jsonSpewer_.spewLIR(graph_);
260 jsonSpewer_.endPass();
261
262 ionspewer.spewPass(this);
263
264 // As this function is used for debugging, we ignore any of the previous
265 // failures and ensure there is enough ballast space, such that we do not
266 // exhaust the ballast space before running the next phase.
267 AutoEnterOOMUnsafeRegion oomUnsafe;
268 if (!graph_->alloc().ensureBallast()) {
269 oomUnsafe.crash(
270 "Could not ensure enough ballast space after spewing graph "
271 "information.");
272 }
273 }
274
275 void GraphSpewer::spewPass(const char* pass, BacktrackingAllocator* ra) {
276 if (!isSpewing()) {
277 return;
278 }
279
280 jsonSpewer_.beginPass(pass);
281 jsonSpewer_.spewMIR(graph_);
282 jsonSpewer_.spewLIR(graph_);
283 jsonSpewer_.spewRanges(ra);
284 jsonSpewer_.endPass();
285
286 ionspewer.spewPass(this);
287 }
288
289 void GraphSpewer::endFunction() {
290 if (!ionspewer.isEnabled()) {
291 return;
292 }
293
294 if (!isSpewing()) {
295 MOZ_ASSERT(filteredOutCompilations != 0);
296 filteredOutCompilations--;
297 return;
298 }
299
300 jsonSpewer_.endFunction();
301
302 ionspewer.endFunction(this);
303 graph_ = nullptr;
304 }
305
306 void GraphSpewer::dump(Fprinter& jsonOut) {
307 if (!jsonPrinter_.hadOutOfMemory()) {
308 jsonPrinter_.exportInto(jsonOut);
309 } else {
310 jsonOut.put("{}");
311 }
312 jsonOut.flush();
313 jsonPrinter_.clear();
314 }
315
316 void jit::SpewBeginFunction(MIRGenerator* mir, JSScript* function) {
317 MIRGraph* graph = &mir->graph();
318 mir->graphSpewer().init(graph, function);
319 mir->graphSpewer().beginFunction(function);
320 }
321
322 void jit::SpewBeginWasmFunction(MIRGenerator* mir, unsigned funcIndex) {
323 MIRGraph* graph = &mir->graph();
324 mir->graphSpewer().init(graph, nullptr);
325 mir->graphSpewer().beginWasmFunction(funcIndex);
326 }
327
328 AutoSpewEndFunction::~AutoSpewEndFunction() {
329 mir_->graphSpewer().endFunction();
330 }
331
332 Fprinter& jit::JitSpewPrinter() {
333 static Fprinter out;
334 return out;
335 }
336
337 static void PrintHelpAndExit(int status = 0) {
338 fflush(nullptr);
339 printf(
340 "\n"
341 "usage: IONFLAGS=option,option,option,... where options can be:\n"
342 "\n"
343 " aborts Compilation abort messages\n"
344 " scripts Compiled scripts\n"
345 " mir MIR information\n"
346 " prune Prune unused branches\n"
347 " escape Escape analysis\n"
348 " alias Alias analysis\n"
349 " alias-sum Alias analysis: shows summaries for every block\n"
350 " gvn Global Value Numbering\n"
351 " licm Loop invariant code motion\n"
352 " flac Fold linear arithmetic constants\n"
353 " eaa Effective address analysis\n"
354 " sink Sink transformation\n"
355 " regalloc Register allocation\n"
356 " inline Inlining\n"
357 " snapshots Snapshot information\n"
358 " codegen Native code generation\n"
359 " bailouts Bailouts\n"
360 " caches Inline caches\n"
361 " osi Invalidation\n"
362 " safepoints Safepoints\n"
363 " pools Literal Pools (ARM only for now)\n"
364 " cacheflush Instruction Cache flushes (ARM only for now)\n"
365 " range Range Analysis\n"
366 " branch-hint Wasm Branch Hinting\n"
367 " wasmbce Wasm Bounds Check Elimination\n"
368 " shapeguards Redundant shape guard elimination\n"
369 " gcbarriers Redundant GC barrier elimination\n"
370 " loadkeys Loads used as property keys\n"
371 " stubfolding CacheIR stub folding\n"
372 " logs JSON visualization logging\n"
373 " logs-sync Same as logs, but flushes between each pass (sync. "
374 "compiled functions only).\n"
375 " profiling Profiling-related information\n"
376 " dump-mir-expr Dump the MIR expressions\n"
377 " unroll Wasm loop unrolling and peeling -- summary info\n"
378 " unroll-details Wasm loop unrolling and peeling -- details\n"
379 " warp-snapshots WarpSnapshots created by WarpOracle\n"
380 " warp-transpiler Warp CacheIR transpiler\n"
381 " warp-trial-inlining Trial inlining for Warp\n"
382 " all Everything\n"
383 "\n"
384 " bl-aborts Baseline compiler abort messages\n"
385 " bl-scripts Baseline script-compilation\n"
386 " bl-op Baseline compiler detailed op-specific messages\n"
387 " bl-ic Baseline inline-cache messages\n"
388 " bl-ic-fb Baseline IC fallback stub messages\n"
389 " bl-osr Baseline IC OSR messages\n"
390 " bl-bails Baseline bailouts\n"
391 " bl-dbg-osr Baseline debug mode on stack recompile messages\n"
392 " bl-all All baseline spew\n"
393 "\n"
394 "See also SPEW=help for information on the Structured Spewer."
395 "\n");
396 exit(status);
397 }
398
399 static bool IsFlag(const char* found, const char* flag) {
400 return strlen(found) == strlen(flag) && strcmp(found, flag) == 0;
401 }
402
403 void jit::CheckLogging() {
404 if (LoggingChecked) {
405 return;
406 }
407
408 LoggingChecked = true;
409
410 char* env = getenv("IONFLAGS");
411 if (!env) {
412 return;
413 }
414
415 const char* found = strtok(env, ",");
416 while (found) {
417 fprintf(stderr, "found tag: %s\n", found);
418 // We're at the end of a flag; check if the previous substring was a
419 // known flag (i-1 is the last character of the flag we just read).
420 if (IsFlag(found, "help")) {
421 PrintHelpAndExit();
422 } else if (IsFlag(found, "aborts")) {
423 EnableChannel(JitSpew_IonAbort);
424 } else if (IsFlag(found, "prune")) {
425 EnableChannel(JitSpew_Prune);
426 } else if (IsFlag(found, "escape")) {
427 EnableChannel(JitSpew_Escape);
428 } else if (IsFlag(found, "alias")) {
429 EnableChannel(JitSpew_Alias);
430 } else if (IsFlag(found, "alias-sum")) {
431 EnableChannel(JitSpew_AliasSummaries);
432 } else if (IsFlag(found, "scripts")) {
433 EnableChannel(JitSpew_IonScripts);
434 } else if (IsFlag(found, "mir")) {
435 EnableChannel(JitSpew_IonMIR);
436 } else if (IsFlag(found, "gvn")) {
437 EnableChannel(JitSpew_GVN);
438 } else if (IsFlag(found, "range")) {
439 EnableChannel(JitSpew_Range);
440 } else if (IsFlag(found, "wasmbce")) {
441 EnableChannel(JitSpew_WasmBCE);
442 } else if (IsFlag(found, "branch-hint")) {
443 EnableChannel(JitSpew_BranchHint);
444 } else if (IsFlag(found, "licm")) {
445 EnableChannel(JitSpew_LICM);
446 } else if (IsFlag(found, "flac")) {
447 EnableChannel(JitSpew_FLAC);
448 } else if (IsFlag(found, "eaa")) {
449 EnableChannel(JitSpew_EAA);
450 } else if (IsFlag(found, "sink")) {
451 EnableChannel(JitSpew_Sink);
452 } else if (IsFlag(found, "regalloc")) {
453 EnableChannel(JitSpew_RegAlloc);
454 } else if (IsFlag(found, "inline")) {
455 EnableChannel(JitSpew_Inlining);
456 } else if (IsFlag(found, "snapshots")) {
457 EnableChannel(JitSpew_IonSnapshots);
458 } else if (IsFlag(found, "codegen")) {
459 EnableChannel(JitSpew_Codegen);
460 } else if (IsFlag(found, "bailouts")) {
461 EnableChannel(JitSpew_IonBailouts);
462 } else if (IsFlag(found, "osi")) {
463 EnableChannel(JitSpew_IonInvalidate);
464 } else if (IsFlag(found, "caches")) {
465 EnableChannel(JitSpew_IonIC);
466 } else if (IsFlag(found, "safepoints")) {
467 EnableChannel(JitSpew_Safepoints);
468 } else if (IsFlag(found, "pools")) {
469 EnableChannel(JitSpew_Pools);
470 } else if (IsFlag(found, "cacheflush")) {
471 EnableChannel(JitSpew_CacheFlush);
472 } else if (IsFlag(found, "shapeguards")) {
473 EnableChannel(JitSpew_RedundantShapeGuards);
474 } else if (IsFlag(found, "gcbarriers")) {
475 EnableChannel(JitSpew_RedundantGCBarriers);
476 } else if (IsFlag(found, "loadkeys")) {
477 EnableChannel(JitSpew_MarkLoadsUsedAsPropertyKeys);
478 } else if (IsFlag(found, "stubfolding")) {
479 EnableChannel(JitSpew_StubFolding);
480 } else if (IsFlag(found, "logs")) {
481 EnableIonDebugAsyncLogging();
482 } else if (IsFlag(found, "logs-sync")) {
483 EnableIonDebugSyncLogging();
484 } else if (IsFlag(found, "profiling")) {
485 EnableChannel(JitSpew_Profiling);
486 } else if (IsFlag(found, "dump-mir-expr")) {
487 EnableChannel(JitSpew_MIRExpressions);
488 } else if (IsFlag(found, "unroll")) {
489 EnableChannel(JitSpew_Unroll);
490 } else if (IsFlag(found, "unroll-details")) {
491 EnableChannel(JitSpew_Unroll);
492 EnableChannel(JitSpew_UnrollDetails);
493 } else if (IsFlag(found, "warp-snapshots")) {
494 EnableChannel(JitSpew_WarpSnapshots);
495 } else if (IsFlag(found, "warp-transpiler")) {
496 EnableChannel(JitSpew_WarpTranspiler);
497 } else if (IsFlag(found, "warp-trial-inlining")) {
498 EnableChannel(JitSpew_WarpTrialInlining);
499 } else if (IsFlag(found, "all")) {
500 LoggingBits = uint64_t(-1);
501 } else if (IsFlag(found, "bl-aborts")) {
502 EnableChannel(JitSpew_BaselineAbort);
503 } else if (IsFlag(found, "bl-scripts")) {
504 EnableChannel(JitSpew_BaselineScripts);
505 } else if (IsFlag(found, "bl-op")) {
506 EnableChannel(JitSpew_BaselineOp);
507 } else if (IsFlag(found, "bl-ic")) {
508 EnableChannel(JitSpew_BaselineIC);
509 } else if (IsFlag(found, "bl-ic-fb")) {
510 EnableChannel(JitSpew_BaselineICFallback);
511 } else if (IsFlag(found, "bl-osr")) {
512 EnableChannel(JitSpew_BaselineOSR);
513 } else if (IsFlag(found, "bl-bails")) {
514 EnableChannel(JitSpew_BaselineBailouts);
515 } else if (IsFlag(found, "bl-dbg-osr")) {
516 EnableChannel(JitSpew_BaselineDebugModeOSR);
517 } else if (IsFlag(found, "bl-all")) {
518 EnableChannel(JitSpew_BaselineAbort);
519 EnableChannel(JitSpew_BaselineScripts);
520 EnableChannel(JitSpew_BaselineOp);
521 EnableChannel(JitSpew_BaselineIC);
522 EnableChannel(JitSpew_BaselineICFallback);
523 EnableChannel(JitSpew_BaselineOSR);
524 EnableChannel(JitSpew_BaselineBailouts);
525 EnableChannel(JitSpew_BaselineDebugModeOSR);
526 } else {
527 fprintf(stderr, "Unknown flag.\n");
528 PrintHelpAndExit(64);
529 }
530 found = strtok(nullptr, ",");
531 }
532
533 FILE* spewfh = stderr;
534 const char* filename = getenv("ION_SPEW_FILENAME");
535 if (filename && *filename) {
536 char actual_filename[2048] = {0};
537 SprintfLiteral(actual_filename, "%s.%d", filename, getpid());
538 spewfh = fopen(actual_filename, "w");
539 MOZ_RELEASE_ASSERT(spewfh);
540 setbuf(spewfh, nullptr); // Make unbuffered
541 }
542 JitSpewPrinter().init(spewfh);
543 }
544
545 JitSpewIndent::JitSpewIndent(JitSpewChannel channel) : channel_(channel) {
546 ChannelIndentLevel[channel]++;
547 }
548
549 JitSpewIndent::~JitSpewIndent() { ChannelIndentLevel[channel_]--; }
550
551 void jit::JitSpewStartVA(JitSpewChannel channel, const char* fmt, va_list ap) {
552 if (!JitSpewEnabled(channel)) {
553 return;
554 }
555
556 JitSpewHeader(channel);
557 Fprinter& out = JitSpewPrinter();
558 out.vprintf(fmt, ap);
559 }
560
561 void jit::JitSpewContVA(JitSpewChannel channel, const char* fmt, va_list ap) {
562 if (!JitSpewEnabled(channel)) {
563 return;
564 }
565
566 Fprinter& out = JitSpewPrinter();
567 out.vprintf(fmt, ap);
568 }
569
570 void jit::JitSpewFin(JitSpewChannel channel) {
571 if (!JitSpewEnabled(channel)) {
572 return;
573 }
574
575 Fprinter& out = JitSpewPrinter();
576 out.put("\n");
577 }
578
579 void jit::JitSpewVA(JitSpewChannel channel, const char* fmt, va_list ap) {
580 JitSpewStartVA(channel, fmt, ap);
581 JitSpewFin(channel);
582 }
583
584 void jit::JitSpew(JitSpewChannel channel, const char* fmt, ...) {
585 va_list ap;
586 va_start(ap, fmt);
587 JitSpewVA(channel, fmt, ap);
588
589 // Suppress hazard analysis on logPrintVA function pointer.
590 JS::AutoSuppressGCAnalysis suppress;
591
592 switch (channel) {
593 # define SpewChannel(x) \
594 case JitSpew_##x: \
595 if (x##Module.shouldLog(js::LogLevel::Debug)) { \
596 x##Module.interface.logPrintVA(x##Module.logger, js::LogLevel::Debug, \
597 fmt, ap); \
598 } \
599 break;
600
601 JITSPEW_CHANNEL_LIST(SpewChannel)
602
603 # undef SpewChannel
604 case JitSpew_Terminator:
605 MOZ_CRASH("Unexpected JitSpew");
606 }
607
608 va_end(ap);
609 }
610
611 void jit::JitSpewDef(JitSpewChannel channel, const char* str,
612 MDefinition* def) {
613 if (!JitSpewEnabled(channel)) {
614 return;
615 }
616
617 JitSpewHeader(channel);
618 Fprinter& out = JitSpewPrinter();
619 out.put(str);
620 def->dump(out);
621 def->dumpLocation(out);
622 }
623
624 void jit::JitSpewStart(JitSpewChannel channel, const char* fmt, ...) {
625 va_list ap;
626 va_start(ap, fmt);
627 JitSpewStartVA(channel, fmt, ap);
628 va_end(ap);
629 }
630 void jit::JitSpewCont(JitSpewChannel channel, const char* fmt, ...) {
631 va_list ap;
632 va_start(ap, fmt);
633 JitSpewContVA(channel, fmt, ap);
634 va_end(ap);
635 }
636
637 void jit::JitSpewHeader(JitSpewChannel channel) {
638 if (!JitSpewEnabled(channel)) {
639 return;
640 }
641
642 Fprinter& out = JitSpewPrinter();
643 out.printf("[%s] ", ChannelNames[channel]);
644 for (size_t i = ChannelIndentLevel[channel]; i != 0; i--) {
645 out.put(" ");
646 }
647 }
648
649 void jit::EnableChannel(JitSpewChannel channel) {
650 MOZ_ASSERT(LoggingChecked);
651 LoggingBits |= uint64_t(1) << uint32_t(channel);
652 }
653
654 void jit::DisableChannel(JitSpewChannel channel) {
655 MOZ_ASSERT(LoggingChecked);
656 LoggingBits &= ~(uint64_t(1) << uint32_t(channel));
657 }
658
659 #endif /* JS_JITSPEW */
660
661 #if defined(JS_JITSPEW) || defined(ENABLE_JS_AOT_ICS)
662
663 const char* js::jit::ValTypeToString(JSValueType type) {
664 switch (type) {
665 case JSVAL_TYPE_DOUBLE:
666 return "Double";
667 case JSVAL_TYPE_INT32:
668 return "Int32";
669 case JSVAL_TYPE_BOOLEAN:
670 return "Boolean";
671 case JSVAL_TYPE_UNDEFINED:
672 return "Undefined";
673 case JSVAL_TYPE_NULL:
674 return "Null";
675 case JSVAL_TYPE_MAGIC:
676 return "Magic";
677 case JSVAL_TYPE_STRING:
678 return "String";
679 case JSVAL_TYPE_SYMBOL:
680 return "Symbol";
681 case JSVAL_TYPE_PRIVATE_GCTHING:
682 return "PrivateGCThing";
683 case JSVAL_TYPE_BIGINT:
684 return "BigInt";
685 case JSVAL_TYPE_OBJECT:
686 return "Object";
687 case JSVAL_TYPE_UNKNOWN:
688 return "None";
689 default:
690 MOZ_CRASH("Unknown JSValueType");
691 }
692 }
693
694 #endif /* defined(JS_JITSPEW) || defined(ENABLE_JS_AOT_ICS) */