Skip to content

Commit 7a9ed0c

Browse files
authored
[NFC] Use the new Timer utility to log times when debugging PossibleContents (#8228)
1 parent 93bde74 commit 7a9ed0c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/ir/possible-contents.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include "ir/module-utils.h"
2828
#include "ir/possible-contents.h"
2929
#include "support/insert_ordered.h"
30+
#ifdef POSSIBLE_CONTENTS_DEBUG
31+
#include "support/timing.h"
32+
#endif
3033
#include "wasm-type.h"
3134
#include "wasm.h"
3235

@@ -2274,18 +2277,24 @@ Flower::Flower(Module& wasm, const PassOptions& options)
22742277
if (options.trapsNeverHappen && wasm.features.hasGC()) {
22752278
#ifdef POSSIBLE_CONTENTS_DEBUG
22762279
std::cout << "tnh phase\n";
2280+
Timer timer;
22772281
#endif
22782282
tnhOracle = std::make_unique<TNHOracle>(wasm, options);
2283+
#ifdef POSSIBLE_CONTENTS_DEBUG
2284+
std::cout << "... " << timer.lastElapsed() << "\n";
2285+
#endif
22792286
}
22802287

22812288
#ifdef POSSIBLE_CONTENTS_DEBUG
22822289
std::cout << "subtypes phase\n";
2290+
Timer timer;
22832291
#endif
22842292

22852293
subTypes = std::make_unique<SubTypes>(wasm);
22862294
maxDepths = subTypes->getMaxDepths();
22872295

22882296
#ifdef POSSIBLE_CONTENTS_DEBUG
2297+
std::cout << "... " << timer.lastElapsed() << "\n";
22892298
std::cout << "parallel phase\n";
22902299
#endif
22912300

@@ -2324,6 +2333,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
23242333
});
23252334

23262335
#ifdef POSSIBLE_CONTENTS_DEBUG
2336+
std::cout << "... " << timer.lastElapsed() << "\n";
23272337
std::cout << "single phase\n";
23282338
#endif
23292339

@@ -2334,6 +2344,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
23342344
finder.walkModuleCode(&wasm);
23352345

23362346
#ifdef POSSIBLE_CONTENTS_DEBUG
2347+
std::cout << "... " << timer.lastElapsed() << "\n";
23372348
std::cout << "global init phase\n";
23382349
#endif
23392350

@@ -2358,6 +2369,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
23582369
// go.
23592370

23602371
#ifdef POSSIBLE_CONTENTS_DEBUG
2372+
std::cout << "... " << timer.lastElapsed() << "\n";
23612373
std::cout << "merging+indexing phase\n";
23622374
#endif
23632375

@@ -2402,6 +2414,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
24022414
analysis.map.clear();
24032415

24042416
#ifdef POSSIBLE_CONTENTS_DEBUG
2417+
std::cout << "... " << timer.lastElapsed() << "\n";
24052418
std::cout << "external phase\n";
24062419
#endif
24072420

@@ -2494,6 +2507,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
24942507
}
24952508

24962509
#ifdef POSSIBLE_CONTENTS_DEBUG
2510+
std::cout << "... " << timer.lastElapsed() << "\n";
24972511
std::cout << "function subtyping phase\n";
24982512
#endif
24992513

@@ -2519,6 +2533,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
25192533
}
25202534

25212535
#ifdef POSSIBLE_CONTENTS_DEBUG
2536+
std::cout << "... " << timer.lastElapsed() << "\n";
25222537
std::cout << "Link-targets phase\n";
25232538
#endif
25242539

@@ -2537,6 +2552,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
25372552
#endif
25382553

25392554
#ifdef POSSIBLE_CONTENTS_DEBUG
2555+
std::cout << "... " << timer.lastElapsed() << "\n";
25402556
std::cout << "roots phase\n";
25412557
#endif
25422558

@@ -2554,6 +2570,7 @@ Flower::Flower(Module& wasm, const PassOptions& options)
25542570
}
25552571

25562572
#ifdef POSSIBLE_CONTENTS_DEBUG
2573+
std::cout << "... " << timer.lastElapsed() << "\n";
25572574
std::cout << "flow phase\n";
25582575
size_t iters = 0;
25592576
#endif
@@ -2574,6 +2591,10 @@ Flower::Flower(Module& wasm, const PassOptions& options)
25742591
flowAfterUpdate(locationIndex);
25752592
}
25762593

2594+
#ifdef POSSIBLE_CONTENTS_DEBUG
2595+
std::cout << "... " << timer.lastElapsed() << "\n";
2596+
#endif
2597+
25772598
// TODO: Add analysis and retrieval logic for fields of immutable globals,
25782599
// including multiple levels of depth (necessary for itables in j2wasm).
25792600
}

src/support/timing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Timer {
3131
public:
3232
Timer() { restart(); }
3333

34-
// Resets the timer's start time and returns the time since its last start.
34+
// Resets the timer's start and last times.
3535
void restart() {
3636
auto now = std::chrono::steady_clock::now();
3737
lastTime = startTime = now;

0 commit comments

Comments
 (0)