|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
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 #ifndef jit_BaselineInspector_h |
|
8 #define jit_BaselineInspector_h |
|
9 |
|
10 #ifdef JS_ION |
|
11 |
|
12 #include "jit/BaselineIC.h" |
|
13 #include "jit/BaselineJIT.h" |
|
14 #include "jit/MIR.h" |
|
15 |
|
16 namespace js { |
|
17 namespace jit { |
|
18 |
|
19 class BaselineInspector; |
|
20 |
|
21 class ICInspector |
|
22 { |
|
23 protected: |
|
24 BaselineInspector *inspector_; |
|
25 jsbytecode *pc_; |
|
26 ICEntry *icEntry_; |
|
27 |
|
28 ICInspector(BaselineInspector *inspector, jsbytecode *pc, ICEntry *icEntry) |
|
29 : inspector_(inspector), pc_(pc), icEntry_(icEntry) |
|
30 { } |
|
31 }; |
|
32 |
|
33 class SetElemICInspector : public ICInspector |
|
34 { |
|
35 public: |
|
36 SetElemICInspector(BaselineInspector *inspector, jsbytecode *pc, ICEntry *icEntry) |
|
37 : ICInspector(inspector, pc, icEntry) |
|
38 { } |
|
39 |
|
40 bool sawOOBDenseWrite() const; |
|
41 bool sawOOBTypedArrayWrite() const; |
|
42 bool sawDenseWrite() const; |
|
43 bool sawTypedArrayWrite() const; |
|
44 }; |
|
45 |
|
46 class BaselineInspector |
|
47 { |
|
48 private: |
|
49 JSScript *script; |
|
50 ICEntry *prevLookedUpEntry; |
|
51 |
|
52 public: |
|
53 BaselineInspector(JSScript *script) |
|
54 : script(script), prevLookedUpEntry(nullptr) |
|
55 { |
|
56 JS_ASSERT(script); |
|
57 } |
|
58 |
|
59 bool hasBaselineScript() const { |
|
60 return script->hasBaselineScript(); |
|
61 } |
|
62 |
|
63 BaselineScript *baselineScript() const { |
|
64 return script->baselineScript(); |
|
65 } |
|
66 |
|
67 private: |
|
68 #ifdef DEBUG |
|
69 bool isValidPC(jsbytecode *pc) { |
|
70 return script->containsPC(pc); |
|
71 } |
|
72 #endif |
|
73 |
|
74 ICEntry &icEntryFromPC(jsbytecode *pc) { |
|
75 JS_ASSERT(hasBaselineScript()); |
|
76 JS_ASSERT(isValidPC(pc)); |
|
77 ICEntry &ent = baselineScript()->icEntryFromPCOffset(script->pcToOffset(pc), prevLookedUpEntry); |
|
78 JS_ASSERT(ent.isForOp()); |
|
79 prevLookedUpEntry = &ent; |
|
80 return ent; |
|
81 } |
|
82 |
|
83 template <typename ICInspectorType> |
|
84 ICInspectorType makeICInspector(jsbytecode *pc, ICStub::Kind expectedFallbackKind) { |
|
85 ICEntry *ent = nullptr; |
|
86 if (hasBaselineScript()) { |
|
87 ent = &icEntryFromPC(pc); |
|
88 JS_ASSERT(ent->fallbackStub()->kind() == expectedFallbackKind); |
|
89 } |
|
90 return ICInspectorType(this, pc, ent); |
|
91 } |
|
92 |
|
93 ICStub *monomorphicStub(jsbytecode *pc); |
|
94 bool dimorphicStub(jsbytecode *pc, ICStub **pfirst, ICStub **psecond); |
|
95 |
|
96 public: |
|
97 typedef Vector<Shape *, 4, IonAllocPolicy> ShapeVector; |
|
98 bool maybeShapesForPropertyOp(jsbytecode *pc, ShapeVector &shapes); |
|
99 |
|
100 SetElemICInspector setElemICInspector(jsbytecode *pc) { |
|
101 return makeICInspector<SetElemICInspector>(pc, ICStub::SetElem_Fallback); |
|
102 } |
|
103 |
|
104 MIRType expectedResultType(jsbytecode *pc); |
|
105 MCompare::CompareType expectedCompareType(jsbytecode *pc); |
|
106 MIRType expectedBinaryArithSpecialization(jsbytecode *pc); |
|
107 |
|
108 bool hasSeenNonNativeGetElement(jsbytecode *pc); |
|
109 bool hasSeenNegativeIndexGetElement(jsbytecode *pc); |
|
110 bool hasSeenAccessedGetter(jsbytecode *pc); |
|
111 bool hasSeenDoubleResult(jsbytecode *pc); |
|
112 bool hasSeenNonStringIterNext(jsbytecode *pc); |
|
113 |
|
114 JSObject *getTemplateObject(jsbytecode *pc); |
|
115 JSObject *getTemplateObjectForNative(jsbytecode *pc, Native native); |
|
116 |
|
117 DeclEnvObject *templateDeclEnvObject(); |
|
118 CallObject *templateCallObject(); |
|
119 |
|
120 JSObject *commonGetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonGetter); |
|
121 JSObject *commonSetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonSetter); |
|
122 }; |
|
123 |
|
124 } // namespace jit |
|
125 } // namespace js |
|
126 |
|
127 #endif // JS_ION |
|
128 |
|
129 #endif /* jit_BaselineInspector_h */ |