1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=4 sw=4 et tw=99:
3 : *
4 : * ***** BEGIN LICENSE BLOCK *****
5 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 : *
7 : * The contents of this file are subject to the Mozilla Public License Version
8 : * 1.1 (the "License"); you may not use this file except in compliance with
9 : * the License. You may obtain a copy of the License at
10 : * http://www.mozilla.org/MPL/
11 : *
12 : * Software distributed under the License is distributed on an "AS IS" basis,
13 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 : * for the specific language governing rights and limitations under the
15 : * License.
16 : *
17 : * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
18 : * May 28, 2008.
19 : *
20 : * The Initial Developer of the Original Code is
21 : * Brendan Eich <brendan@mozilla.org>
22 : *
23 : * Contributor(s):
24 : * David Mandelin <dmandelin@mozilla.com>
25 : * David Anderson <danderson@mozilla.com>
26 : * Chris Leary <cdleary@mozilla.com>
27 : * Jacob Bramley <Jacob.Bramely@arm.com>
28 : *
29 : * Alternatively, the contents of this file may be used under the terms of
30 : * either of the GNU General Public License Version 2 or later (the "GPL"),
31 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 : * in which case the provisions of the GPL or the LGPL are applicable instead
33 : * of those above. If you wish to allow use of your version of this file only
34 : * under the terms of either the GPL or the LGPL, and not to allow others to
35 : * use your version of this file under the terms of the MPL, indicate your
36 : * decision by deleting the provisions above and replace them with the notice
37 : * and other provisions required by the GPL or the LGPL. If you do not delete
38 : * the provisions above, a recipient may use your version of this file under
39 : * the terms of any one of the MPL, the GPL or the LGPL.
40 : *
41 : * ***** END LICENSE BLOCK ***** */
42 :
43 : #if !defined jsjaeger_ic_labels_h__ && defined JS_METHODJIT
44 : #define jsjaeger_ic_labels_h__
45 :
46 : #include "methodjit/BaseCompiler.h"
47 :
48 : class ICOffsetInitializer {
49 : public:
50 : ICOffsetInitializer();
51 : };
52 :
53 : namespace js {
54 : namespace mjit {
55 : namespace ic {
56 :
57 : /* GetPropCompiler */
58 : struct GetPropLabels : MacroAssemblerTypedefs {
59 : friend class ::ICOffsetInitializer;
60 :
61 443629 : void setValueLoad(MacroAssembler &masm, Label fastPathRejoin, Label fastValueLoad) {
62 443629 : int offset = masm.differenceBetween(fastPathRejoin, fastValueLoad);
63 443629 : inlineValueLoadOffset = offset;
64 :
65 : /*
66 : * Note: the offset between the type and data loads for x86 is asserted
67 : * in NunboxAssembler::loadValueWithAddressOffsetPatch.
68 : */
69 443629 : JS_ASSERT(offset == inlineValueLoadOffset);
70 : (void) offset;
71 443629 : }
72 :
73 138376 : CodeLocationLabel getValueLoad(CodeLocationLabel fastPathRejoin) {
74 138376 : return fastPathRejoin.labelAtOffset(inlineValueLoadOffset);
75 : }
76 :
77 443629 : void setDslotsLoad(MacroAssembler &masm, Label fastPathRejoin, Label dslotsLoad) {
78 443629 : int offset = masm.differenceBetween(fastPathRejoin, dslotsLoad);
79 443629 : setDslotsLoadOffset(offset);
80 443629 : }
81 :
82 96863 : CodeLocationInstruction getDslotsLoad(CodeLocationLabel fastPathRejoin) {
83 96863 : return fastPathRejoin.instructionAtOffset(getDslotsLoadOffset());
84 : }
85 :
86 443629 : void setInlineShapeData(MacroAssembler &masm, Label shapeGuard, DataLabelPtr inlineShape) {
87 443629 : int offset = masm.differenceBetween(shapeGuard, inlineShape);
88 443629 : setInlineShapeOffset(offset);
89 443629 : }
90 :
91 138376 : CodeLocationDataLabelPtr getInlineShapeData(CodeLocationLabel fastShapeGuard) {
92 138376 : return fastShapeGuard.dataLabelPtrAtOffset(getInlineShapeOffset());
93 : }
94 :
95 : /*
96 : * Note: on x64, the base is the inlineShapeLabel DataLabelPtr, whereas on other
97 : * platforms the base is the shapeGuard.
98 : */
99 : template <typename T>
100 443629 : void setInlineShapeJump(MacroAssembler &masm, T base, Label afterJump) {
101 443629 : setInlineShapeJumpOffset(masm.differenceBetween(base, afterJump));
102 443629 : }
103 :
104 : CodeLocationJump getInlineShapeJump(CodeLocationLabel fastShapeGuard) {
105 : return fastShapeGuard.jumpAtOffset(getInlineShapeJumpOffset());
106 : }
107 :
108 390137 : void setInlineTypeJump(MacroAssembler &masm, Label fastPathStart, Label afterTypeJump) {
109 390137 : int offset = masm.differenceBetween(fastPathStart, afterTypeJump);
110 390137 : setInlineTypeJumpOffset(offset);
111 390137 : }
112 :
113 7670 : CodeLocationJump getInlineTypeJump(CodeLocationLabel fastPathStart) {
114 7670 : return fastPathStart.jumpAtOffset(getInlineTypeJumpOffset());
115 : }
116 :
117 45540 : void setStubShapeJump(MacroAssembler &masm, Label stubStart, Label shapeJump) {
118 45540 : int offset = masm.differenceBetween(stubStart, shapeJump);
119 45540 : setStubShapeJumpOffset(offset);
120 45540 : }
121 :
122 : /* Offset-based interface */
123 :
124 443629 : void setDslotsLoadOffset(int offset) {
125 443629 : dslotsLoadOffset = offset;
126 443629 : JS_ASSERT(offset == dslotsLoadOffset);
127 443629 : }
128 :
129 443629 : void setInlineShapeOffset(int offset) {
130 443629 : inlineShapeOffset = offset;
131 443629 : JS_ASSERT(offset == inlineShapeOffset);
132 443629 : }
133 :
134 45540 : void setStubShapeJumpOffset(int offset) {
135 45540 : stubShapeJumpOffset = offset;
136 45540 : JS_ASSERT(offset == stubShapeJumpOffset);
137 45540 : }
138 :
139 38588 : int getInlineShapeJumpOffset() {
140 38588 : return POST_INST_OFFSET(inlineShapeJumpOffset);
141 : }
142 :
143 443629 : void setInlineShapeJumpOffset(int offset) {
144 443629 : inlineShapeJumpOffset = offset;
145 443629 : JS_ASSERT(offset == inlineShapeJumpOffset);
146 443629 : }
147 :
148 7670 : int getInlineTypeJumpOffset() {
149 7670 : return POST_INST_OFFSET(inlineTypeJumpOffset);
150 : }
151 :
152 390137 : void setInlineTypeJumpOffset(int offset) {
153 390137 : inlineTypeJumpOffset = offset;
154 390137 : JS_ASSERT(offset == inlineTypeJumpOffset);
155 390137 : }
156 :
157 138376 : int getInlineShapeOffset() {
158 138376 : return inlineShapeOffset;
159 : }
160 96863 : int getDslotsLoadOffset() {
161 96863 : return dslotsLoadOffset;
162 : }
163 23138 : int getStubShapeJumpOffset() {
164 23138 : return POST_INST_OFFSET(stubShapeJumpOffset);
165 : }
166 :
167 : private:
168 : /* Offset from storeBack to beginning of 'mov dslots, addr' */
169 : int32_t dslotsLoadOffset : 8;
170 :
171 : /* Offset from shapeGuard to end of shape comparison. */
172 : int32_t inlineShapeOffset : 8;
173 :
174 : /* Offset from storeBack to end of value load. */
175 : int32_t inlineValueLoadOffset : 8;
176 :
177 : /*
178 : * Offset from lastStubStart to end of shape jump.
179 : * TODO: We can redefine the location of lastStubStart to be
180 : * after the jump -- at which point this is always 0.
181 : */
182 : int32_t stubShapeJumpOffset : 8;
183 :
184 : /* Offset from the shape guard start to the shape guard jump. */
185 : int32_t inlineShapeJumpOffset : 8;
186 :
187 : /* Offset from the fast path to the type guard jump. */
188 : int32_t inlineTypeJumpOffset : 8;
189 : };
190 :
191 : /* SetPropCompiler */
192 : struct SetPropLabels : MacroAssemblerTypedefs {
193 : friend class ::ICOffsetInitializer;
194 :
195 33078 : void setInlineValueStore(MacroAssembler &masm, Label fastPathRejoin, DataLabel32 inlineValueStore) {
196 33078 : int offset = masm.differenceBetween(fastPathRejoin, inlineValueStore);
197 33078 : setInlineValueStoreOffset(offset);
198 33078 : }
199 :
200 6029 : CodeLocationLabel getInlineValueStore(CodeLocationLabel fastPathRejoin) {
201 6029 : return fastPathRejoin.labelAtOffset(getInlineValueStoreOffset());
202 : }
203 :
204 33078 : void setInlineShapeData(MacroAssembler &masm, Label shapeGuard, DataLabelPtr inlineShapeData) {
205 33078 : int offset = masm.differenceBetween(shapeGuard, inlineShapeData);
206 33078 : setInlineShapeDataOffset(offset);
207 33078 : }
208 :
209 6029 : CodeLocationDataLabelPtr getInlineShapeData(CodeLocationLabel fastPathStart, int shapeGuardOffset) {
210 6029 : return fastPathStart.dataLabelPtrAtOffset(shapeGuardOffset + getInlineShapeDataOffset());
211 : }
212 :
213 33078 : void setDslotsLoad(MacroAssembler &masm, Label fastPathRejoin, Label beforeLoad) {
214 33078 : int offset = masm.differenceBetween(fastPathRejoin, beforeLoad);
215 33078 : setDslotsLoadOffset(offset);
216 33078 : }
217 :
218 4929 : CodeLocationInstruction getDslotsLoad(CodeLocationLabel fastPathRejoin, const ValueRemat &vr) {
219 4929 : return fastPathRejoin.instructionAtOffset(getDslotsLoadOffset(vr));
220 : }
221 :
222 33078 : void setInlineShapeJump(MacroAssembler &masm, Label shapeGuard, Label afterJump) {
223 33078 : setInlineShapeJumpOffset(masm.differenceBetween(shapeGuard, afterJump));
224 33078 : }
225 :
226 4686 : CodeLocationJump getInlineShapeJump(CodeLocationLabel shapeGuard) {
227 4686 : return shapeGuard.jumpAtOffset(getInlineShapeJumpOffset());
228 : }
229 :
230 5429 : void setStubShapeJump(MacroAssembler &masm, Label stubStart, Label afterShapeJump) {
231 5429 : int offset = masm.differenceBetween(stubStart, afterShapeJump);
232 5429 : setStubShapeJumpOffset(offset);
233 5429 : }
234 :
235 743 : CodeLocationJump getStubShapeJump(CodeLocationLabel stubStart) {
236 743 : return stubStart.jumpAtOffset(getStubShapeJumpOffset());
237 : }
238 :
239 : private:
240 :
241 : /* Offset-based interface. */
242 :
243 33078 : void setDslotsLoadOffset(int offset) {
244 33078 : dslotsLoadOffset = offset;
245 33078 : JS_ASSERT(offset == dslotsLoadOffset);
246 33078 : }
247 :
248 4929 : int getDslotsLoadOffset(const ValueRemat &vr) {
249 : (void) vr;
250 4929 : return dslotsLoadOffset;
251 : }
252 :
253 33078 : void setInlineShapeDataOffset(int offset) {
254 33078 : inlineShapeDataOffset = offset;
255 33078 : JS_ASSERT(offset == inlineShapeDataOffset);
256 33078 : }
257 :
258 5429 : void setStubShapeJumpOffset(int offset) {
259 5429 : stubShapeJumpOffset = offset;
260 5429 : JS_ASSERT(offset == stubShapeJumpOffset);
261 5429 : }
262 :
263 33078 : void setInlineValueStoreOffset(int offset) {
264 33078 : inlineValueStoreOffset = offset;
265 33078 : JS_ASSERT(offset == inlineValueStoreOffset);
266 33078 : }
267 :
268 33078 : void setInlineShapeJumpOffset(int offset) {
269 33078 : inlineShapeJumpOffset = offset;
270 33078 : JS_ASSERT(offset == inlineShapeJumpOffset);
271 33078 : }
272 :
273 4686 : int getInlineShapeJumpOffset() {
274 4686 : return POST_INST_OFFSET(inlineShapeJumpOffset);
275 : }
276 :
277 6029 : int getInlineShapeDataOffset() {
278 6029 : return inlineShapeDataOffset;
279 : }
280 :
281 743 : int getStubShapeJumpOffset() {
282 743 : return POST_INST_OFFSET(stubShapeJumpOffset);
283 : }
284 :
285 6029 : int getInlineValueStoreOffset() {
286 6029 : return inlineValueStoreOffset;
287 : }
288 :
289 : /* Offset from storeBack to beginning of 'mov dslots, addr'. */
290 : int32_t dslotsLoadOffset : 8;
291 :
292 : /* Offset from shapeGuard to end of shape comparison. */
293 : int32_t inlineShapeDataOffset : 8;
294 :
295 : /*
296 : * Offset from lastStubStart to end of shape jump.
297 : * TODO: We can redefine the location of lastStubStart to be
298 : * after the jump -- at which point this is always 0.
299 : */
300 : int32_t stubShapeJumpOffset : 8;
301 :
302 : int32_t inlineValueStoreOffset : 8;
303 :
304 : /* Offset from shapeGuard to the end of the shape jump. */
305 : int32_t inlineShapeJumpOffset : 8;
306 : };
307 :
308 : /* BindNameCompiler */
309 : struct BindNameLabels : MacroAssemblerTypedefs {
310 : friend class ::ICOffsetInitializer;
311 :
312 7111 : void setInlineJumpOffset(int offset) {
313 7111 : inlineJumpOffset = offset;
314 7111 : JS_ASSERT(offset == inlineJumpOffset);
315 7111 : }
316 :
317 7111 : void setInlineJump(MacroAssembler &masm, Label shapeGuard, Jump inlineJump) {
318 7111 : int offset = masm.differenceBetween(shapeGuard, inlineJump);
319 7111 : setInlineJumpOffset(offset);
320 7111 : }
321 :
322 987 : CodeLocationJump getInlineJump(CodeLocationLabel fastPathStart) {
323 987 : return fastPathStart.jumpAtOffset(getInlineJumpOffset());
324 : }
325 :
326 987 : int getInlineJumpOffset() {
327 987 : return inlineJumpOffset;
328 : }
329 :
330 1009 : void setStubJumpOffset(int offset) {
331 1009 : stubJumpOffset = offset;
332 1009 : JS_ASSERT(offset == stubJumpOffset);
333 1009 : }
334 :
335 1009 : void setStubJump(MacroAssembler &masm, Label stubStart, Jump stubJump) {
336 1009 : int offset = masm.differenceBetween(stubStart, stubJump);
337 1009 : setStubJumpOffset(offset);
338 1009 : }
339 :
340 22 : CodeLocationJump getStubJump(CodeLocationLabel lastStubStart) {
341 22 : return lastStubStart.jumpAtOffset(getStubJumpOffset());
342 : }
343 :
344 22 : int getStubJumpOffset() {
345 22 : return stubJumpOffset;
346 : }
347 :
348 : private:
349 : /* Offset from shapeGuard to end of shape jump. */
350 : int32_t inlineJumpOffset : 8;
351 :
352 : /* Offset from lastStubStart to end of the shape jump. */
353 : int32_t stubJumpOffset : 8;
354 : };
355 :
356 : /* ScopeNameCompiler */
357 : struct ScopeNameLabels : MacroAssemblerTypedefs {
358 : friend class ::ICOffsetInitializer;
359 :
360 339417 : void setInlineJumpOffset(int offset) {
361 339417 : inlineJumpOffset = offset;
362 339417 : JS_ASSERT(offset == inlineJumpOffset);
363 339417 : }
364 :
365 339027 : void setInlineJump(MacroAssembler &masm, Label fastPathStart, Jump inlineJump) {
366 339027 : int offset = masm.differenceBetween(fastPathStart, inlineJump);
367 339027 : setInlineJumpOffset(offset);
368 339027 : }
369 :
370 171558 : CodeLocationJump getInlineJump(CodeLocationLabel fastPathStart) {
371 171558 : return fastPathStart.jumpAtOffset(getInlineJumpOffset());
372 : }
373 :
374 171558 : int getInlineJumpOffset() {
375 171558 : return inlineJumpOffset;
376 : }
377 :
378 179814 : void setStubJumpOffset(int offset) {
379 179814 : stubJumpOffset = offset;
380 179814 : JS_ASSERT(offset == stubJumpOffset);
381 179814 : }
382 :
383 179814 : void setStubJump(MacroAssembler &masm, Label stubStart, Jump stubJump) {
384 179814 : int offset = masm.differenceBetween(stubStart, stubJump);
385 179814 : setStubJumpOffset(offset);
386 179814 : }
387 :
388 8256 : CodeLocationJump getStubJump(CodeLocationLabel lastStubStart) {
389 8256 : return lastStubStart.jumpAtOffset(getStubJumpOffset());
390 : }
391 :
392 8256 : int getStubJumpOffset() {
393 8256 : return stubJumpOffset;
394 : }
395 :
396 : private:
397 : /* Offset from fastPathStart to end of shape jump. */
398 : int32_t inlineJumpOffset : 8;
399 :
400 : /* Offset from lastStubStart to end of the shape jump. */
401 : int32_t stubJumpOffset : 8;
402 : };
403 :
404 : } /* namespace ic */
405 : } /* namespace mjit */
406 : } /* namespace js */
407 :
408 : #endif /* jsjaeger_ic_labels_h__ */
|