Bug 1890689 apply drift correction to input rate instead of output rate r=pehrsons
[gecko.git] / js / public / JitCodeAPI.h
blobe1cdad20836846db6aebc1d5b1827e752de65e35
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* SpiderMonkey API for obtaining JitCode information. */
8 #ifndef js_JitCodeAPI_h
9 #define js_JitCodeAPI_h
11 #include "js/AllocPolicy.h"
12 #include "js/ColumnNumber.h" // JS::LimitedColumnNumberOneOrigin
13 #include "js/Initialization.h"
14 #include "js/Printf.h"
15 #include "js/Vector.h"
17 namespace JS {
19 enum class JitTier { Baseline, IC, Ion, Other };
21 class JitOpcodeDictionary {
22 typedef js::Vector<UniqueChars, 0, js::SystemAllocPolicy> StringVector;
24 public:
25 JitOpcodeDictionary();
27 StringVector& GetBaselineDictionary() { return baselineDictionary; }
28 StringVector& GetIonDictionary() { return ionDictionary; }
29 StringVector& GetInlineCacheDictionary() { return icDictionary; }
31 private:
32 StringVector baselineDictionary;
33 StringVector icDictionary;
34 StringVector ionDictionary;
37 struct JitCodeSourceInfo {
38 UniqueChars filename;
39 uint32_t offset = 0;
41 // Line number (1-origin).
42 uint32_t lineno = 0;
43 // Column number in UTF-16 code units.
44 JS::LimitedColumnNumberOneOrigin colno;
47 struct JitCodeIRInfo {
48 uint32_t offset = 0;
49 uint32_t opcode = 0;
50 UniqueChars str;
53 typedef js::Vector<JitCodeSourceInfo, 0, js::SystemAllocPolicy>
54 SourceInfoVector;
55 typedef js::Vector<JitCodeIRInfo, 0, js::SystemAllocPolicy> IRInfoVector;
57 struct JitCodeRecord {
58 UniqueChars functionName;
59 uint64_t code_addr = 0;
60 uint32_t instructionSize = 0;
61 JitTier tier = JitTier::Other;
63 SourceInfoVector sourceInfo;
64 IRInfoVector irInfo;
67 class JitCodeIterator {
68 void getDataForIndex(size_t iteratorIndex);
70 public:
71 JitCodeIterator();
72 ~JitCodeIterator();
74 void operator++(int) {
75 iteratorIndex++;
76 getDataForIndex(iteratorIndex);
79 explicit operator bool() const { return data != nullptr; }
81 SourceInfoVector& sourceData() { return data->sourceInfo; }
83 IRInfoVector& irData() { return data->irInfo; }
85 const char* functionName() const { return data->functionName.get(); }
86 uint64_t code_addr() const { return data->code_addr; }
87 uint32_t instructionSize() { return data->instructionSize; }
88 JitTier jit_tier() const { return data->tier; }
90 private:
91 JitCodeRecord* data = nullptr;
92 size_t iteratorIndex = 0;
95 } // namespace JS
97 #endif /* js_JitCodeAPI_h */