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"
19 enum class JitTier
{ Baseline
, IC
, Ion
, Other
};
21 class JitOpcodeDictionary
{
22 typedef js::Vector
<UniqueChars
, 0, js::SystemAllocPolicy
> StringVector
;
25 JitOpcodeDictionary();
27 StringVector
& GetBaselineDictionary() { return baselineDictionary
; }
28 StringVector
& GetIonDictionary() { return ionDictionary
; }
29 StringVector
& GetInlineCacheDictionary() { return icDictionary
; }
32 StringVector baselineDictionary
;
33 StringVector icDictionary
;
34 StringVector ionDictionary
;
37 struct JitCodeSourceInfo
{
41 // Line number (1-origin).
43 // Column number in UTF-16 code units.
44 JS::LimitedColumnNumberOneOrigin colno
;
47 struct JitCodeIRInfo
{
53 typedef js::Vector
<JitCodeSourceInfo
, 0, js::SystemAllocPolicy
>
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
;
67 class JitCodeIterator
{
68 void getDataForIndex(size_t iteratorIndex
);
74 void operator++(int) {
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
; }
91 JitCodeRecord
* data
= nullptr;
92 size_t iteratorIndex
= 0;
97 #endif /* js_JitCodeAPI_h */