Merge "Save and re-bind previously bounded texture when using cairo_gl_surface_set_bi...
[framework/web/webkit-efl.git] / Source / JavaScriptCore / assembler / X86Assembler.h
1 /*
2  * Copyright (C) 2008, 2012 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #ifndef X86Assembler_h
27 #define X86Assembler_h
28
29 #if ENABLE(ASSEMBLER) && (CPU(X86) || CPU(X86_64))
30
31 #include "AssemblerBuffer.h"
32 #include "JITCompilationEffort.h"
33 #include <stdint.h>
34 #include <wtf/Assertions.h>
35 #include <wtf/Vector.h>
36
37 namespace JSC {
38
39 inline bool CAN_SIGN_EXTEND_8_32(int32_t value) { return value == (int32_t)(signed char)value; }
40
41 namespace X86Registers {
42     typedef enum {
43         eax,
44         ecx,
45         edx,
46         ebx,
47         esp,
48         ebp,
49         esi,
50         edi,
51
52 #if CPU(X86_64)
53         r8,
54         r9,
55         r10,
56         r11,
57         r12,
58         r13,
59         r14,
60         r15,
61 #endif
62     } RegisterID;
63
64     typedef enum {
65         xmm0,
66         xmm1,
67         xmm2,
68         xmm3,
69         xmm4,
70         xmm5,
71         xmm6,
72         xmm7,
73     } XMMRegisterID;
74 }
75
76 class X86Assembler {
77 public:
78     typedef X86Registers::RegisterID RegisterID;
79     typedef X86Registers::XMMRegisterID XMMRegisterID;
80     typedef XMMRegisterID FPRegisterID;
81
82     typedef enum {
83         ConditionO,
84         ConditionNO,
85         ConditionB,
86         ConditionAE,
87         ConditionE,
88         ConditionNE,
89         ConditionBE,
90         ConditionA,
91         ConditionS,
92         ConditionNS,
93         ConditionP,
94         ConditionNP,
95         ConditionL,
96         ConditionGE,
97         ConditionLE,
98         ConditionG,
99
100         ConditionC  = ConditionB,
101         ConditionNC = ConditionAE,
102     } Condition;
103
104 private:
105     typedef enum {
106         OP_ADD_EvGv                     = 0x01,
107         OP_ADD_GvEv                     = 0x03,
108         OP_OR_EvGv                      = 0x09,
109         OP_OR_GvEv                      = 0x0B,
110         OP_2BYTE_ESCAPE                 = 0x0F,
111         OP_AND_EvGv                     = 0x21,
112         OP_AND_GvEv                     = 0x23,
113         OP_SUB_EvGv                     = 0x29,
114         OP_SUB_GvEv                     = 0x2B,
115         PRE_PREDICT_BRANCH_NOT_TAKEN    = 0x2E,
116         OP_XOR_EvGv                     = 0x31,
117         OP_XOR_GvEv                     = 0x33,
118         OP_CMP_EvGv                     = 0x39,
119         OP_CMP_GvEv                     = 0x3B,
120 #if CPU(X86_64)
121         PRE_REX                         = 0x40,
122 #endif
123         OP_PUSH_EAX                     = 0x50,
124         OP_POP_EAX                      = 0x58,
125 #if CPU(X86_64)
126         OP_MOVSXD_GvEv                  = 0x63,
127 #endif
128         PRE_OPERAND_SIZE                = 0x66,
129         PRE_SSE_66                      = 0x66,
130         OP_PUSH_Iz                      = 0x68,
131         OP_IMUL_GvEvIz                  = 0x69,
132         OP_GROUP1_EbIb                  = 0x80,
133         OP_GROUP1_EvIz                  = 0x81,
134         OP_GROUP1_EvIb                  = 0x83,
135         OP_TEST_EbGb                    = 0x84,
136         OP_TEST_EvGv                    = 0x85,
137         OP_XCHG_EvGv                    = 0x87,
138         OP_MOV_EbGb                     = 0x88,
139         OP_MOV_EvGv                     = 0x89,
140         OP_MOV_GvEv                     = 0x8B,
141         OP_LEA                          = 0x8D,
142         OP_GROUP1A_Ev                   = 0x8F,
143         OP_NOP                          = 0x90,
144         OP_CDQ                          = 0x99,
145         OP_MOV_EAXOv                    = 0xA1,
146         OP_MOV_OvEAX                    = 0xA3,
147         OP_MOV_EAXIv                    = 0xB8,
148         OP_GROUP2_EvIb                  = 0xC1,
149         OP_RET                          = 0xC3,
150         OP_GROUP11_EvIb                 = 0xC6,
151         OP_GROUP11_EvIz                 = 0xC7,
152         OP_INT3                         = 0xCC,
153         OP_GROUP2_Ev1                   = 0xD1,
154         OP_GROUP2_EvCL                  = 0xD3,
155         OP_ESCAPE_DD                    = 0xDD,
156         OP_CALL_rel32                   = 0xE8,
157         OP_JMP_rel32                    = 0xE9,
158         PRE_SSE_F2                      = 0xF2,
159         PRE_SSE_F3                      = 0xF3,
160         OP_HLT                          = 0xF4,
161         OP_GROUP3_EbIb                  = 0xF6,
162         OP_GROUP3_Ev                    = 0xF7,
163         OP_GROUP3_EvIz                  = 0xF7, // OP_GROUP3_Ev has an immediate, when instruction is a test. 
164         OP_GROUP5_Ev                    = 0xFF,
165     } OneByteOpcodeID;
166
167     typedef enum {
168         OP2_MOVSD_VsdWsd    = 0x10,
169         OP2_MOVSD_WsdVsd    = 0x11,
170         OP2_MOVSS_VsdWsd    = 0x10,
171         OP2_MOVSS_WsdVsd    = 0x11,
172         OP2_CVTSI2SD_VsdEd  = 0x2A,
173         OP2_CVTTSD2SI_GdWsd = 0x2C,
174         OP2_UCOMISD_VsdWsd  = 0x2E,
175         OP2_ADDSD_VsdWsd    = 0x58,
176         OP2_MULSD_VsdWsd    = 0x59,
177         OP2_CVTSD2SS_VsdWsd = 0x5A,
178         OP2_CVTSS2SD_VsdWsd = 0x5A,
179         OP2_SUBSD_VsdWsd    = 0x5C,
180         OP2_DIVSD_VsdWsd    = 0x5E,
181         OP2_SQRTSD_VsdWsd   = 0x51,
182         OP2_ANDNPD_VpdWpd   = 0x55,
183         OP2_XORPD_VpdWpd    = 0x57,
184         OP2_MOVD_VdEd       = 0x6E,
185         OP2_MOVD_EdVd       = 0x7E,
186         OP2_JCC_rel32       = 0x80,
187         OP_SETCC            = 0x90,
188         OP2_IMUL_GvEv       = 0xAF,
189         OP2_MOVZX_GvEb      = 0xB6,
190         OP2_MOVSX_GvEb      = 0xBE,
191         OP2_MOVZX_GvEw      = 0xB7,
192         OP2_MOVSX_GvEw      = 0xBF,
193         OP2_PEXTRW_GdUdIb   = 0xC5,
194         OP2_PSLLQ_UdqIb     = 0x73,
195         OP2_PSRLQ_UdqIb     = 0x73,
196         OP2_POR_VdqWdq      = 0XEB,
197     } TwoByteOpcodeID;
198
199     TwoByteOpcodeID jccRel32(Condition cond)
200     {
201         return (TwoByteOpcodeID)(OP2_JCC_rel32 + cond);
202     }
203
204     TwoByteOpcodeID setccOpcode(Condition cond)
205     {
206         return (TwoByteOpcodeID)(OP_SETCC + cond);
207     }
208
209     typedef enum {
210         GROUP1_OP_ADD = 0,
211         GROUP1_OP_OR  = 1,
212         GROUP1_OP_ADC = 2,
213         GROUP1_OP_AND = 4,
214         GROUP1_OP_SUB = 5,
215         GROUP1_OP_XOR = 6,
216         GROUP1_OP_CMP = 7,
217
218         GROUP1A_OP_POP = 0,
219         
220         GROUP2_OP_ROL = 0,
221         GROUP2_OP_ROR = 1,
222         GROUP2_OP_RCL = 2,
223         GROUP2_OP_RCR = 3,
224         
225         GROUP2_OP_SHL = 4,
226         GROUP2_OP_SHR = 5,
227         GROUP2_OP_SAR = 7,
228
229         GROUP3_OP_TEST = 0,
230         GROUP3_OP_NOT  = 2,
231         GROUP3_OP_NEG  = 3,
232         GROUP3_OP_IDIV = 7,
233
234         GROUP5_OP_CALLN = 2,
235         GROUP5_OP_JMPN  = 4,
236         GROUP5_OP_PUSH  = 6,
237
238         GROUP11_MOV = 0,
239
240         GROUP14_OP_PSLLQ = 6,
241         GROUP14_OP_PSRLQ = 2,
242
243         ESCAPE_DD_FSTP_doubleReal = 3,
244     } GroupOpcodeID;
245     
246     class X86InstructionFormatter;
247 public:
248
249     X86Assembler()
250         : m_indexOfLastWatchpoint(INT_MIN)
251         , m_indexOfTailOfLastWatchpoint(INT_MIN)
252     {
253     }
254
255     // Stack operations:
256
257     void push_r(RegisterID reg)
258     {
259         m_formatter.oneByteOp(OP_PUSH_EAX, reg);
260     }
261
262     void pop_r(RegisterID reg)
263     {
264         m_formatter.oneByteOp(OP_POP_EAX, reg);
265     }
266
267     void push_i32(int imm)
268     {
269         m_formatter.oneByteOp(OP_PUSH_Iz);
270         m_formatter.immediate32(imm);
271     }
272
273     void push_m(int offset, RegisterID base)
274     {
275         m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_PUSH, base, offset);
276     }
277
278     void pop_m(int offset, RegisterID base)
279     {
280         m_formatter.oneByteOp(OP_GROUP1A_Ev, GROUP1A_OP_POP, base, offset);
281     }
282
283     // Arithmetic operations:
284
285 #if !CPU(X86_64)
286     void adcl_im(int imm, const void* addr)
287     {
288         if (CAN_SIGN_EXTEND_8_32(imm)) {
289             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADC, addr);
290             m_formatter.immediate8(imm);
291         } else {
292             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADC, addr);
293             m_formatter.immediate32(imm);
294         }
295     }
296 #endif
297
298     void addl_rr(RegisterID src, RegisterID dst)
299     {
300         m_formatter.oneByteOp(OP_ADD_EvGv, src, dst);
301     }
302
303     void addl_mr(int offset, RegisterID base, RegisterID dst)
304     {
305         m_formatter.oneByteOp(OP_ADD_GvEv, dst, base, offset);
306     }
307     
308 #if !CPU(X86_64)
309     void addl_mr(const void* addr, RegisterID dst)
310     {
311         m_formatter.oneByteOp(OP_ADD_GvEv, dst, addr);
312     }
313 #endif
314
315     void addl_rm(RegisterID src, int offset, RegisterID base)
316     {
317         m_formatter.oneByteOp(OP_ADD_EvGv, src, base, offset);
318     }
319
320     void addl_ir(int imm, RegisterID dst)
321     {
322         if (CAN_SIGN_EXTEND_8_32(imm)) {
323             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADD, dst);
324             m_formatter.immediate8(imm);
325         } else {
326             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADD, dst);
327             m_formatter.immediate32(imm);
328         }
329     }
330
331     void addl_im(int imm, int offset, RegisterID base)
332     {
333         if (CAN_SIGN_EXTEND_8_32(imm)) {
334             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADD, base, offset);
335             m_formatter.immediate8(imm);
336         } else {
337             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADD, base, offset);
338             m_formatter.immediate32(imm);
339         }
340     }
341
342 #if CPU(X86_64)
343     void addq_rr(RegisterID src, RegisterID dst)
344     {
345         m_formatter.oneByteOp64(OP_ADD_EvGv, src, dst);
346     }
347
348     void addq_mr(int offset, RegisterID base, RegisterID dst)
349     {
350         m_formatter.oneByteOp64(OP_ADD_GvEv, dst, base, offset);
351     }
352
353     void addq_ir(int imm, RegisterID dst)
354     {
355         if (CAN_SIGN_EXTEND_8_32(imm)) {
356             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_ADD, dst);
357             m_formatter.immediate8(imm);
358         } else {
359             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_ADD, dst);
360             m_formatter.immediate32(imm);
361         }
362     }
363
364     void addq_im(int imm, int offset, RegisterID base)
365     {
366         if (CAN_SIGN_EXTEND_8_32(imm)) {
367             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_ADD, base, offset);
368             m_formatter.immediate8(imm);
369         } else {
370             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_ADD, base, offset);
371             m_formatter.immediate32(imm);
372         }
373     }
374 #else
375     void addl_im(int imm, const void* addr)
376     {
377         if (CAN_SIGN_EXTEND_8_32(imm)) {
378             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_ADD, addr);
379             m_formatter.immediate8(imm);
380         } else {
381             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_ADD, addr);
382             m_formatter.immediate32(imm);
383         }
384     }
385 #endif
386
387     void andl_rr(RegisterID src, RegisterID dst)
388     {
389         m_formatter.oneByteOp(OP_AND_EvGv, src, dst);
390     }
391
392     void andl_mr(int offset, RegisterID base, RegisterID dst)
393     {
394         m_formatter.oneByteOp(OP_AND_GvEv, dst, base, offset);
395     }
396
397     void andl_rm(RegisterID src, int offset, RegisterID base)
398     {
399         m_formatter.oneByteOp(OP_AND_EvGv, src, base, offset);
400     }
401
402     void andl_ir(int imm, RegisterID dst)
403     {
404         if (CAN_SIGN_EXTEND_8_32(imm)) {
405             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_AND, dst);
406             m_formatter.immediate8(imm);
407         } else {
408             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_AND, dst);
409             m_formatter.immediate32(imm);
410         }
411     }
412
413     void andl_im(int imm, int offset, RegisterID base)
414     {
415         if (CAN_SIGN_EXTEND_8_32(imm)) {
416             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_AND, base, offset);
417             m_formatter.immediate8(imm);
418         } else {
419             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_AND, base, offset);
420             m_formatter.immediate32(imm);
421         }
422     }
423
424 #if CPU(X86_64)
425     void andq_rr(RegisterID src, RegisterID dst)
426     {
427         m_formatter.oneByteOp64(OP_AND_EvGv, src, dst);
428     }
429
430     void andq_ir(int imm, RegisterID dst)
431     {
432         if (CAN_SIGN_EXTEND_8_32(imm)) {
433             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_AND, dst);
434             m_formatter.immediate8(imm);
435         } else {
436             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_AND, dst);
437             m_formatter.immediate32(imm);
438         }
439     }
440 #else
441     void andl_im(int imm, const void* addr)
442     {
443         if (CAN_SIGN_EXTEND_8_32(imm)) {
444             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_AND, addr);
445             m_formatter.immediate8(imm);
446         } else {
447             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_AND, addr);
448             m_formatter.immediate32(imm);
449         }
450     }
451 #endif
452
453     void negl_r(RegisterID dst)
454     {
455         m_formatter.oneByteOp(OP_GROUP3_Ev, GROUP3_OP_NEG, dst);
456     }
457
458 #if CPU(X86_64)
459     void negq_r(RegisterID dst)
460     {
461         m_formatter.oneByteOp64(OP_GROUP3_Ev, GROUP3_OP_NEG, dst);
462     }
463 #endif
464
465     void negl_m(int offset, RegisterID base)
466     {
467         m_formatter.oneByteOp(OP_GROUP3_Ev, GROUP3_OP_NEG, base, offset);
468     }
469
470     void notl_r(RegisterID dst)
471     {
472         m_formatter.oneByteOp(OP_GROUP3_Ev, GROUP3_OP_NOT, dst);
473     }
474
475     void notl_m(int offset, RegisterID base)
476     {
477         m_formatter.oneByteOp(OP_GROUP3_Ev, GROUP3_OP_NOT, base, offset);
478     }
479
480     void orl_rr(RegisterID src, RegisterID dst)
481     {
482         m_formatter.oneByteOp(OP_OR_EvGv, src, dst);
483     }
484
485     void orl_mr(int offset, RegisterID base, RegisterID dst)
486     {
487         m_formatter.oneByteOp(OP_OR_GvEv, dst, base, offset);
488     }
489
490     void orl_rm(RegisterID src, int offset, RegisterID base)
491     {
492         m_formatter.oneByteOp(OP_OR_EvGv, src, base, offset);
493     }
494
495     void orl_ir(int imm, RegisterID dst)
496     {
497         if (CAN_SIGN_EXTEND_8_32(imm)) {
498             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_OR, dst);
499             m_formatter.immediate8(imm);
500         } else {
501             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_OR, dst);
502             m_formatter.immediate32(imm);
503         }
504     }
505
506     void orl_im(int imm, int offset, RegisterID base)
507     {
508         if (CAN_SIGN_EXTEND_8_32(imm)) {
509             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_OR, base, offset);
510             m_formatter.immediate8(imm);
511         } else {
512             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_OR, base, offset);
513             m_formatter.immediate32(imm);
514         }
515     }
516
517 #if CPU(X86_64)
518     void orq_rr(RegisterID src, RegisterID dst)
519     {
520         m_formatter.oneByteOp64(OP_OR_EvGv, src, dst);
521     }
522
523     void orq_ir(int imm, RegisterID dst)
524     {
525         if (CAN_SIGN_EXTEND_8_32(imm)) {
526             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_OR, dst);
527             m_formatter.immediate8(imm);
528         } else {
529             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_OR, dst);
530             m_formatter.immediate32(imm);
531         }
532     }
533 #else
534     void orl_im(int imm, const void* addr)
535     {
536         if (CAN_SIGN_EXTEND_8_32(imm)) {
537             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_OR, addr);
538             m_formatter.immediate8(imm);
539         } else {
540             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_OR, addr);
541             m_formatter.immediate32(imm);
542         }
543     }
544 #endif
545
546     void subl_rr(RegisterID src, RegisterID dst)
547     {
548         m_formatter.oneByteOp(OP_SUB_EvGv, src, dst);
549     }
550
551     void subl_mr(int offset, RegisterID base, RegisterID dst)
552     {
553         m_formatter.oneByteOp(OP_SUB_GvEv, dst, base, offset);
554     }
555
556     void subl_rm(RegisterID src, int offset, RegisterID base)
557     {
558         m_formatter.oneByteOp(OP_SUB_EvGv, src, base, offset);
559     }
560
561     void subl_ir(int imm, RegisterID dst)
562     {
563         if (CAN_SIGN_EXTEND_8_32(imm)) {
564             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_SUB, dst);
565             m_formatter.immediate8(imm);
566         } else {
567             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_SUB, dst);
568             m_formatter.immediate32(imm);
569         }
570     }
571     
572     void subl_im(int imm, int offset, RegisterID base)
573     {
574         if (CAN_SIGN_EXTEND_8_32(imm)) {
575             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_SUB, base, offset);
576             m_formatter.immediate8(imm);
577         } else {
578             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_SUB, base, offset);
579             m_formatter.immediate32(imm);
580         }
581     }
582
583 #if CPU(X86_64)
584     void subq_rr(RegisterID src, RegisterID dst)
585     {
586         m_formatter.oneByteOp64(OP_SUB_EvGv, src, dst);
587     }
588
589     void subq_ir(int imm, RegisterID dst)
590     {
591         if (CAN_SIGN_EXTEND_8_32(imm)) {
592             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_SUB, dst);
593             m_formatter.immediate8(imm);
594         } else {
595             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_SUB, dst);
596             m_formatter.immediate32(imm);
597         }
598     }
599 #else
600     void subl_im(int imm, const void* addr)
601     {
602         if (CAN_SIGN_EXTEND_8_32(imm)) {
603             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_SUB, addr);
604             m_formatter.immediate8(imm);
605         } else {
606             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_SUB, addr);
607             m_formatter.immediate32(imm);
608         }
609     }
610 #endif
611
612     void xorl_rr(RegisterID src, RegisterID dst)
613     {
614         m_formatter.oneByteOp(OP_XOR_EvGv, src, dst);
615     }
616
617     void xorl_mr(int offset, RegisterID base, RegisterID dst)
618     {
619         m_formatter.oneByteOp(OP_XOR_GvEv, dst, base, offset);
620     }
621
622     void xorl_rm(RegisterID src, int offset, RegisterID base)
623     {
624         m_formatter.oneByteOp(OP_XOR_EvGv, src, base, offset);
625     }
626
627     void xorl_im(int imm, int offset, RegisterID base)
628     {
629         if (CAN_SIGN_EXTEND_8_32(imm)) {
630             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_XOR, base, offset);
631             m_formatter.immediate8(imm);
632         } else {
633             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_XOR, base, offset);
634             m_formatter.immediate32(imm);
635         }
636     }
637
638     void xorl_ir(int imm, RegisterID dst)
639     {
640         if (CAN_SIGN_EXTEND_8_32(imm)) {
641             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_XOR, dst);
642             m_formatter.immediate8(imm);
643         } else {
644             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_XOR, dst);
645             m_formatter.immediate32(imm);
646         }
647     }
648
649 #if CPU(X86_64)
650     void xorq_rr(RegisterID src, RegisterID dst)
651     {
652         m_formatter.oneByteOp64(OP_XOR_EvGv, src, dst);
653     }
654
655     void xorq_ir(int imm, RegisterID dst)
656     {
657         if (CAN_SIGN_EXTEND_8_32(imm)) {
658             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_XOR, dst);
659             m_formatter.immediate8(imm);
660         } else {
661             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_XOR, dst);
662             m_formatter.immediate32(imm);
663         }
664     }
665     
666     void xorq_rm(RegisterID src, int offset, RegisterID base)
667     {
668         m_formatter.oneByteOp64(OP_XOR_EvGv, src, base, offset);
669     }
670     
671     void rorq_i8r(int imm, RegisterID dst)
672     {
673         if (imm == 1)
674             m_formatter.oneByteOp64(OP_GROUP2_Ev1, GROUP2_OP_ROR, dst);
675         else {
676             m_formatter.oneByteOp64(OP_GROUP2_EvIb, GROUP2_OP_ROR, dst);
677             m_formatter.immediate8(imm);
678         }
679     }
680
681 #endif
682
683     void sarl_i8r(int imm, RegisterID dst)
684     {
685         if (imm == 1)
686             m_formatter.oneByteOp(OP_GROUP2_Ev1, GROUP2_OP_SAR, dst);
687         else {
688             m_formatter.oneByteOp(OP_GROUP2_EvIb, GROUP2_OP_SAR, dst);
689             m_formatter.immediate8(imm);
690         }
691     }
692
693     void sarl_CLr(RegisterID dst)
694     {
695         m_formatter.oneByteOp(OP_GROUP2_EvCL, GROUP2_OP_SAR, dst);
696     }
697     
698     void shrl_i8r(int imm, RegisterID dst)
699     {
700         if (imm == 1)
701             m_formatter.oneByteOp(OP_GROUP2_Ev1, GROUP2_OP_SHR, dst);
702         else {
703             m_formatter.oneByteOp(OP_GROUP2_EvIb, GROUP2_OP_SHR, dst);
704             m_formatter.immediate8(imm);
705         }
706     }
707     
708     void shrl_CLr(RegisterID dst)
709     {
710         m_formatter.oneByteOp(OP_GROUP2_EvCL, GROUP2_OP_SHR, dst);
711     }
712
713     void shll_i8r(int imm, RegisterID dst)
714     {
715         if (imm == 1)
716             m_formatter.oneByteOp(OP_GROUP2_Ev1, GROUP2_OP_SHL, dst);
717         else {
718             m_formatter.oneByteOp(OP_GROUP2_EvIb, GROUP2_OP_SHL, dst);
719             m_formatter.immediate8(imm);
720         }
721     }
722
723     void shll_CLr(RegisterID dst)
724     {
725         m_formatter.oneByteOp(OP_GROUP2_EvCL, GROUP2_OP_SHL, dst);
726     }
727
728 #if CPU(X86_64)
729     void sarq_CLr(RegisterID dst)
730     {
731         m_formatter.oneByteOp64(OP_GROUP2_EvCL, GROUP2_OP_SAR, dst);
732     }
733
734     void sarq_i8r(int imm, RegisterID dst)
735     {
736         if (imm == 1)
737             m_formatter.oneByteOp64(OP_GROUP2_Ev1, GROUP2_OP_SAR, dst);
738         else {
739             m_formatter.oneByteOp64(OP_GROUP2_EvIb, GROUP2_OP_SAR, dst);
740             m_formatter.immediate8(imm);
741         }
742     }
743 #endif
744
745     void imull_rr(RegisterID src, RegisterID dst)
746     {
747         m_formatter.twoByteOp(OP2_IMUL_GvEv, dst, src);
748     }
749
750     void imull_mr(int offset, RegisterID base, RegisterID dst)
751     {
752         m_formatter.twoByteOp(OP2_IMUL_GvEv, dst, base, offset);
753     }
754
755     void imull_i32r(RegisterID src, int32_t value, RegisterID dst)
756     {
757         m_formatter.oneByteOp(OP_IMUL_GvEvIz, dst, src);
758         m_formatter.immediate32(value);
759     }
760
761     void idivl_r(RegisterID dst)
762     {
763         m_formatter.oneByteOp(OP_GROUP3_Ev, GROUP3_OP_IDIV, dst);
764     }
765
766     // Comparisons:
767
768     void cmpl_rr(RegisterID src, RegisterID dst)
769     {
770         m_formatter.oneByteOp(OP_CMP_EvGv, src, dst);
771     }
772
773     void cmpl_rm(RegisterID src, int offset, RegisterID base)
774     {
775         m_formatter.oneByteOp(OP_CMP_EvGv, src, base, offset);
776     }
777
778     void cmpl_mr(int offset, RegisterID base, RegisterID src)
779     {
780         m_formatter.oneByteOp(OP_CMP_GvEv, src, base, offset);
781     }
782
783     void cmpl_ir(int imm, RegisterID dst)
784     {
785         if (CAN_SIGN_EXTEND_8_32(imm)) {
786             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, dst);
787             m_formatter.immediate8(imm);
788         } else {
789             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, dst);
790             m_formatter.immediate32(imm);
791         }
792     }
793
794     void cmpl_ir_force32(int imm, RegisterID dst)
795     {
796         m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, dst);
797         m_formatter.immediate32(imm);
798     }
799     
800     void cmpl_im(int imm, int offset, RegisterID base)
801     {
802         if (CAN_SIGN_EXTEND_8_32(imm)) {
803             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, offset);
804             m_formatter.immediate8(imm);
805         } else {
806             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, offset);
807             m_formatter.immediate32(imm);
808         }
809     }
810     
811     void cmpb_im(int imm, int offset, RegisterID base)
812     {
813         m_formatter.oneByteOp(OP_GROUP1_EbIb, GROUP1_OP_CMP, base, offset);
814         m_formatter.immediate8(imm);
815     }
816     
817     void cmpb_im(int imm, int offset, RegisterID base, RegisterID index, int scale)
818     {
819         m_formatter.oneByteOp(OP_GROUP1_EbIb, GROUP1_OP_CMP, base, index, scale, offset);
820         m_formatter.immediate8(imm);
821     }
822     
823 #if CPU(X86)
824     void cmpb_im(int imm, const void* addr)
825     {
826         m_formatter.oneByteOp(OP_GROUP1_EbIb, GROUP1_OP_CMP, addr);
827         m_formatter.immediate8(imm);
828     }
829 #endif
830
831     void cmpl_im(int imm, int offset, RegisterID base, RegisterID index, int scale)
832     {
833         if (CAN_SIGN_EXTEND_8_32(imm)) {
834             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, index, scale, offset);
835             m_formatter.immediate8(imm);
836         } else {
837             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, index, scale, offset);
838             m_formatter.immediate32(imm);
839         }
840     }
841
842     void cmpl_im_force32(int imm, int offset, RegisterID base)
843     {
844         m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, offset);
845         m_formatter.immediate32(imm);
846     }
847
848 #if CPU(X86_64)
849     void cmpq_rr(RegisterID src, RegisterID dst)
850     {
851         m_formatter.oneByteOp64(OP_CMP_EvGv, src, dst);
852     }
853
854     void cmpq_rm(RegisterID src, int offset, RegisterID base)
855     {
856         m_formatter.oneByteOp64(OP_CMP_EvGv, src, base, offset);
857     }
858
859     void cmpq_mr(int offset, RegisterID base, RegisterID src)
860     {
861         m_formatter.oneByteOp64(OP_CMP_GvEv, src, base, offset);
862     }
863
864     void cmpq_ir(int imm, RegisterID dst)
865     {
866         if (CAN_SIGN_EXTEND_8_32(imm)) {
867             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_CMP, dst);
868             m_formatter.immediate8(imm);
869         } else {
870             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_CMP, dst);
871             m_formatter.immediate32(imm);
872         }
873     }
874
875     void cmpq_im(int imm, int offset, RegisterID base)
876     {
877         if (CAN_SIGN_EXTEND_8_32(imm)) {
878             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, offset);
879             m_formatter.immediate8(imm);
880         } else {
881             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, offset);
882             m_formatter.immediate32(imm);
883         }
884     }
885
886     void cmpq_im(int imm, int offset, RegisterID base, RegisterID index, int scale)
887     {
888         if (CAN_SIGN_EXTEND_8_32(imm)) {
889             m_formatter.oneByteOp64(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, index, scale, offset);
890             m_formatter.immediate8(imm);
891         } else {
892             m_formatter.oneByteOp64(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, index, scale, offset);
893             m_formatter.immediate32(imm);
894         }
895     }
896 #else
897     void cmpl_rm(RegisterID reg, const void* addr)
898     {
899         m_formatter.oneByteOp(OP_CMP_EvGv, reg, addr);
900     }
901
902     void cmpl_im(int imm, const void* addr)
903     {
904         if (CAN_SIGN_EXTEND_8_32(imm)) {
905             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, addr);
906             m_formatter.immediate8(imm);
907         } else {
908             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, addr);
909             m_formatter.immediate32(imm);
910         }
911     }
912 #endif
913
914     void cmpw_ir(int imm, RegisterID dst)
915     {
916         if (CAN_SIGN_EXTEND_8_32(imm)) {
917             m_formatter.prefix(PRE_OPERAND_SIZE);
918             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, dst);
919             m_formatter.immediate8(imm);
920         } else {
921             m_formatter.prefix(PRE_OPERAND_SIZE);
922             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, dst);
923             m_formatter.immediate16(imm);
924         }
925     }
926
927     void cmpw_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale)
928     {
929         m_formatter.prefix(PRE_OPERAND_SIZE);
930         m_formatter.oneByteOp(OP_CMP_EvGv, src, base, index, scale, offset);
931     }
932
933     void cmpw_im(int imm, int offset, RegisterID base, RegisterID index, int scale)
934     {
935         if (CAN_SIGN_EXTEND_8_32(imm)) {
936             m_formatter.prefix(PRE_OPERAND_SIZE);
937             m_formatter.oneByteOp(OP_GROUP1_EvIb, GROUP1_OP_CMP, base, index, scale, offset);
938             m_formatter.immediate8(imm);
939         } else {
940             m_formatter.prefix(PRE_OPERAND_SIZE);
941             m_formatter.oneByteOp(OP_GROUP1_EvIz, GROUP1_OP_CMP, base, index, scale, offset);
942             m_formatter.immediate16(imm);
943         }
944     }
945
946     void testl_rr(RegisterID src, RegisterID dst)
947     {
948         m_formatter.oneByteOp(OP_TEST_EvGv, src, dst);
949     }
950     
951     void testl_i32r(int imm, RegisterID dst)
952     {
953         m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst);
954         m_formatter.immediate32(imm);
955     }
956
957     void testl_i32m(int imm, int offset, RegisterID base)
958     {
959         m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, offset);
960         m_formatter.immediate32(imm);
961     }
962
963     void testb_rr(RegisterID src, RegisterID dst)
964     {
965         m_formatter.oneByteOp8(OP_TEST_EbGb, src, dst);
966     }
967
968     void testb_im(int imm, int offset, RegisterID base)
969     {
970         m_formatter.oneByteOp(OP_GROUP3_EbIb, GROUP3_OP_TEST, base, offset);
971         m_formatter.immediate8(imm);
972     }
973     
974     void testb_im(int imm, int offset, RegisterID base, RegisterID index, int scale)
975     {
976         m_formatter.oneByteOp(OP_GROUP3_EbIb, GROUP3_OP_TEST, base, index, scale, offset);
977         m_formatter.immediate8(imm);
978     }
979
980 #if CPU(X86)
981     void testb_im(int imm, const void* addr)
982     {
983         m_formatter.oneByteOp(OP_GROUP3_EbIb, GROUP3_OP_TEST, addr);
984         m_formatter.immediate8(imm);
985     }
986 #endif
987
988     void testl_i32m(int imm, int offset, RegisterID base, RegisterID index, int scale)
989     {
990         m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, index, scale, offset);
991         m_formatter.immediate32(imm);
992     }
993
994 #if CPU(X86_64)
995     void testq_rr(RegisterID src, RegisterID dst)
996     {
997         m_formatter.oneByteOp64(OP_TEST_EvGv, src, dst);
998     }
999
1000     void testq_rm(RegisterID src, int offset, RegisterID base)
1001     {
1002         m_formatter.oneByteOp64(OP_TEST_EvGv, src, base, offset);
1003     }
1004
1005     void testq_i32r(int imm, RegisterID dst)
1006     {
1007         m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst);
1008         m_formatter.immediate32(imm);
1009     }
1010
1011     void testq_i32m(int imm, int offset, RegisterID base)
1012     {
1013         m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, offset);
1014         m_formatter.immediate32(imm);
1015     }
1016
1017     void testq_i32m(int imm, int offset, RegisterID base, RegisterID index, int scale)
1018     {
1019         m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, index, scale, offset);
1020         m_formatter.immediate32(imm);
1021     }
1022 #endif 
1023
1024     void testw_rr(RegisterID src, RegisterID dst)
1025     {
1026         m_formatter.prefix(PRE_OPERAND_SIZE);
1027         m_formatter.oneByteOp(OP_TEST_EvGv, src, dst);
1028     }
1029     
1030     void testb_i8r(int imm, RegisterID dst)
1031     {
1032         m_formatter.oneByteOp8(OP_GROUP3_EbIb, GROUP3_OP_TEST, dst);
1033         m_formatter.immediate8(imm);
1034     }
1035
1036     void setCC_r(Condition cond, RegisterID dst)
1037     {
1038         m_formatter.twoByteOp8(setccOpcode(cond), (GroupOpcodeID)0, dst);
1039     }
1040
1041     void sete_r(RegisterID dst)
1042     {
1043         m_formatter.twoByteOp8(setccOpcode(ConditionE), (GroupOpcodeID)0, dst);
1044     }
1045
1046     void setz_r(RegisterID dst)
1047     {
1048         sete_r(dst);
1049     }
1050
1051     void setne_r(RegisterID dst)
1052     {
1053         m_formatter.twoByteOp8(setccOpcode(ConditionNE), (GroupOpcodeID)0, dst);
1054     }
1055
1056     void setnz_r(RegisterID dst)
1057     {
1058         setne_r(dst);
1059     }
1060
1061     // Various move ops:
1062
1063     void cdq()
1064     {
1065         m_formatter.oneByteOp(OP_CDQ);
1066     }
1067
1068     void fstpl(int offset, RegisterID base)
1069     {
1070         m_formatter.oneByteOp(OP_ESCAPE_DD, ESCAPE_DD_FSTP_doubleReal, base, offset);
1071     }
1072
1073     void xchgl_rr(RegisterID src, RegisterID dst)
1074     {
1075         m_formatter.oneByteOp(OP_XCHG_EvGv, src, dst);
1076     }
1077
1078 #if CPU(X86_64)
1079     void xchgq_rr(RegisterID src, RegisterID dst)
1080     {
1081         m_formatter.oneByteOp64(OP_XCHG_EvGv, src, dst);
1082     }
1083 #endif
1084
1085     void movl_rr(RegisterID src, RegisterID dst)
1086     {
1087         m_formatter.oneByteOp(OP_MOV_EvGv, src, dst);
1088     }
1089     
1090     void movl_rm(RegisterID src, int offset, RegisterID base)
1091     {
1092         m_formatter.oneByteOp(OP_MOV_EvGv, src, base, offset);
1093     }
1094
1095     void movl_rm_disp32(RegisterID src, int offset, RegisterID base)
1096     {
1097         m_formatter.oneByteOp_disp32(OP_MOV_EvGv, src, base, offset);
1098     }
1099
1100     void movl_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale)
1101     {
1102         m_formatter.oneByteOp(OP_MOV_EvGv, src, base, index, scale, offset);
1103     }
1104     
1105     void movl_mEAX(const void* addr)
1106     {
1107         m_formatter.oneByteOp(OP_MOV_EAXOv);
1108 #if CPU(X86_64)
1109         m_formatter.immediate64(reinterpret_cast<int64_t>(addr));
1110 #else
1111         m_formatter.immediate32(reinterpret_cast<int>(addr));
1112 #endif
1113     }
1114
1115     void movl_mr(int offset, RegisterID base, RegisterID dst)
1116     {
1117         m_formatter.oneByteOp(OP_MOV_GvEv, dst, base, offset);
1118     }
1119
1120     void movl_mr_disp32(int offset, RegisterID base, RegisterID dst)
1121     {
1122         m_formatter.oneByteOp_disp32(OP_MOV_GvEv, dst, base, offset);
1123     }
1124     
1125     void movl_mr_disp8(int offset, RegisterID base, RegisterID dst)
1126     {
1127         m_formatter.oneByteOp_disp8(OP_MOV_GvEv, dst, base, offset);
1128     }
1129
1130     void movl_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
1131     {
1132         m_formatter.oneByteOp(OP_MOV_GvEv, dst, base, index, scale, offset);
1133     }
1134
1135     void movl_i32r(int imm, RegisterID dst)
1136     {
1137         m_formatter.oneByteOp(OP_MOV_EAXIv, dst);
1138         m_formatter.immediate32(imm);
1139     }
1140
1141     void movl_i32m(int imm, int offset, RegisterID base)
1142     {
1143         m_formatter.oneByteOp(OP_GROUP11_EvIz, GROUP11_MOV, base, offset);
1144         m_formatter.immediate32(imm);
1145     }
1146     
1147     void movl_i32m(int imm, int offset, RegisterID base, RegisterID index, int scale)
1148     {
1149         m_formatter.oneByteOp(OP_GROUP11_EvIz, GROUP11_MOV, base, index, scale, offset);
1150         m_formatter.immediate32(imm);
1151     }
1152
1153     void movb_i8m(int imm, int offset, RegisterID base)
1154     {
1155         ASSERT(-128 <= imm && imm < 128);
1156         m_formatter.oneByteOp(OP_GROUP11_EvIb, GROUP11_MOV, base, offset);
1157         m_formatter.immediate8(imm);
1158     }
1159
1160     void movb_i8m(int imm, int offset, RegisterID base, RegisterID index, int scale)
1161     {
1162         ASSERT(-128 <= imm && imm < 128);
1163         m_formatter.oneByteOp(OP_GROUP11_EvIb, GROUP11_MOV, base, index, scale, offset);
1164         m_formatter.immediate8(imm);
1165     }
1166     
1167     void movb_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale)
1168     {
1169         m_formatter.oneByteOp8(OP_MOV_EbGb, src, base, index, scale, offset);
1170     }
1171     
1172     void movw_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale)
1173     {
1174         m_formatter.prefix(PRE_OPERAND_SIZE);
1175         m_formatter.oneByteOp8(OP_MOV_EvGv, src, base, index, scale, offset);
1176     }
1177
1178     void movl_EAXm(const void* addr)
1179     {
1180         m_formatter.oneByteOp(OP_MOV_OvEAX);
1181 #if CPU(X86_64)
1182         m_formatter.immediate64(reinterpret_cast<int64_t>(addr));
1183 #else
1184         m_formatter.immediate32(reinterpret_cast<int>(addr));
1185 #endif
1186     }
1187
1188 #if CPU(X86_64)
1189     void movq_rr(RegisterID src, RegisterID dst)
1190     {
1191         m_formatter.oneByteOp64(OP_MOV_EvGv, src, dst);
1192     }
1193
1194     void movq_rm(RegisterID src, int offset, RegisterID base)
1195     {
1196         m_formatter.oneByteOp64(OP_MOV_EvGv, src, base, offset);
1197     }
1198
1199     void movq_rm_disp32(RegisterID src, int offset, RegisterID base)
1200     {
1201         m_formatter.oneByteOp64_disp32(OP_MOV_EvGv, src, base, offset);
1202     }
1203
1204     void movq_rm(RegisterID src, int offset, RegisterID base, RegisterID index, int scale)
1205     {
1206         m_formatter.oneByteOp64(OP_MOV_EvGv, src, base, index, scale, offset);
1207     }
1208
1209     void movq_mEAX(const void* addr)
1210     {
1211         m_formatter.oneByteOp64(OP_MOV_EAXOv);
1212         m_formatter.immediate64(reinterpret_cast<int64_t>(addr));
1213     }
1214
1215     void movq_EAXm(const void* addr)
1216     {
1217         m_formatter.oneByteOp64(OP_MOV_OvEAX);
1218         m_formatter.immediate64(reinterpret_cast<int64_t>(addr));
1219     }
1220
1221     void movq_mr(int offset, RegisterID base, RegisterID dst)
1222     {
1223         m_formatter.oneByteOp64(OP_MOV_GvEv, dst, base, offset);
1224     }
1225
1226     void movq_mr_disp32(int offset, RegisterID base, RegisterID dst)
1227     {
1228         m_formatter.oneByteOp64_disp32(OP_MOV_GvEv, dst, base, offset);
1229     }
1230
1231     void movq_mr_disp8(int offset, RegisterID base, RegisterID dst)
1232     {
1233         m_formatter.oneByteOp64_disp8(OP_MOV_GvEv, dst, base, offset);
1234     }
1235
1236     void movq_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
1237     {
1238         m_formatter.oneByteOp64(OP_MOV_GvEv, dst, base, index, scale, offset);
1239     }
1240
1241     void movq_i32m(int imm, int offset, RegisterID base)
1242     {
1243         m_formatter.oneByteOp64(OP_GROUP11_EvIz, GROUP11_MOV, base, offset);
1244         m_formatter.immediate32(imm);
1245     }
1246
1247     void movq_i64r(int64_t imm, RegisterID dst)
1248     {
1249         m_formatter.oneByteOp64(OP_MOV_EAXIv, dst);
1250         m_formatter.immediate64(imm);
1251     }
1252     
1253     void movsxd_rr(RegisterID src, RegisterID dst)
1254     {
1255         m_formatter.oneByteOp64(OP_MOVSXD_GvEv, dst, src);
1256     }
1257     
1258     
1259 #else
1260     void movl_rm(RegisterID src, const void* addr)
1261     {
1262         if (src == X86Registers::eax)
1263             movl_EAXm(addr);
1264         else 
1265             m_formatter.oneByteOp(OP_MOV_EvGv, src, addr);
1266     }
1267     
1268     void movl_mr(const void* addr, RegisterID dst)
1269     {
1270         if (dst == X86Registers::eax)
1271             movl_mEAX(addr);
1272         else
1273             m_formatter.oneByteOp(OP_MOV_GvEv, dst, addr);
1274     }
1275
1276     void movl_i32m(int imm, const void* addr)
1277     {
1278         m_formatter.oneByteOp(OP_GROUP11_EvIz, GROUP11_MOV, addr);
1279         m_formatter.immediate32(imm);
1280     }
1281 #endif
1282
1283     void movzwl_mr(int offset, RegisterID base, RegisterID dst)
1284     {
1285         m_formatter.twoByteOp(OP2_MOVZX_GvEw, dst, base, offset);
1286     }
1287
1288     void movzwl_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
1289     {
1290         m_formatter.twoByteOp(OP2_MOVZX_GvEw, dst, base, index, scale, offset);
1291     }
1292
1293     void movswl_mr(int offset, RegisterID base, RegisterID dst)
1294     {
1295         m_formatter.twoByteOp(OP2_MOVSX_GvEw, dst, base, offset);
1296     }
1297
1298     void movswl_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
1299     {
1300         m_formatter.twoByteOp(OP2_MOVSX_GvEw, dst, base, index, scale, offset);
1301     }
1302
1303     void movzbl_mr(int offset, RegisterID base, RegisterID dst)
1304     {
1305         m_formatter.twoByteOp(OP2_MOVZX_GvEb, dst, base, offset);
1306     }
1307     
1308     void movzbl_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
1309     {
1310         m_formatter.twoByteOp(OP2_MOVZX_GvEb, dst, base, index, scale, offset);
1311     }
1312
1313     void movsbl_mr(int offset, RegisterID base, RegisterID dst)
1314     {
1315         m_formatter.twoByteOp(OP2_MOVSX_GvEb, dst, base, offset);
1316     }
1317     
1318     void movsbl_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
1319     {
1320         m_formatter.twoByteOp(OP2_MOVSX_GvEb, dst, base, index, scale, offset);
1321     }
1322
1323     void movzbl_rr(RegisterID src, RegisterID dst)
1324     {
1325         // In 64-bit, this may cause an unnecessary REX to be planted (if the dst register
1326         // is in the range ESP-EDI, and the src would not have required a REX).  Unneeded
1327         // REX prefixes are defined to be silently ignored by the processor.
1328         m_formatter.twoByteOp8(OP2_MOVZX_GvEb, dst, src);
1329     }
1330
1331     void leal_mr(int offset, RegisterID base, RegisterID dst)
1332     {
1333         m_formatter.oneByteOp(OP_LEA, dst, base, offset);
1334     }
1335 #if CPU(X86_64)
1336     void leaq_mr(int offset, RegisterID base, RegisterID dst)
1337     {
1338         m_formatter.oneByteOp64(OP_LEA, dst, base, offset);
1339     }
1340 #endif
1341
1342     // Flow control:
1343
1344     AssemblerLabel call()
1345     {
1346         m_formatter.oneByteOp(OP_CALL_rel32);
1347         return m_formatter.immediateRel32();
1348     }
1349     
1350     AssemblerLabel call(RegisterID dst)
1351     {
1352         m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_CALLN, dst);
1353         return m_formatter.label();
1354     }
1355     
1356     void call_m(int offset, RegisterID base)
1357     {
1358         m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_CALLN, base, offset);
1359     }
1360
1361     AssemblerLabel jmp()
1362     {
1363         m_formatter.oneByteOp(OP_JMP_rel32);
1364         return m_formatter.immediateRel32();
1365     }
1366     
1367     // Return a AssemblerLabel so we have a label to the jump, so we can use this
1368     // To make a tail recursive call on x86-64.  The MacroAssembler
1369     // really shouldn't wrap this as a Jump, since it can't be linked. :-/
1370     AssemblerLabel jmp_r(RegisterID dst)
1371     {
1372         m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_JMPN, dst);
1373         return m_formatter.label();
1374     }
1375     
1376     void jmp_m(int offset, RegisterID base)
1377     {
1378         m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_JMPN, base, offset);
1379     }
1380     
1381 #if !CPU(X86_64)
1382     void jmp_m(const void* address)
1383     {
1384         m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_JMPN, address);
1385     }
1386 #endif
1387
1388     AssemblerLabel jne()
1389     {
1390         m_formatter.twoByteOp(jccRel32(ConditionNE));
1391         return m_formatter.immediateRel32();
1392     }
1393     
1394     AssemblerLabel jnz()
1395     {
1396         return jne();
1397     }
1398
1399     AssemblerLabel je()
1400     {
1401         m_formatter.twoByteOp(jccRel32(ConditionE));
1402         return m_formatter.immediateRel32();
1403     }
1404     
1405     AssemblerLabel jz()
1406     {
1407         return je();
1408     }
1409
1410     AssemblerLabel jl()
1411     {
1412         m_formatter.twoByteOp(jccRel32(ConditionL));
1413         return m_formatter.immediateRel32();
1414     }
1415     
1416     AssemblerLabel jb()
1417     {
1418         m_formatter.twoByteOp(jccRel32(ConditionB));
1419         return m_formatter.immediateRel32();
1420     }
1421     
1422     AssemblerLabel jle()
1423     {
1424         m_formatter.twoByteOp(jccRel32(ConditionLE));
1425         return m_formatter.immediateRel32();
1426     }
1427     
1428     AssemblerLabel jbe()
1429     {
1430         m_formatter.twoByteOp(jccRel32(ConditionBE));
1431         return m_formatter.immediateRel32();
1432     }
1433     
1434     AssemblerLabel jge()
1435     {
1436         m_formatter.twoByteOp(jccRel32(ConditionGE));
1437         return m_formatter.immediateRel32();
1438     }
1439
1440     AssemblerLabel jg()
1441     {
1442         m_formatter.twoByteOp(jccRel32(ConditionG));
1443         return m_formatter.immediateRel32();
1444     }
1445
1446     AssemblerLabel ja()
1447     {
1448         m_formatter.twoByteOp(jccRel32(ConditionA));
1449         return m_formatter.immediateRel32();
1450     }
1451     
1452     AssemblerLabel jae()
1453     {
1454         m_formatter.twoByteOp(jccRel32(ConditionAE));
1455         return m_formatter.immediateRel32();
1456     }
1457     
1458     AssemblerLabel jo()
1459     {
1460         m_formatter.twoByteOp(jccRel32(ConditionO));
1461         return m_formatter.immediateRel32();
1462     }
1463
1464     AssemblerLabel jp()
1465     {
1466         m_formatter.twoByteOp(jccRel32(ConditionP));
1467         return m_formatter.immediateRel32();
1468     }
1469     
1470     AssemblerLabel js()
1471     {
1472         m_formatter.twoByteOp(jccRel32(ConditionS));
1473         return m_formatter.immediateRel32();
1474     }
1475
1476     AssemblerLabel jCC(Condition cond)
1477     {
1478         m_formatter.twoByteOp(jccRel32(cond));
1479         return m_formatter.immediateRel32();
1480     }
1481
1482     // SSE operations:
1483
1484     void addsd_rr(XMMRegisterID src, XMMRegisterID dst)
1485     {
1486         m_formatter.prefix(PRE_SSE_F2);
1487         m_formatter.twoByteOp(OP2_ADDSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
1488     }
1489
1490     void addsd_mr(int offset, RegisterID base, XMMRegisterID dst)
1491     {
1492         m_formatter.prefix(PRE_SSE_F2);
1493         m_formatter.twoByteOp(OP2_ADDSD_VsdWsd, (RegisterID)dst, base, offset);
1494     }
1495
1496 #if !CPU(X86_64)
1497     void addsd_mr(const void* address, XMMRegisterID dst)
1498     {
1499         m_formatter.prefix(PRE_SSE_F2);
1500         m_formatter.twoByteOp(OP2_ADDSD_VsdWsd, (RegisterID)dst, address);
1501     }
1502 #endif
1503
1504     void cvtsi2sd_rr(RegisterID src, XMMRegisterID dst)
1505     {
1506         m_formatter.prefix(PRE_SSE_F2);
1507         m_formatter.twoByteOp(OP2_CVTSI2SD_VsdEd, (RegisterID)dst, src);
1508     }
1509
1510     void cvtsi2sd_mr(int offset, RegisterID base, XMMRegisterID dst)
1511     {
1512         m_formatter.prefix(PRE_SSE_F2);
1513         m_formatter.twoByteOp(OP2_CVTSI2SD_VsdEd, (RegisterID)dst, base, offset);
1514     }
1515
1516 #if !CPU(X86_64)
1517     void cvtsi2sd_mr(const void* address, XMMRegisterID dst)
1518     {
1519         m_formatter.prefix(PRE_SSE_F2);
1520         m_formatter.twoByteOp(OP2_CVTSI2SD_VsdEd, (RegisterID)dst, address);
1521     }
1522 #endif
1523
1524     void cvttsd2si_rr(XMMRegisterID src, RegisterID dst)
1525     {
1526         m_formatter.prefix(PRE_SSE_F2);
1527         m_formatter.twoByteOp(OP2_CVTTSD2SI_GdWsd, dst, (RegisterID)src);
1528     }
1529
1530     void cvtsd2ss_rr(XMMRegisterID src, XMMRegisterID dst)
1531     {
1532         m_formatter.prefix(PRE_SSE_F2);
1533         m_formatter.twoByteOp(OP2_CVTSD2SS_VsdWsd, dst, (RegisterID)src);
1534     }
1535
1536     void cvtss2sd_rr(XMMRegisterID src, XMMRegisterID dst)
1537     {
1538         m_formatter.prefix(PRE_SSE_F3);
1539         m_formatter.twoByteOp(OP2_CVTSS2SD_VsdWsd, dst, (RegisterID)src);
1540     }
1541     
1542 #if CPU(X86_64)
1543     void cvttsd2siq_rr(XMMRegisterID src, RegisterID dst)
1544     {
1545         m_formatter.prefix(PRE_SSE_F2);
1546         m_formatter.twoByteOp64(OP2_CVTTSD2SI_GdWsd, dst, (RegisterID)src);
1547     }
1548 #endif
1549
1550     void movd_rr(XMMRegisterID src, RegisterID dst)
1551     {
1552         m_formatter.prefix(PRE_SSE_66);
1553         m_formatter.twoByteOp(OP2_MOVD_EdVd, (RegisterID)src, dst);
1554     }
1555
1556     void movd_rr(RegisterID src, XMMRegisterID dst)
1557     {
1558         m_formatter.prefix(PRE_SSE_66);
1559         m_formatter.twoByteOp(OP2_MOVD_VdEd, (RegisterID)dst, src);
1560     }
1561
1562 #if CPU(X86_64)
1563     void movq_rr(XMMRegisterID src, RegisterID dst)
1564     {
1565         m_formatter.prefix(PRE_SSE_66);
1566         m_formatter.twoByteOp64(OP2_MOVD_EdVd, (RegisterID)src, dst);
1567     }
1568
1569     void movq_rr(RegisterID src, XMMRegisterID dst)
1570     {
1571         m_formatter.prefix(PRE_SSE_66);
1572         m_formatter.twoByteOp64(OP2_MOVD_VdEd, (RegisterID)dst, src);
1573     }
1574 #endif
1575
1576     void movsd_rr(XMMRegisterID src, XMMRegisterID dst)
1577     {
1578         m_formatter.prefix(PRE_SSE_F2);
1579         m_formatter.twoByteOp(OP2_MOVSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
1580     }
1581
1582     void movsd_rm(XMMRegisterID src, int offset, RegisterID base)
1583     {
1584         m_formatter.prefix(PRE_SSE_F2);
1585         m_formatter.twoByteOp(OP2_MOVSD_WsdVsd, (RegisterID)src, base, offset);
1586     }
1587     
1588     void movsd_rm(XMMRegisterID src, int offset, RegisterID base, RegisterID index, int scale)
1589     {
1590         m_formatter.prefix(PRE_SSE_F2);
1591         m_formatter.twoByteOp(OP2_MOVSD_WsdVsd, (RegisterID)src, base, index, scale, offset);
1592     }
1593     
1594     void movss_rm(XMMRegisterID src, int offset, RegisterID base, RegisterID index, int scale)
1595     {
1596         m_formatter.prefix(PRE_SSE_F3);
1597         m_formatter.twoByteOp(OP2_MOVSD_WsdVsd, (RegisterID)src, base, index, scale, offset);
1598     }
1599     
1600     void movsd_mr(int offset, RegisterID base, XMMRegisterID dst)
1601     {
1602         m_formatter.prefix(PRE_SSE_F2);
1603         m_formatter.twoByteOp(OP2_MOVSD_VsdWsd, (RegisterID)dst, base, offset);
1604     }
1605
1606     void movsd_mr(int offset, RegisterID base, RegisterID index, int scale, XMMRegisterID dst)
1607     {
1608         m_formatter.prefix(PRE_SSE_F2);
1609         m_formatter.twoByteOp(OP2_MOVSD_VsdWsd, dst, base, index, scale, offset);
1610     }
1611     
1612     void movss_mr(int offset, RegisterID base, RegisterID index, int scale, XMMRegisterID dst)
1613     {
1614         m_formatter.prefix(PRE_SSE_F3);
1615         m_formatter.twoByteOp(OP2_MOVSD_VsdWsd, dst, base, index, scale, offset);
1616     }
1617
1618 #if !CPU(X86_64)
1619     void movsd_mr(const void* address, XMMRegisterID dst)
1620     {
1621         m_formatter.prefix(PRE_SSE_F2);
1622         m_formatter.twoByteOp(OP2_MOVSD_VsdWsd, (RegisterID)dst, address);
1623     }
1624     void movsd_rm(XMMRegisterID src, const void* address)
1625     {
1626         m_formatter.prefix(PRE_SSE_F2);
1627         m_formatter.twoByteOp(OP2_MOVSD_WsdVsd, (RegisterID)src, address);
1628     }
1629 #endif
1630
1631     void mulsd_rr(XMMRegisterID src, XMMRegisterID dst)
1632     {
1633         m_formatter.prefix(PRE_SSE_F2);
1634         m_formatter.twoByteOp(OP2_MULSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
1635     }
1636
1637     void mulsd_mr(int offset, RegisterID base, XMMRegisterID dst)
1638     {
1639         m_formatter.prefix(PRE_SSE_F2);
1640         m_formatter.twoByteOp(OP2_MULSD_VsdWsd, (RegisterID)dst, base, offset);
1641     }
1642
1643     void pextrw_irr(int whichWord, XMMRegisterID src, RegisterID dst)
1644     {
1645         m_formatter.prefix(PRE_SSE_66);
1646         m_formatter.twoByteOp(OP2_PEXTRW_GdUdIb, (RegisterID)dst, (RegisterID)src);
1647         m_formatter.immediate8(whichWord);
1648     }
1649
1650     void psllq_i8r(int imm, XMMRegisterID dst)
1651     {
1652         m_formatter.prefix(PRE_SSE_66);
1653         m_formatter.twoByteOp8(OP2_PSLLQ_UdqIb, GROUP14_OP_PSLLQ, (RegisterID)dst);
1654         m_formatter.immediate8(imm);
1655     }
1656
1657     void psrlq_i8r(int imm, XMMRegisterID dst)
1658     {
1659         m_formatter.prefix(PRE_SSE_66);
1660         m_formatter.twoByteOp8(OP2_PSRLQ_UdqIb, GROUP14_OP_PSRLQ, (RegisterID)dst);
1661         m_formatter.immediate8(imm);
1662     }
1663
1664     void por_rr(XMMRegisterID src, XMMRegisterID dst)
1665     {
1666         m_formatter.prefix(PRE_SSE_66);
1667         m_formatter.twoByteOp(OP2_POR_VdqWdq, (RegisterID)dst, (RegisterID)src);
1668     }
1669
1670     void subsd_rr(XMMRegisterID src, XMMRegisterID dst)
1671     {
1672         m_formatter.prefix(PRE_SSE_F2);
1673         m_formatter.twoByteOp(OP2_SUBSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
1674     }
1675
1676     void subsd_mr(int offset, RegisterID base, XMMRegisterID dst)
1677     {
1678         m_formatter.prefix(PRE_SSE_F2);
1679         m_formatter.twoByteOp(OP2_SUBSD_VsdWsd, (RegisterID)dst, base, offset);
1680     }
1681
1682     void ucomisd_rr(XMMRegisterID src, XMMRegisterID dst)
1683     {
1684         m_formatter.prefix(PRE_SSE_66);
1685         m_formatter.twoByteOp(OP2_UCOMISD_VsdWsd, (RegisterID)dst, (RegisterID)src);
1686     }
1687
1688     void ucomisd_mr(int offset, RegisterID base, XMMRegisterID dst)
1689     {
1690         m_formatter.prefix(PRE_SSE_66);
1691         m_formatter.twoByteOp(OP2_UCOMISD_VsdWsd, (RegisterID)dst, base, offset);
1692     }
1693
1694     void divsd_rr(XMMRegisterID src, XMMRegisterID dst)
1695     {
1696         m_formatter.prefix(PRE_SSE_F2);
1697         m_formatter.twoByteOp(OP2_DIVSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
1698     }
1699
1700     void divsd_mr(int offset, RegisterID base, XMMRegisterID dst)
1701     {
1702         m_formatter.prefix(PRE_SSE_F2);
1703         m_formatter.twoByteOp(OP2_DIVSD_VsdWsd, (RegisterID)dst, base, offset);
1704     }
1705
1706     void xorpd_rr(XMMRegisterID src, XMMRegisterID dst)
1707     {
1708         m_formatter.prefix(PRE_SSE_66);
1709         m_formatter.twoByteOp(OP2_XORPD_VpdWpd, (RegisterID)dst, (RegisterID)src);
1710     }
1711
1712     void andnpd_rr(XMMRegisterID src, XMMRegisterID dst)
1713     {
1714         m_formatter.prefix(PRE_SSE_66);
1715         m_formatter.twoByteOp(OP2_ANDNPD_VpdWpd, (RegisterID)dst, (RegisterID)src);
1716     }
1717
1718     void sqrtsd_rr(XMMRegisterID src, XMMRegisterID dst)
1719     {
1720         m_formatter.prefix(PRE_SSE_F2);
1721         m_formatter.twoByteOp(OP2_SQRTSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
1722     }
1723
1724     // Misc instructions:
1725
1726     void int3()
1727     {
1728         m_formatter.oneByteOp(OP_INT3);
1729     }
1730     
1731     void ret()
1732     {
1733         m_formatter.oneByteOp(OP_RET);
1734     }
1735
1736     void predictNotTaken()
1737     {
1738         m_formatter.prefix(PRE_PREDICT_BRANCH_NOT_TAKEN);
1739     }
1740
1741     // Assembler admin methods:
1742
1743     size_t codeSize() const
1744     {
1745         return m_formatter.codeSize();
1746     }
1747     
1748     AssemblerLabel labelForWatchpoint()
1749     {
1750         AssemblerLabel result = m_formatter.label();
1751         if (static_cast<int>(result.m_offset) != m_indexOfLastWatchpoint)
1752             result = label();
1753         m_indexOfLastWatchpoint = result.m_offset;
1754         m_indexOfTailOfLastWatchpoint = result.m_offset + maxJumpReplacementSize();
1755         return result;
1756     }
1757     
1758     AssemblerLabel labelIgnoringWatchpoints()
1759     {
1760         return m_formatter.label();
1761     }
1762
1763     AssemblerLabel label()
1764     {
1765         AssemblerLabel result = m_formatter.label();
1766         while (UNLIKELY(static_cast<int>(result.m_offset) < m_indexOfTailOfLastWatchpoint)) {
1767             nop();
1768             result = m_formatter.label();
1769         }
1770         return result;
1771     }
1772
1773     AssemblerLabel align(int alignment)
1774     {
1775         while (!m_formatter.isAligned(alignment))
1776             m_formatter.oneByteOp(OP_HLT);
1777
1778         return label();
1779     }
1780
1781     // Linking & patching:
1782     //
1783     // 'link' and 'patch' methods are for use on unprotected code - such as the code
1784     // within the AssemblerBuffer, and code being patched by the patch buffer.  Once
1785     // code has been finalized it is (platform support permitting) within a non-
1786     // writable region of memory; to modify the code in an execute-only execuable
1787     // pool the 'repatch' and 'relink' methods should be used.
1788
1789     void linkJump(AssemblerLabel from, AssemblerLabel to)
1790     {
1791         ASSERT(from.isSet());
1792         ASSERT(to.isSet());
1793
1794         char* code = reinterpret_cast<char*>(m_formatter.data());
1795         ASSERT(!reinterpret_cast<int32_t*>(code + from.m_offset)[-1]);
1796         setRel32(code + from.m_offset, code + to.m_offset);
1797     }
1798     
1799     static void linkJump(void* code, AssemblerLabel from, void* to)
1800     {
1801         ASSERT(from.isSet());
1802
1803         setRel32(reinterpret_cast<char*>(code) + from.m_offset, to);
1804     }
1805
1806     static void linkCall(void* code, AssemblerLabel from, void* to)
1807     {
1808         ASSERT(from.isSet());
1809
1810         setRel32(reinterpret_cast<char*>(code) + from.m_offset, to);
1811     }
1812
1813     static void linkPointer(void* code, AssemblerLabel where, void* value)
1814     {
1815         ASSERT(where.isSet());
1816
1817         setPointer(reinterpret_cast<char*>(code) + where.m_offset, value);
1818     }
1819
1820     static void relinkJump(void* from, void* to)
1821     {
1822         setRel32(from, to);
1823     }
1824     
1825     static void relinkCall(void* from, void* to)
1826     {
1827         setRel32(from, to);
1828     }
1829     
1830     static void repatchCompact(void* where, int32_t value)
1831     {
1832         ASSERT(value >= std::numeric_limits<int8_t>::min());
1833         ASSERT(value <= std::numeric_limits<int8_t>::max());
1834         setInt8(where, value);
1835     }
1836
1837     static void repatchInt32(void* where, int32_t value)
1838     {
1839         setInt32(where, value);
1840     }
1841
1842     static void repatchPointer(void* where, void* value)
1843     {
1844         setPointer(where, value);
1845     }
1846     
1847     static void* readPointer(void* where)
1848     {
1849         return reinterpret_cast<void**>(where)[-1];
1850     }
1851
1852     static void replaceWithJump(void* instructionStart, void* to)
1853     {
1854         uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart);
1855         uint8_t* dstPtr = reinterpret_cast<uint8_t*>(to);
1856         intptr_t distance = (intptr_t)(dstPtr - (ptr + 5));
1857         ptr[0] = static_cast<uint8_t>(OP_JMP_rel32);
1858         *reinterpret_cast<int32_t*>(ptr + 1) = static_cast<int32_t>(distance);
1859     }
1860     
1861     static ptrdiff_t maxJumpReplacementSize()
1862     {
1863         return 5;
1864     }
1865     
1866     static void replaceWithLoad(void* instructionStart)
1867     {
1868         uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart);
1869 #if CPU(X86_64)
1870         if ((*ptr & ~15) == PRE_REX)
1871             ptr++;
1872 #endif
1873         switch (*ptr) {
1874         case OP_MOV_GvEv:
1875             break;
1876         case OP_LEA:
1877             *ptr = OP_MOV_GvEv;
1878             break;
1879         default:
1880             ASSERT_NOT_REACHED();
1881         }
1882     }
1883     
1884     static void replaceWithAddressComputation(void* instructionStart)
1885     {
1886         uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart);
1887 #if CPU(X86_64)
1888         if ((*ptr & ~15) == PRE_REX)
1889             ptr++;
1890 #endif
1891         switch (*ptr) {
1892         case OP_MOV_GvEv:
1893             *ptr = OP_LEA;
1894             break;
1895         case OP_LEA:
1896             break;
1897         default:
1898             ASSERT_NOT_REACHED();
1899         }
1900     }
1901     
1902     static unsigned getCallReturnOffset(AssemblerLabel call)
1903     {
1904         ASSERT(call.isSet());
1905         return call.m_offset;
1906     }
1907
1908     static void* getRelocatedAddress(void* code, AssemblerLabel label)
1909     {
1910         ASSERT(label.isSet());
1911         return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + label.m_offset);
1912     }
1913     
1914     static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
1915     {
1916         return b.m_offset - a.m_offset;
1917     }
1918     
1919     PassRefPtr<ExecutableMemoryHandle> executableCopy(JSGlobalData& globalData, void* ownerUID, JITCompilationEffort effort)
1920     {
1921         return m_formatter.executableCopy(globalData, ownerUID, effort);
1922     }
1923
1924     unsigned debugOffset() { return m_formatter.debugOffset(); }
1925
1926     void nop()
1927     {
1928         m_formatter.oneByteOp(OP_NOP);
1929     }
1930
1931     // This is a no-op on x86
1932     ALWAYS_INLINE static void cacheFlush(void*, size_t) { }
1933
1934 private:
1935
1936     static void setPointer(void* where, void* value)
1937     {
1938         reinterpret_cast<void**>(where)[-1] = value;
1939     }
1940
1941     static void setInt32(void* where, int32_t value)
1942     {
1943         reinterpret_cast<int32_t*>(where)[-1] = value;
1944     }
1945     
1946     static void setInt8(void* where, int8_t value)
1947     {
1948         reinterpret_cast<int8_t*>(where)[-1] = value;
1949     }
1950
1951     static void setRel32(void* from, void* to)
1952     {
1953         intptr_t offset = reinterpret_cast<intptr_t>(to) - reinterpret_cast<intptr_t>(from);
1954         ASSERT(offset == static_cast<int32_t>(offset));
1955
1956         setInt32(from, offset);
1957     }
1958
1959     class X86InstructionFormatter {
1960
1961         static const int maxInstructionSize = 16;
1962
1963     public:
1964
1965         // Legacy prefix bytes:
1966         //
1967         // These are emmitted prior to the instruction.
1968
1969         void prefix(OneByteOpcodeID pre)
1970         {
1971             m_buffer.putByte(pre);
1972         }
1973
1974         // Word-sized operands / no operand instruction formatters.
1975         //
1976         // In addition to the opcode, the following operand permutations are supported:
1977         //   * None - instruction takes no operands.
1978         //   * One register - the low three bits of the RegisterID are added into the opcode.
1979         //   * Two registers - encode a register form ModRm (for all ModRm formats, the reg field is passed first, and a GroupOpcodeID may be passed in its place).
1980         //   * Three argument ModRM - a register, and a register and an offset describing a memory operand.
1981         //   * Five argument ModRM - a register, and a base register, an index, scale, and offset describing a memory operand.
1982         //
1983         // For 32-bit x86 targets, the address operand may also be provided as a void*.
1984         // On 64-bit targets REX prefixes will be planted as necessary, where high numbered registers are used.
1985         //
1986         // The twoByteOp methods plant two-byte Intel instructions sequences (first opcode byte 0x0F).
1987
1988         void oneByteOp(OneByteOpcodeID opcode)
1989         {
1990             m_buffer.ensureSpace(maxInstructionSize);
1991             m_buffer.putByteUnchecked(opcode);
1992         }
1993
1994         void oneByteOp(OneByteOpcodeID opcode, RegisterID reg)
1995         {
1996             m_buffer.ensureSpace(maxInstructionSize);
1997             emitRexIfNeeded(0, 0, reg);
1998             m_buffer.putByteUnchecked(opcode + (reg & 7));
1999         }
2000
2001         void oneByteOp(OneByteOpcodeID opcode, int reg, RegisterID rm)
2002         {
2003             m_buffer.ensureSpace(maxInstructionSize);
2004             emitRexIfNeeded(reg, 0, rm);
2005             m_buffer.putByteUnchecked(opcode);
2006             registerModRM(reg, rm);
2007         }
2008
2009         void oneByteOp(OneByteOpcodeID opcode, int reg, RegisterID base, int offset)
2010         {
2011             m_buffer.ensureSpace(maxInstructionSize);
2012             emitRexIfNeeded(reg, 0, base);
2013             m_buffer.putByteUnchecked(opcode);
2014             memoryModRM(reg, base, offset);
2015         }
2016
2017         void oneByteOp_disp32(OneByteOpcodeID opcode, int reg, RegisterID base, int offset)
2018         {
2019             m_buffer.ensureSpace(maxInstructionSize);
2020             emitRexIfNeeded(reg, 0, base);
2021             m_buffer.putByteUnchecked(opcode);
2022             memoryModRM_disp32(reg, base, offset);
2023         }
2024         
2025         void oneByteOp_disp8(OneByteOpcodeID opcode, int reg, RegisterID base, int offset)
2026         {
2027             m_buffer.ensureSpace(maxInstructionSize);
2028             emitRexIfNeeded(reg, 0, base);
2029             m_buffer.putByteUnchecked(opcode);
2030             memoryModRM_disp8(reg, base, offset);
2031         }
2032
2033         void oneByteOp(OneByteOpcodeID opcode, int reg, RegisterID base, RegisterID index, int scale, int offset)
2034         {
2035             m_buffer.ensureSpace(maxInstructionSize);
2036             emitRexIfNeeded(reg, index, base);
2037             m_buffer.putByteUnchecked(opcode);
2038             memoryModRM(reg, base, index, scale, offset);
2039         }
2040
2041 #if !CPU(X86_64)
2042         void oneByteOp(OneByteOpcodeID opcode, int reg, const void* address)
2043         {
2044             m_buffer.ensureSpace(maxInstructionSize);
2045             m_buffer.putByteUnchecked(opcode);
2046             memoryModRM(reg, address);
2047         }
2048 #endif
2049
2050         void twoByteOp(TwoByteOpcodeID opcode)
2051         {
2052             m_buffer.ensureSpace(maxInstructionSize);
2053             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2054             m_buffer.putByteUnchecked(opcode);
2055         }
2056
2057         void twoByteOp(TwoByteOpcodeID opcode, int reg, RegisterID rm)
2058         {
2059             m_buffer.ensureSpace(maxInstructionSize);
2060             emitRexIfNeeded(reg, 0, rm);
2061             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2062             m_buffer.putByteUnchecked(opcode);
2063             registerModRM(reg, rm);
2064         }
2065
2066         void twoByteOp(TwoByteOpcodeID opcode, int reg, RegisterID base, int offset)
2067         {
2068             m_buffer.ensureSpace(maxInstructionSize);
2069             emitRexIfNeeded(reg, 0, base);
2070             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2071             m_buffer.putByteUnchecked(opcode);
2072             memoryModRM(reg, base, offset);
2073         }
2074
2075         void twoByteOp(TwoByteOpcodeID opcode, int reg, RegisterID base, RegisterID index, int scale, int offset)
2076         {
2077             m_buffer.ensureSpace(maxInstructionSize);
2078             emitRexIfNeeded(reg, index, base);
2079             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2080             m_buffer.putByteUnchecked(opcode);
2081             memoryModRM(reg, base, index, scale, offset);
2082         }
2083
2084 #if !CPU(X86_64)
2085         void twoByteOp(TwoByteOpcodeID opcode, int reg, const void* address)
2086         {
2087             m_buffer.ensureSpace(maxInstructionSize);
2088             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2089             m_buffer.putByteUnchecked(opcode);
2090             memoryModRM(reg, address);
2091         }
2092 #endif
2093
2094 #if CPU(X86_64)
2095         // Quad-word-sized operands:
2096         //
2097         // Used to format 64-bit operantions, planting a REX.w prefix.
2098         // When planting d64 or f64 instructions, not requiring a REX.w prefix,
2099         // the normal (non-'64'-postfixed) formatters should be used.
2100
2101         void oneByteOp64(OneByteOpcodeID opcode)
2102         {
2103             m_buffer.ensureSpace(maxInstructionSize);
2104             emitRexW(0, 0, 0);
2105             m_buffer.putByteUnchecked(opcode);
2106         }
2107
2108         void oneByteOp64(OneByteOpcodeID opcode, RegisterID reg)
2109         {
2110             m_buffer.ensureSpace(maxInstructionSize);
2111             emitRexW(0, 0, reg);
2112             m_buffer.putByteUnchecked(opcode + (reg & 7));
2113         }
2114
2115         void oneByteOp64(OneByteOpcodeID opcode, int reg, RegisterID rm)
2116         {
2117             m_buffer.ensureSpace(maxInstructionSize);
2118             emitRexW(reg, 0, rm);
2119             m_buffer.putByteUnchecked(opcode);
2120             registerModRM(reg, rm);
2121         }
2122
2123         void oneByteOp64(OneByteOpcodeID opcode, int reg, RegisterID base, int offset)
2124         {
2125             m_buffer.ensureSpace(maxInstructionSize);
2126             emitRexW(reg, 0, base);
2127             m_buffer.putByteUnchecked(opcode);
2128             memoryModRM(reg, base, offset);
2129         }
2130
2131         void oneByteOp64_disp32(OneByteOpcodeID opcode, int reg, RegisterID base, int offset)
2132         {
2133             m_buffer.ensureSpace(maxInstructionSize);
2134             emitRexW(reg, 0, base);
2135             m_buffer.putByteUnchecked(opcode);
2136             memoryModRM_disp32(reg, base, offset);
2137         }
2138         
2139         void oneByteOp64_disp8(OneByteOpcodeID opcode, int reg, RegisterID base, int offset)
2140         {
2141             m_buffer.ensureSpace(maxInstructionSize);
2142             emitRexW(reg, 0, base);
2143             m_buffer.putByteUnchecked(opcode);
2144             memoryModRM_disp8(reg, base, offset);
2145         }
2146
2147         void oneByteOp64(OneByteOpcodeID opcode, int reg, RegisterID base, RegisterID index, int scale, int offset)
2148         {
2149             m_buffer.ensureSpace(maxInstructionSize);
2150             emitRexW(reg, index, base);
2151             m_buffer.putByteUnchecked(opcode);
2152             memoryModRM(reg, base, index, scale, offset);
2153         }
2154
2155         void twoByteOp64(TwoByteOpcodeID opcode, int reg, RegisterID rm)
2156         {
2157             m_buffer.ensureSpace(maxInstructionSize);
2158             emitRexW(reg, 0, rm);
2159             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2160             m_buffer.putByteUnchecked(opcode);
2161             registerModRM(reg, rm);
2162         }
2163 #endif
2164
2165         // Byte-operands:
2166         //
2167         // These methods format byte operations.  Byte operations differ from the normal
2168         // formatters in the circumstances under which they will decide to emit REX prefixes.
2169         // These should be used where any register operand signifies a byte register.
2170         //
2171         // The disctinction is due to the handling of register numbers in the range 4..7 on
2172         // x86-64.  These register numbers may either represent the second byte of the first
2173         // four registers (ah..bh) or the first byte of the second four registers (spl..dil).
2174         //
2175         // Since ah..bh cannot be used in all permutations of operands (specifically cannot
2176         // be accessed where a REX prefix is present), these are likely best treated as
2177         // deprecated.  In order to ensure the correct registers spl..dil are selected a
2178         // REX prefix will be emitted for any byte register operand in the range 4..15.
2179         //
2180         // These formatters may be used in instructions where a mix of operand sizes, in which
2181         // case an unnecessary REX will be emitted, for example:
2182         //     movzbl %al, %edi
2183         // In this case a REX will be planted since edi is 7 (and were this a byte operand
2184         // a REX would be required to specify dil instead of bh).  Unneeded REX prefixes will
2185         // be silently ignored by the processor.
2186         //
2187         // Address operands should still be checked using regRequiresRex(), while byteRegRequiresRex()
2188         // is provided to check byte register operands.
2189
2190         void oneByteOp8(OneByteOpcodeID opcode, GroupOpcodeID groupOp, RegisterID rm)
2191         {
2192             m_buffer.ensureSpace(maxInstructionSize);
2193             emitRexIf(byteRegRequiresRex(rm), 0, 0, rm);
2194             m_buffer.putByteUnchecked(opcode);
2195             registerModRM(groupOp, rm);
2196         }
2197
2198         void oneByteOp8(OneByteOpcodeID opcode, int reg, RegisterID rm)
2199         {
2200             m_buffer.ensureSpace(maxInstructionSize);
2201             emitRexIf(byteRegRequiresRex(reg) || byteRegRequiresRex(rm), reg, 0, rm);
2202             m_buffer.putByteUnchecked(opcode);
2203             registerModRM(reg, rm);
2204         }
2205
2206         void oneByteOp8(OneByteOpcodeID opcode, int reg, RegisterID base, RegisterID index, int scale, int offset)
2207         {
2208             m_buffer.ensureSpace(maxInstructionSize);
2209             emitRexIf(byteRegRequiresRex(reg) || regRequiresRex(index) || regRequiresRex(base), reg, index, base);
2210             m_buffer.putByteUnchecked(opcode);
2211             memoryModRM(reg, base, index, scale, offset);
2212         }
2213
2214         void twoByteOp8(TwoByteOpcodeID opcode, RegisterID reg, RegisterID rm)
2215         {
2216             m_buffer.ensureSpace(maxInstructionSize);
2217             emitRexIf(byteRegRequiresRex(reg)|byteRegRequiresRex(rm), reg, 0, rm);
2218             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2219             m_buffer.putByteUnchecked(opcode);
2220             registerModRM(reg, rm);
2221         }
2222
2223         void twoByteOp8(TwoByteOpcodeID opcode, GroupOpcodeID groupOp, RegisterID rm)
2224         {
2225             m_buffer.ensureSpace(maxInstructionSize);
2226             emitRexIf(byteRegRequiresRex(rm), 0, 0, rm);
2227             m_buffer.putByteUnchecked(OP_2BYTE_ESCAPE);
2228             m_buffer.putByteUnchecked(opcode);
2229             registerModRM(groupOp, rm);
2230         }
2231
2232         // Immediates:
2233         //
2234         // An immedaite should be appended where appropriate after an op has been emitted.
2235         // The writes are unchecked since the opcode formatters above will have ensured space.
2236
2237         void immediate8(int imm)
2238         {
2239             m_buffer.putByteUnchecked(imm);
2240         }
2241
2242         void immediate16(int imm)
2243         {
2244             m_buffer.putShortUnchecked(imm);
2245         }
2246
2247         void immediate32(int imm)
2248         {
2249             m_buffer.putIntUnchecked(imm);
2250         }
2251
2252         void immediate64(int64_t imm)
2253         {
2254             m_buffer.putInt64Unchecked(imm);
2255         }
2256
2257         AssemblerLabel immediateRel32()
2258         {
2259             m_buffer.putIntUnchecked(0);
2260             return label();
2261         }
2262
2263         // Administrative methods:
2264
2265         size_t codeSize() const { return m_buffer.codeSize(); }
2266         AssemblerLabel label() const { return m_buffer.label(); }
2267         bool isAligned(int alignment) const { return m_buffer.isAligned(alignment); }
2268         void* data() const { return m_buffer.data(); }
2269
2270         PassRefPtr<ExecutableMemoryHandle> executableCopy(JSGlobalData& globalData, void* ownerUID, JITCompilationEffort effort)
2271         {
2272             return m_buffer.executableCopy(globalData, ownerUID, effort);
2273         }
2274
2275         unsigned debugOffset() { return m_buffer.debugOffset(); }
2276
2277     private:
2278
2279         // Internals; ModRm and REX formatters.
2280
2281         static const RegisterID noBase = X86Registers::ebp;
2282         static const RegisterID hasSib = X86Registers::esp;
2283         static const RegisterID noIndex = X86Registers::esp;
2284 #if CPU(X86_64)
2285         static const RegisterID noBase2 = X86Registers::r13;
2286         static const RegisterID hasSib2 = X86Registers::r12;
2287
2288         // Registers r8 & above require a REX prefixe.
2289         inline bool regRequiresRex(int reg)
2290         {
2291             return (reg >= X86Registers::r8);
2292         }
2293
2294         // Byte operand register spl & above require a REX prefix (to prevent the 'H' registers be accessed).
2295         inline bool byteRegRequiresRex(int reg)
2296         {
2297             return (reg >= X86Registers::esp);
2298         }
2299
2300         // Format a REX prefix byte.
2301         inline void emitRex(bool w, int r, int x, int b)
2302         {
2303             m_buffer.putByteUnchecked(PRE_REX | ((int)w << 3) | ((r>>3)<<2) | ((x>>3)<<1) | (b>>3));
2304         }
2305
2306         // Used to plant a REX byte with REX.w set (for 64-bit operations).
2307         inline void emitRexW(int r, int x, int b)
2308         {
2309             emitRex(true, r, x, b);
2310         }
2311
2312         // Used for operations with byte operands - use byteRegRequiresRex() to check register operands,
2313         // regRequiresRex() to check other registers (i.e. address base & index).
2314         inline void emitRexIf(bool condition, int r, int x, int b)
2315         {
2316             if (condition) emitRex(false, r, x, b);
2317         }
2318
2319         // Used for word sized operations, will plant a REX prefix if necessary (if any register is r8 or above).
2320         inline void emitRexIfNeeded(int r, int x, int b)
2321         {
2322             emitRexIf(regRequiresRex(r) || regRequiresRex(x) || regRequiresRex(b), r, x, b);
2323         }
2324 #else
2325         // No REX prefix bytes on 32-bit x86.
2326         inline bool regRequiresRex(int) { return false; }
2327         inline bool byteRegRequiresRex(int) { return false; }
2328         inline void emitRexIf(bool, int, int, int) {}
2329         inline void emitRexIfNeeded(int, int, int) {}
2330 #endif
2331
2332         enum ModRmMode {
2333             ModRmMemoryNoDisp,
2334             ModRmMemoryDisp8,
2335             ModRmMemoryDisp32,
2336             ModRmRegister,
2337         };
2338
2339         void putModRm(ModRmMode mode, int reg, RegisterID rm)
2340         {
2341             m_buffer.putByteUnchecked((mode << 6) | ((reg & 7) << 3) | (rm & 7));
2342         }
2343
2344         void putModRmSib(ModRmMode mode, int reg, RegisterID base, RegisterID index, int scale)
2345         {
2346             ASSERT(mode != ModRmRegister);
2347
2348             putModRm(mode, reg, hasSib);
2349             m_buffer.putByteUnchecked((scale << 6) | ((index & 7) << 3) | (base & 7));
2350         }
2351
2352         void registerModRM(int reg, RegisterID rm)
2353         {
2354             putModRm(ModRmRegister, reg, rm);
2355         }
2356
2357         void memoryModRM(int reg, RegisterID base, int offset)
2358         {
2359             // A base of esp or r12 would be interpreted as a sib, so force a sib with no index & put the base in there.
2360 #if CPU(X86_64)
2361             if ((base == hasSib) || (base == hasSib2)) {
2362 #else
2363             if (base == hasSib) {
2364 #endif
2365                 if (!offset) // No need to check if the base is noBase, since we know it is hasSib!
2366                     putModRmSib(ModRmMemoryNoDisp, reg, base, noIndex, 0);
2367                 else if (CAN_SIGN_EXTEND_8_32(offset)) {
2368                     putModRmSib(ModRmMemoryDisp8, reg, base, noIndex, 0);
2369                     m_buffer.putByteUnchecked(offset);
2370                 } else {
2371                     putModRmSib(ModRmMemoryDisp32, reg, base, noIndex, 0);
2372                     m_buffer.putIntUnchecked(offset);
2373                 }
2374             } else {
2375 #if CPU(X86_64)
2376                 if (!offset && (base != noBase) && (base != noBase2))
2377 #else
2378                 if (!offset && (base != noBase))
2379 #endif
2380                     putModRm(ModRmMemoryNoDisp, reg, base);
2381                 else if (CAN_SIGN_EXTEND_8_32(offset)) {
2382                     putModRm(ModRmMemoryDisp8, reg, base);
2383                     m_buffer.putByteUnchecked(offset);
2384                 } else {
2385                     putModRm(ModRmMemoryDisp32, reg, base);
2386                     m_buffer.putIntUnchecked(offset);
2387                 }
2388             }
2389         }
2390
2391         void memoryModRM_disp8(int reg, RegisterID base, int offset)
2392         {
2393             // A base of esp or r12 would be interpreted as a sib, so force a sib with no index & put the base in there.
2394             ASSERT(CAN_SIGN_EXTEND_8_32(offset));
2395 #if CPU(X86_64)
2396             if ((base == hasSib) || (base == hasSib2)) {
2397 #else
2398             if (base == hasSib) {
2399 #endif
2400                 putModRmSib(ModRmMemoryDisp8, reg, base, noIndex, 0);
2401                 m_buffer.putByteUnchecked(offset);
2402             } else {
2403                 putModRm(ModRmMemoryDisp8, reg, base);
2404                 m_buffer.putByteUnchecked(offset);
2405             }
2406         }
2407
2408         void memoryModRM_disp32(int reg, RegisterID base, int offset)
2409         {
2410             // A base of esp or r12 would be interpreted as a sib, so force a sib with no index & put the base in there.
2411 #if CPU(X86_64)
2412             if ((base == hasSib) || (base == hasSib2)) {
2413 #else
2414             if (base == hasSib) {
2415 #endif
2416                 putModRmSib(ModRmMemoryDisp32, reg, base, noIndex, 0);
2417                 m_buffer.putIntUnchecked(offset);
2418             } else {
2419                 putModRm(ModRmMemoryDisp32, reg, base);
2420                 m_buffer.putIntUnchecked(offset);
2421             }
2422         }
2423     
2424         void memoryModRM(int reg, RegisterID base, RegisterID index, int scale, int offset)
2425         {
2426             ASSERT(index != noIndex);
2427
2428 #if CPU(X86_64)
2429             if (!offset && (base != noBase) && (base != noBase2))
2430 #else
2431             if (!offset && (base != noBase))
2432 #endif
2433                 putModRmSib(ModRmMemoryNoDisp, reg, base, index, scale);
2434             else if (CAN_SIGN_EXTEND_8_32(offset)) {
2435                 putModRmSib(ModRmMemoryDisp8, reg, base, index, scale);
2436                 m_buffer.putByteUnchecked(offset);
2437             } else {
2438                 putModRmSib(ModRmMemoryDisp32, reg, base, index, scale);
2439                 m_buffer.putIntUnchecked(offset);
2440             }
2441         }
2442
2443 #if !CPU(X86_64)
2444         void memoryModRM(int reg, const void* address)
2445         {
2446             // noBase + ModRmMemoryNoDisp means noBase + ModRmMemoryDisp32!
2447             putModRm(ModRmMemoryNoDisp, reg, noBase);
2448             m_buffer.putIntUnchecked(reinterpret_cast<int32_t>(address));
2449         }
2450 #endif
2451
2452         AssemblerBuffer m_buffer;
2453     } m_formatter;
2454     int m_indexOfLastWatchpoint;
2455     int m_indexOfTailOfLastWatchpoint;
2456 };
2457
2458 } // namespace JSC
2459
2460 #endif // ENABLE(ASSEMBLER) && CPU(X86)
2461
2462 #endif // X86Assembler_h