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 77926 : void setValueLoad(MacroAssembler &masm, Label fastPathRejoin, Label fastValueLoad) {
62 77926 : int offset = masm.differenceBetween(fastPathRejoin, fastValueLoad);
63 77926 : inlineValueLoadOffset = offset;
64 :
65 : /*
66 : * Note: the offset between the type and data loads for x86 is asserted
67 : * in NunboxAssembler::loadValueWithAddressOffsetPatch.
68 : */
69 77926 : JS_ASSERT(offset == inlineValueLoadOffset);
70 : (void) offset;
71 77926 : }
72 :
73 14097 : CodeLocationLabel getValueLoad(CodeLocationLabel fastPathRejoin) {
74 14097 : return fastPathRejoin.labelAtOffset(inlineValueLoadOffset);
75 : }
76 :
77 77926 : void setDslotsLoad(MacroAssembler &masm, Label fastPathRejoin, Label dslotsLoad) {
78 77926 : int offset = masm.differenceBetween(fastPathRejoin, dslotsLoad);
79 77926 : setDslotsLoadOffset(offset);
80 77926 : }
81 :
82 8908 : CodeLocationInstruction getDslotsLoad(CodeLocationLabel fastPathRejoin) {
83 8908 : return fastPathRejoin.instructionAtOffset(getDslotsLoadOffset());
84 : }
85 :
86 77926 : void setInlineShapeData(MacroAssembler &masm, Label shapeGuard, DataLabelPtr inlineShape) {
87 77926 : int offset = masm.differenceBetween(shapeGuard, inlineShape);
88 77926 : setInlineShapeOffset(offset);
89 77926 : }
90 :
91 14097 : CodeLocationDataLabelPtr getInlineShapeData(CodeLocationLabel fastShapeGuard) {
92 14097 : 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 77926 : void setInlineShapeJump(MacroAssembler &masm, T base, Label afterJump) {
101 77926 : setInlineShapeJumpOffset(masm.differenceBetween(base, afterJump));
102 77926 : }
103 :
104 : CodeLocationJump getInlineShapeJump(CodeLocationLabel fastShapeGuard) {
105 : return fastShapeGuard.jumpAtOffset(getInlineShapeJumpOffset());
106 : }
107 :
108 51133 : void setInlineTypeJump(MacroAssembler &masm, Label fastPathStart, Label afterTypeJump) {
109 51133 : int offset = masm.differenceBetween(fastPathStart, afterTypeJump);
110 51133 : setInlineTypeJumpOffset(offset);
111 51133 : }
112 :
113 951 : CodeLocationJump getInlineTypeJump(CodeLocationLabel fastPathStart) {
114 951 : return fastPathStart.jumpAtOffset(getInlineTypeJumpOffset());
115 : }
116 :
117 7821 : void setStubShapeJump(MacroAssembler &masm, Label stubStart, Label shapeJump) {
118 7821 : int offset = masm.differenceBetween(stubStart, shapeJump);
119 7821 : setStubShapeJumpOffset(offset);
120 7821 : }
121 :
122 : /* Offset-based interface */
123 :
124 77926 : void setDslotsLoadOffset(int offset) {
125 77926 : dslotsLoadOffset = offset;
126 77926 : JS_ASSERT(offset == dslotsLoadOffset);
127 77926 : }
128 :
129 77926 : void setInlineShapeOffset(int offset) {
130 77926 : inlineShapeOffset = offset;
131 77926 : JS_ASSERT(offset == inlineShapeOffset);
132 77926 : }
133 :
134 7821 : void setStubShapeJumpOffset(int offset) {
135 7821 : stubShapeJumpOffset = offset;
136 7821 : JS_ASSERT(offset == stubShapeJumpOffset);
137 7821 : }
138 :
139 12949 : int getInlineShapeJumpOffset() {
140 12949 : return POST_INST_OFFSET(inlineShapeJumpOffset);
141 : }
142 :
143 77926 : void setInlineShapeJumpOffset(int offset) {
144 77926 : inlineShapeJumpOffset = offset;
145 77926 : JS_ASSERT(offset == inlineShapeJumpOffset);
146 77926 : }
147 :
148 951 : int getInlineTypeJumpOffset() {
149 951 : return POST_INST_OFFSET(inlineTypeJumpOffset);
150 : }
151 :
152 51133 : void setInlineTypeJumpOffset(int offset) {
153 51133 : inlineTypeJumpOffset = offset;
154 51133 : JS_ASSERT(offset == inlineTypeJumpOffset);
155 51133 : }
156 :
157 14097 : int getInlineShapeOffset() {
158 14097 : return inlineShapeOffset;
159 : }
160 8908 : int getDslotsLoadOffset() {
161 8908 : return dslotsLoadOffset;
162 : }
163 1900 : int getStubShapeJumpOffset() {
164 1900 : 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 15850 : void setInlineValueStore(MacroAssembler &masm, Label fastPathRejoin, DataLabel32 inlineValueStore) {
196 15850 : int offset = masm.differenceBetween(fastPathRejoin, inlineValueStore);
197 15850 : setInlineValueStoreOffset(offset);
198 15850 : }
199 :
200 1485 : CodeLocationLabel getInlineValueStore(CodeLocationLabel fastPathRejoin) {
201 1485 : return fastPathRejoin.labelAtOffset(getInlineValueStoreOffset());
202 : }
203 :
204 15850 : void setInlineShapeData(MacroAssembler &masm, Label shapeGuard, DataLabelPtr inlineShapeData) {
205 15850 : int offset = masm.differenceBetween(shapeGuard, inlineShapeData);
206 15850 : setInlineShapeDataOffset(offset);
207 15850 : }
208 :
209 1485 : CodeLocationDataLabelPtr getInlineShapeData(CodeLocationLabel fastPathStart, int shapeGuardOffset) {
210 1485 : return fastPathStart.dataLabelPtrAtOffset(shapeGuardOffset + getInlineShapeDataOffset());
211 : }
212 :
213 15850 : void setDslotsLoad(MacroAssembler &masm, Label fastPathRejoin, Label beforeLoad) {
214 15850 : int offset = masm.differenceBetween(fastPathRejoin, beforeLoad);
215 15850 : setDslotsLoadOffset(offset);
216 15850 : }
217 :
218 1069 : CodeLocationInstruction getDslotsLoad(CodeLocationLabel fastPathRejoin, const ValueRemat &vr) {
219 1069 : return fastPathRejoin.instructionAtOffset(getDslotsLoadOffset(vr));
220 : }
221 :
222 15850 : void setInlineShapeJump(MacroAssembler &masm, Label shapeGuard, Label afterJump) {
223 15850 : setInlineShapeJumpOffset(masm.differenceBetween(shapeGuard, afterJump));
224 15850 : }
225 :
226 2083 : CodeLocationJump getInlineShapeJump(CodeLocationLabel shapeGuard) {
227 2083 : return shapeGuard.jumpAtOffset(getInlineShapeJumpOffset());
228 : }
229 :
230 2582 : void setStubShapeJump(MacroAssembler &masm, Label stubStart, Label afterShapeJump) {
231 2582 : int offset = masm.differenceBetween(stubStart, afterShapeJump);
232 2582 : setStubShapeJumpOffset(offset);
233 2582 : }
234 :
235 499 : CodeLocationJump getStubShapeJump(CodeLocationLabel stubStart) {
236 499 : return stubStart.jumpAtOffset(getStubShapeJumpOffset());
237 : }
238 :
239 : private:
240 :
241 : /* Offset-based interface. */
242 :
243 15850 : void setDslotsLoadOffset(int offset) {
244 15850 : dslotsLoadOffset = offset;
245 15850 : JS_ASSERT(offset == dslotsLoadOffset);
246 15850 : }
247 :
248 1069 : int getDslotsLoadOffset(const ValueRemat &vr) {
249 : (void) vr;
250 1069 : return dslotsLoadOffset;
251 : }
252 :
253 15850 : void setInlineShapeDataOffset(int offset) {
254 15850 : inlineShapeDataOffset = offset;
255 15850 : JS_ASSERT(offset == inlineShapeDataOffset);
256 15850 : }
257 :
258 2582 : void setStubShapeJumpOffset(int offset) {
259 2582 : stubShapeJumpOffset = offset;
260 2582 : JS_ASSERT(offset == stubShapeJumpOffset);
261 2582 : }
262 :
263 15850 : void setInlineValueStoreOffset(int offset) {
264 15850 : inlineValueStoreOffset = offset;
265 15850 : JS_ASSERT(offset == inlineValueStoreOffset);
266 15850 : }
267 :
268 15850 : void setInlineShapeJumpOffset(int offset) {
269 15850 : inlineShapeJumpOffset = offset;
270 15850 : JS_ASSERT(offset == inlineShapeJumpOffset);
271 15850 : }
272 :
273 2083 : int getInlineShapeJumpOffset() {
274 2083 : return POST_INST_OFFSET(inlineShapeJumpOffset);
275 : }
276 :
277 1485 : int getInlineShapeDataOffset() {
278 1485 : return inlineShapeDataOffset;
279 : }
280 :
281 499 : int getStubShapeJumpOffset() {
282 499 : return POST_INST_OFFSET(stubShapeJumpOffset);
283 : }
284 :
285 1485 : int getInlineValueStoreOffset() {
286 1485 : 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 3075 : void setInlineJumpOffset(int offset) {
313 3075 : inlineJumpOffset = offset;
314 3075 : JS_ASSERT(offset == inlineJumpOffset);
315 3075 : }
316 :
317 3075 : void setInlineJump(MacroAssembler &masm, Label shapeGuard, Jump inlineJump) {
318 3075 : int offset = masm.differenceBetween(shapeGuard, inlineJump);
319 3075 : setInlineJumpOffset(offset);
320 3075 : }
321 :
322 557 : CodeLocationJump getInlineJump(CodeLocationLabel fastPathStart) {
323 557 : return fastPathStart.jumpAtOffset(getInlineJumpOffset());
324 : }
325 :
326 557 : int getInlineJumpOffset() {
327 557 : return inlineJumpOffset;
328 : }
329 :
330 565 : void setStubJumpOffset(int offset) {
331 565 : stubJumpOffset = offset;
332 565 : JS_ASSERT(offset == stubJumpOffset);
333 565 : }
334 :
335 565 : void setStubJump(MacroAssembler &masm, Label stubStart, Jump stubJump) {
336 565 : int offset = masm.differenceBetween(stubStart, stubJump);
337 565 : setStubJumpOffset(offset);
338 565 : }
339 :
340 8 : CodeLocationJump getStubJump(CodeLocationLabel lastStubStart) {
341 8 : return lastStubStart.jumpAtOffset(getStubJumpOffset());
342 : }
343 :
344 8 : int getStubJumpOffset() {
345 8 : 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 32520 : void setInlineJumpOffset(int offset) {
361 32520 : inlineJumpOffset = offset;
362 32520 : JS_ASSERT(offset == inlineJumpOffset);
363 32520 : }
364 :
365 32263 : void setInlineJump(MacroAssembler &masm, Label fastPathStart, Jump inlineJump) {
366 32263 : int offset = masm.differenceBetween(fastPathStart, inlineJump);
367 32263 : setInlineJumpOffset(offset);
368 32263 : }
369 :
370 21333 : CodeLocationJump getInlineJump(CodeLocationLabel fastPathStart) {
371 21333 : return fastPathStart.jumpAtOffset(getInlineJumpOffset());
372 : }
373 :
374 21333 : int getInlineJumpOffset() {
375 21333 : return inlineJumpOffset;
376 : }
377 :
378 22022 : void setStubJumpOffset(int offset) {
379 22022 : stubJumpOffset = offset;
380 22022 : JS_ASSERT(offset == stubJumpOffset);
381 22022 : }
382 :
383 22022 : void setStubJump(MacroAssembler &masm, Label stubStart, Jump stubJump) {
384 22022 : int offset = masm.differenceBetween(stubStart, stubJump);
385 22022 : setStubJumpOffset(offset);
386 22022 : }
387 :
388 689 : CodeLocationJump getStubJump(CodeLocationLabel lastStubStart) {
389 689 : return lastStubStart.jumpAtOffset(getStubJumpOffset());
390 : }
391 :
392 689 : int getStubJumpOffset() {
393 689 : 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__ */
|