1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // 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 are
6 // met:
7 //
8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 //
11 // - Redistribution in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // - Neither the name of Sun Microsystems or the names of contributors may
16 // be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // The original source code covered by the above license above has been
32 // modified significantly by Google Inc.
33 // Copyright 2012 the V8 project authors. All rights reserved.
34 
35 // A light-weight IA32 Assembler.
36 
37 #ifndef V8_IA32_ASSEMBLER_IA32_INL_H_
38 #define V8_IA32_ASSEMBLER_IA32_INL_H_
39 
40 #include "src/ia32/assembler-ia32.h"
41 
42 #include "src/assembler.h"
43 #include "src/debug/debug.h"
44 
45 namespace v8 {
46 namespace internal {
47 
SupportsCrankshaft()48 bool CpuFeatures::SupportsCrankshaft() { return true; }
49 
50 
51 static const byte kCallOpcode = 0xE8;
52 static const int kNoCodeAgeSequenceLength = 5;
53 
54 
55 // The modes possibly affected by apply must be in kApplyMask.
apply(intptr_t delta)56 void RelocInfo::apply(intptr_t delta) {
57   if (IsRuntimeEntry(rmode_) || IsCodeTarget(rmode_)) {
58     int32_t* p = reinterpret_cast<int32_t*>(pc_);
59     *p -= delta;  // Relocate entry.
60   } else if (IsCodeAgeSequence(rmode_)) {
61     if (*pc_ == kCallOpcode) {
62       int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1);
63       *p -= delta;  // Relocate entry.
64     }
65   } else if (IsDebugBreakSlot(rmode_) && IsPatchedDebugBreakSlotSequence()) {
66     // Special handling of a debug break slot when a break point is set (call
67     // instruction has been inserted).
68     int32_t* p = reinterpret_cast<int32_t*>(
69         pc_ + Assembler::kPatchDebugBreakSlotAddressOffset);
70     *p -= delta;  // Relocate entry.
71   } else if (IsInternalReference(rmode_)) {
72     // absolute code pointer inside code object moves with the code object.
73     int32_t* p = reinterpret_cast<int32_t*>(pc_);
74     *p += delta;  // Relocate entry.
75   }
76 }
77 
78 
target_address()79 Address RelocInfo::target_address() {
80   DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
81   return Assembler::target_address_at(pc_, host_);
82 }
83 
84 
target_address_address()85 Address RelocInfo::target_address_address() {
86   DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
87                               || rmode_ == EMBEDDED_OBJECT
88                               || rmode_ == EXTERNAL_REFERENCE);
89   return reinterpret_cast<Address>(pc_);
90 }
91 
92 
constant_pool_entry_address()93 Address RelocInfo::constant_pool_entry_address() {
94   UNREACHABLE();
95   return NULL;
96 }
97 
98 
target_address_size()99 int RelocInfo::target_address_size() {
100   return Assembler::kSpecialTargetSize;
101 }
102 
103 
set_target_address(Address target,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)104 void RelocInfo::set_target_address(Address target,
105                                    WriteBarrierMode write_barrier_mode,
106                                    ICacheFlushMode icache_flush_mode) {
107   Assembler::set_target_address_at(isolate_, pc_, host_, target,
108                                    icache_flush_mode);
109   DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
110   if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL &&
111       IsCodeTarget(rmode_)) {
112     Object* target_code = Code::GetCodeFromTargetAddress(target);
113     host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
114         host(), this, HeapObject::cast(target_code));
115   }
116 }
117 
118 
target_object()119 Object* RelocInfo::target_object() {
120   DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
121   return Memory::Object_at(pc_);
122 }
123 
124 
target_object_handle(Assembler * origin)125 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) {
126   DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
127   return Memory::Object_Handle_at(pc_);
128 }
129 
130 
set_target_object(Object * target,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)131 void RelocInfo::set_target_object(Object* target,
132                                   WriteBarrierMode write_barrier_mode,
133                                   ICacheFlushMode icache_flush_mode) {
134   DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
135   Memory::Object_at(pc_) = target;
136   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
137     Assembler::FlushICache(isolate_, pc_, sizeof(Address));
138   }
139   if (write_barrier_mode == UPDATE_WRITE_BARRIER &&
140       host() != NULL &&
141       target->IsHeapObject()) {
142     host()->GetHeap()->incremental_marking()->RecordWrite(
143         host(), &Memory::Object_at(pc_), HeapObject::cast(target));
144   }
145 }
146 
147 
target_external_reference()148 Address RelocInfo::target_external_reference() {
149   DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
150   return Memory::Address_at(pc_);
151 }
152 
153 
target_internal_reference()154 Address RelocInfo::target_internal_reference() {
155   DCHECK(rmode_ == INTERNAL_REFERENCE);
156   return Memory::Address_at(pc_);
157 }
158 
159 
target_internal_reference_address()160 Address RelocInfo::target_internal_reference_address() {
161   DCHECK(rmode_ == INTERNAL_REFERENCE);
162   return reinterpret_cast<Address>(pc_);
163 }
164 
165 
target_runtime_entry(Assembler * origin)166 Address RelocInfo::target_runtime_entry(Assembler* origin) {
167   DCHECK(IsRuntimeEntry(rmode_));
168   return reinterpret_cast<Address>(*reinterpret_cast<int32_t*>(pc_));
169 }
170 
171 
set_target_runtime_entry(Address target,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)172 void RelocInfo::set_target_runtime_entry(Address target,
173                                          WriteBarrierMode write_barrier_mode,
174                                          ICacheFlushMode icache_flush_mode) {
175   DCHECK(IsRuntimeEntry(rmode_));
176   if (target_address() != target) {
177     set_target_address(target, write_barrier_mode, icache_flush_mode);
178   }
179 }
180 
181 
target_cell_handle()182 Handle<Cell> RelocInfo::target_cell_handle() {
183   DCHECK(rmode_ == RelocInfo::CELL);
184   Address address = Memory::Address_at(pc_);
185   return Handle<Cell>(reinterpret_cast<Cell**>(address));
186 }
187 
188 
target_cell()189 Cell* RelocInfo::target_cell() {
190   DCHECK(rmode_ == RelocInfo::CELL);
191   return Cell::FromValueAddress(Memory::Address_at(pc_));
192 }
193 
194 
set_target_cell(Cell * cell,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)195 void RelocInfo::set_target_cell(Cell* cell,
196                                 WriteBarrierMode write_barrier_mode,
197                                 ICacheFlushMode icache_flush_mode) {
198   DCHECK(cell->IsCell());
199   DCHECK(rmode_ == RelocInfo::CELL);
200   Address address = cell->address() + Cell::kValueOffset;
201   Memory::Address_at(pc_) = address;
202   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
203     Assembler::FlushICache(isolate_, pc_, sizeof(Address));
204   }
205   if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
206     // TODO(1550) We are passing NULL as a slot because cell can never be on
207     // evacuation candidate.
208     host()->GetHeap()->incremental_marking()->RecordWrite(
209         host(), NULL, cell);
210   }
211 }
212 
213 
code_age_stub_handle(Assembler * origin)214 Handle<Object> RelocInfo::code_age_stub_handle(Assembler* origin) {
215   DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
216   DCHECK(*pc_ == kCallOpcode);
217   return Memory::Object_Handle_at(pc_ + 1);
218 }
219 
220 
code_age_stub()221 Code* RelocInfo::code_age_stub() {
222   DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
223   DCHECK(*pc_ == kCallOpcode);
224   return Code::GetCodeFromTargetAddress(
225       Assembler::target_address_at(pc_ + 1, host_));
226 }
227 
228 
set_code_age_stub(Code * stub,ICacheFlushMode icache_flush_mode)229 void RelocInfo::set_code_age_stub(Code* stub,
230                                   ICacheFlushMode icache_flush_mode) {
231   DCHECK(*pc_ == kCallOpcode);
232   DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
233   Assembler::set_target_address_at(
234       isolate_, pc_ + 1, host_, stub->instruction_start(), icache_flush_mode);
235 }
236 
237 
debug_call_address()238 Address RelocInfo::debug_call_address() {
239   DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
240   Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset;
241   return Assembler::target_address_at(location, host_);
242 }
243 
244 
set_debug_call_address(Address target)245 void RelocInfo::set_debug_call_address(Address target) {
246   DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
247   Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset;
248   Assembler::set_target_address_at(isolate_, location, host_, target);
249   if (host() != NULL) {
250     Object* target_code = Code::GetCodeFromTargetAddress(target);
251     host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
252         host(), this, HeapObject::cast(target_code));
253   }
254 }
255 
256 
WipeOut()257 void RelocInfo::WipeOut() {
258   if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) ||
259       IsInternalReference(rmode_)) {
260     Memory::Address_at(pc_) = NULL;
261   } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) {
262     // Effectively write zero into the relocation.
263     Assembler::set_target_address_at(isolate_, pc_, host_,
264                                      pc_ + sizeof(int32_t));
265   } else {
266     UNREACHABLE();
267   }
268 }
269 
270 
IsPatchedReturnSequence()271 bool RelocInfo::IsPatchedReturnSequence() {
272   return *pc_ == kCallOpcode;
273 }
274 
275 
IsPatchedDebugBreakSlotSequence()276 bool RelocInfo::IsPatchedDebugBreakSlotSequence() {
277   return !Assembler::IsNop(pc());
278 }
279 
280 
Visit(Isolate * isolate,ObjectVisitor * visitor)281 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) {
282   RelocInfo::Mode mode = rmode();
283   if (mode == RelocInfo::EMBEDDED_OBJECT) {
284     visitor->VisitEmbeddedPointer(this);
285     Assembler::FlushICache(isolate, pc_, sizeof(Address));
286   } else if (RelocInfo::IsCodeTarget(mode)) {
287     visitor->VisitCodeTarget(this);
288   } else if (mode == RelocInfo::CELL) {
289     visitor->VisitCell(this);
290   } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
291     visitor->VisitExternalReference(this);
292   } else if (mode == RelocInfo::INTERNAL_REFERENCE) {
293     visitor->VisitInternalReference(this);
294   } else if (RelocInfo::IsCodeAgeSequence(mode)) {
295     visitor->VisitCodeAgeSequence(this);
296   } else if (RelocInfo::IsDebugBreakSlot(mode) &&
297              IsPatchedDebugBreakSlotSequence()) {
298     visitor->VisitDebugTarget(this);
299   } else if (IsRuntimeEntry(mode)) {
300     visitor->VisitRuntimeEntry(this);
301   }
302 }
303 
304 
305 template<typename StaticVisitor>
Visit(Heap * heap)306 void RelocInfo::Visit(Heap* heap) {
307   RelocInfo::Mode mode = rmode();
308   if (mode == RelocInfo::EMBEDDED_OBJECT) {
309     StaticVisitor::VisitEmbeddedPointer(heap, this);
310     Assembler::FlushICache(heap->isolate(), pc_, sizeof(Address));
311   } else if (RelocInfo::IsCodeTarget(mode)) {
312     StaticVisitor::VisitCodeTarget(heap, this);
313   } else if (mode == RelocInfo::CELL) {
314     StaticVisitor::VisitCell(heap, this);
315   } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
316     StaticVisitor::VisitExternalReference(this);
317   } else if (mode == RelocInfo::INTERNAL_REFERENCE) {
318     StaticVisitor::VisitInternalReference(this);
319   } else if (RelocInfo::IsCodeAgeSequence(mode)) {
320     StaticVisitor::VisitCodeAgeSequence(heap, this);
321   } else if (RelocInfo::IsDebugBreakSlot(mode) &&
322              IsPatchedDebugBreakSlotSequence()) {
323     StaticVisitor::VisitDebugTarget(heap, this);
324   } else if (IsRuntimeEntry(mode)) {
325     StaticVisitor::VisitRuntimeEntry(this);
326   }
327 }
328 
329 
330 
Immediate(int x)331 Immediate::Immediate(int x)  {
332   x_ = x;
333   rmode_ = RelocInfo::NONE32;
334 }
335 
336 
Immediate(const ExternalReference & ext)337 Immediate::Immediate(const ExternalReference& ext) {
338   x_ = reinterpret_cast<int32_t>(ext.address());
339   rmode_ = RelocInfo::EXTERNAL_REFERENCE;
340 }
341 
342 
Immediate(Label * internal_offset)343 Immediate::Immediate(Label* internal_offset) {
344   x_ = reinterpret_cast<int32_t>(internal_offset);
345   rmode_ = RelocInfo::INTERNAL_REFERENCE;
346 }
347 
348 
Immediate(Handle<Object> handle)349 Immediate::Immediate(Handle<Object> handle) {
350   AllowDeferredHandleDereference using_raw_address;
351   // Verify all Objects referred by code are NOT in new space.
352   Object* obj = *handle;
353   if (obj->IsHeapObject()) {
354     DCHECK(!HeapObject::cast(obj)->GetHeap()->InNewSpace(obj));
355     x_ = reinterpret_cast<intptr_t>(handle.location());
356     rmode_ = RelocInfo::EMBEDDED_OBJECT;
357   } else {
358     // no relocation needed
359     x_ =  reinterpret_cast<intptr_t>(obj);
360     rmode_ = RelocInfo::NONE32;
361   }
362 }
363 
364 
Immediate(Smi * value)365 Immediate::Immediate(Smi* value) {
366   x_ = reinterpret_cast<intptr_t>(value);
367   rmode_ = RelocInfo::NONE32;
368 }
369 
370 
Immediate(Address addr)371 Immediate::Immediate(Address addr) {
372   x_ = reinterpret_cast<int32_t>(addr);
373   rmode_ = RelocInfo::NONE32;
374 }
375 
376 
emit(uint32_t x)377 void Assembler::emit(uint32_t x) {
378   *reinterpret_cast<uint32_t*>(pc_) = x;
379   pc_ += sizeof(uint32_t);
380 }
381 
382 
emit_q(uint64_t x)383 void Assembler::emit_q(uint64_t x) {
384   *reinterpret_cast<uint64_t*>(pc_) = x;
385   pc_ += sizeof(uint64_t);
386 }
387 
388 
emit(Handle<Object> handle)389 void Assembler::emit(Handle<Object> handle) {
390   AllowDeferredHandleDereference heap_object_check;
391   // Verify all Objects referred by code are NOT in new space.
392   Object* obj = *handle;
393   DCHECK(!isolate()->heap()->InNewSpace(obj));
394   if (obj->IsHeapObject()) {
395     emit(reinterpret_cast<intptr_t>(handle.location()),
396          RelocInfo::EMBEDDED_OBJECT);
397   } else {
398     // no relocation needed
399     emit(reinterpret_cast<intptr_t>(obj));
400   }
401 }
402 
403 
emit(uint32_t x,RelocInfo::Mode rmode,TypeFeedbackId id)404 void Assembler::emit(uint32_t x, RelocInfo::Mode rmode, TypeFeedbackId id) {
405   if (rmode == RelocInfo::CODE_TARGET && !id.IsNone()) {
406     RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID, id.ToInt());
407   } else if (!RelocInfo::IsNone(rmode)
408       && rmode != RelocInfo::CODE_AGE_SEQUENCE) {
409     RecordRelocInfo(rmode);
410   }
411   emit(x);
412 }
413 
414 
emit(Handle<Code> code,RelocInfo::Mode rmode,TypeFeedbackId id)415 void Assembler::emit(Handle<Code> code,
416                      RelocInfo::Mode rmode,
417                      TypeFeedbackId id) {
418   AllowDeferredHandleDereference embedding_raw_address;
419   emit(reinterpret_cast<intptr_t>(code.location()), rmode, id);
420 }
421 
422 
emit(const Immediate & x)423 void Assembler::emit(const Immediate& x) {
424   if (x.rmode_ == RelocInfo::INTERNAL_REFERENCE) {
425     Label* label = reinterpret_cast<Label*>(x.x_);
426     emit_code_relative_offset(label);
427     return;
428   }
429   if (!RelocInfo::IsNone(x.rmode_)) RecordRelocInfo(x.rmode_);
430   emit(x.x_);
431 }
432 
433 
emit_code_relative_offset(Label * label)434 void Assembler::emit_code_relative_offset(Label* label) {
435   if (label->is_bound()) {
436     int32_t pos;
437     pos = label->pos() + Code::kHeaderSize - kHeapObjectTag;
438     emit(pos);
439   } else {
440     emit_disp(label, Displacement::CODE_RELATIVE);
441   }
442 }
443 
444 
emit_w(const Immediate & x)445 void Assembler::emit_w(const Immediate& x) {
446   DCHECK(RelocInfo::IsNone(x.rmode_));
447   uint16_t value = static_cast<uint16_t>(x.x_);
448   reinterpret_cast<uint16_t*>(pc_)[0] = value;
449   pc_ += sizeof(uint16_t);
450 }
451 
452 
target_address_at(Address pc,Address constant_pool)453 Address Assembler::target_address_at(Address pc, Address constant_pool) {
454   return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc);
455 }
456 
457 
set_target_address_at(Isolate * isolate,Address pc,Address constant_pool,Address target,ICacheFlushMode icache_flush_mode)458 void Assembler::set_target_address_at(Isolate* isolate, Address pc,
459                                       Address constant_pool, Address target,
460                                       ICacheFlushMode icache_flush_mode) {
461   int32_t* p = reinterpret_cast<int32_t*>(pc);
462   *p = target - (pc + sizeof(int32_t));
463   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
464     Assembler::FlushICache(isolate, p, sizeof(int32_t));
465   }
466 }
467 
468 
target_address_from_return_address(Address pc)469 Address Assembler::target_address_from_return_address(Address pc) {
470   return pc - kCallTargetAddressOffset;
471 }
472 
473 
disp_at(Label * L)474 Displacement Assembler::disp_at(Label* L) {
475   return Displacement(long_at(L->pos()));
476 }
477 
478 
disp_at_put(Label * L,Displacement disp)479 void Assembler::disp_at_put(Label* L, Displacement disp) {
480   long_at_put(L->pos(), disp.data());
481 }
482 
483 
emit_disp(Label * L,Displacement::Type type)484 void Assembler::emit_disp(Label* L, Displacement::Type type) {
485   Displacement disp(L, type);
486   L->link_to(pc_offset());
487   emit(static_cast<int>(disp.data()));
488 }
489 
490 
emit_near_disp(Label * L)491 void Assembler::emit_near_disp(Label* L) {
492   byte disp = 0x00;
493   if (L->is_near_linked()) {
494     int offset = L->near_link_pos() - pc_offset();
495     DCHECK(is_int8(offset));
496     disp = static_cast<byte>(offset & 0xFF);
497   }
498   L->link_to(pc_offset(), Label::kNear);
499   *pc_++ = disp;
500 }
501 
502 
deserialization_set_target_internal_reference_at(Isolate * isolate,Address pc,Address target,RelocInfo::Mode mode)503 void Assembler::deserialization_set_target_internal_reference_at(
504     Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) {
505   Memory::Address_at(pc) = target;
506 }
507 
508 
set_modrm(int mod,Register rm)509 void Operand::set_modrm(int mod, Register rm) {
510   DCHECK((mod & -4) == 0);
511   buf_[0] = mod << 6 | rm.code();
512   len_ = 1;
513 }
514 
515 
set_sib(ScaleFactor scale,Register index,Register base)516 void Operand::set_sib(ScaleFactor scale, Register index, Register base) {
517   DCHECK(len_ == 1);
518   DCHECK((scale & -4) == 0);
519   // Use SIB with no index register only for base esp.
520   DCHECK(!index.is(esp) || base.is(esp));
521   buf_[1] = scale << 6 | index.code() << 3 | base.code();
522   len_ = 2;
523 }
524 
525 
set_disp8(int8_t disp)526 void Operand::set_disp8(int8_t disp) {
527   DCHECK(len_ == 1 || len_ == 2);
528   *reinterpret_cast<int8_t*>(&buf_[len_++]) = disp;
529 }
530 
531 
set_dispr(int32_t disp,RelocInfo::Mode rmode)532 void Operand::set_dispr(int32_t disp, RelocInfo::Mode rmode) {
533   DCHECK(len_ == 1 || len_ == 2);
534   int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]);
535   *p = disp;
536   len_ += sizeof(int32_t);
537   rmode_ = rmode;
538 }
539 
Operand(Register reg)540 Operand::Operand(Register reg) {
541   // reg
542   set_modrm(3, reg);
543 }
544 
545 
Operand(XMMRegister xmm_reg)546 Operand::Operand(XMMRegister xmm_reg) {
547   Register reg = { xmm_reg.code() };
548   set_modrm(3, reg);
549 }
550 
551 
Operand(int32_t disp,RelocInfo::Mode rmode)552 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) {
553   // [disp/r]
554   set_modrm(0, ebp);
555   set_dispr(disp, rmode);
556 }
557 
558 
Operand(Immediate imm)559 Operand::Operand(Immediate imm) {
560   // [disp/r]
561   set_modrm(0, ebp);
562   set_dispr(imm.x_, imm.rmode_);
563 }
564 }  // namespace internal
565 }  // namespace v8
566 
567 #endif  // V8_IA32_ASSEMBLER_IA32_INL_H_
568