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_X87_ASSEMBLER_X87_INL_H_
38 #define V8_X87_ASSEMBLER_X87_INL_H_
39 
40 #include "src/x87/assembler-x87.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   Assembler::set_target_address_at(isolate_, pc_, host_, target);
110   DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
111   if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL &&
112       IsCodeTarget(rmode_)) {
113     Object* target_code = Code::GetCodeFromTargetAddress(target);
114     host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
115         host(), this, HeapObject::cast(target_code));
116   }
117 }
118 
119 
target_object()120 Object* RelocInfo::target_object() {
121   DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
122   return Memory::Object_at(pc_);
123 }
124 
125 
target_object_handle(Assembler * origin)126 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) {
127   DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
128   return Memory::Object_Handle_at(pc_);
129 }
130 
131 
set_target_object(Object * target,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)132 void RelocInfo::set_target_object(Object* target,
133                                   WriteBarrierMode write_barrier_mode,
134                                   ICacheFlushMode icache_flush_mode) {
135   DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
136   Memory::Object_at(pc_) = target;
137   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
138     Assembler::FlushICache(isolate_, pc_, sizeof(Address));
139   }
140   if (write_barrier_mode == UPDATE_WRITE_BARRIER &&
141       host() != NULL &&
142       target->IsHeapObject()) {
143     host()->GetHeap()->incremental_marking()->RecordWrite(
144         host(), &Memory::Object_at(pc_), HeapObject::cast(target));
145   }
146 }
147 
148 
target_external_reference()149 Address RelocInfo::target_external_reference() {
150   DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
151   return Memory::Address_at(pc_);
152 }
153 
154 
target_internal_reference()155 Address RelocInfo::target_internal_reference() {
156   DCHECK(rmode_ == INTERNAL_REFERENCE);
157   return Memory::Address_at(pc_);
158 }
159 
160 
target_internal_reference_address()161 Address RelocInfo::target_internal_reference_address() {
162   DCHECK(rmode_ == INTERNAL_REFERENCE);
163   return reinterpret_cast<Address>(pc_);
164 }
165 
166 
target_runtime_entry(Assembler * origin)167 Address RelocInfo::target_runtime_entry(Assembler* origin) {
168   DCHECK(IsRuntimeEntry(rmode_));
169   return reinterpret_cast<Address>(*reinterpret_cast<int32_t*>(pc_));
170 }
171 
172 
set_target_runtime_entry(Address target,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)173 void RelocInfo::set_target_runtime_entry(Address target,
174                                          WriteBarrierMode write_barrier_mode,
175                                          ICacheFlushMode icache_flush_mode) {
176   DCHECK(IsRuntimeEntry(rmode_));
177   if (target_address() != target) {
178     set_target_address(target, write_barrier_mode, icache_flush_mode);
179   }
180 }
181 
182 
target_cell_handle()183 Handle<Cell> RelocInfo::target_cell_handle() {
184   DCHECK(rmode_ == RelocInfo::CELL);
185   Address address = Memory::Address_at(pc_);
186   return Handle<Cell>(reinterpret_cast<Cell**>(address));
187 }
188 
189 
target_cell()190 Cell* RelocInfo::target_cell() {
191   DCHECK(rmode_ == RelocInfo::CELL);
192   return Cell::FromValueAddress(Memory::Address_at(pc_));
193 }
194 
195 
set_target_cell(Cell * cell,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)196 void RelocInfo::set_target_cell(Cell* cell,
197                                 WriteBarrierMode write_barrier_mode,
198                                 ICacheFlushMode icache_flush_mode) {
199   DCHECK(cell->IsCell());
200   DCHECK(rmode_ == RelocInfo::CELL);
201   Address address = cell->address() + Cell::kValueOffset;
202   Memory::Address_at(pc_) = address;
203   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
204     Assembler::FlushICache(isolate_, pc_, sizeof(Address));
205   }
206   if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
207     // TODO(1550) We are passing NULL as a slot because cell can never be on
208     // evacuation candidate.
209     host()->GetHeap()->incremental_marking()->RecordWrite(
210         host(), NULL, cell);
211   }
212 }
213 
214 
code_age_stub_handle(Assembler * origin)215 Handle<Object> RelocInfo::code_age_stub_handle(Assembler* origin) {
216   DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
217   DCHECK(*pc_ == kCallOpcode);
218   return Memory::Object_Handle_at(pc_ + 1);
219 }
220 
221 
code_age_stub()222 Code* RelocInfo::code_age_stub() {
223   DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
224   DCHECK(*pc_ == kCallOpcode);
225   return Code::GetCodeFromTargetAddress(
226       Assembler::target_address_at(pc_ + 1, host_));
227 }
228 
229 
set_code_age_stub(Code * stub,ICacheFlushMode icache_flush_mode)230 void RelocInfo::set_code_age_stub(Code* stub,
231                                   ICacheFlushMode icache_flush_mode) {
232   DCHECK(*pc_ == kCallOpcode);
233   DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
234   Assembler::set_target_address_at(
235       isolate_, pc_ + 1, host_, stub->instruction_start(), icache_flush_mode);
236 }
237 
238 
debug_call_address()239 Address RelocInfo::debug_call_address() {
240   DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
241   Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset;
242   return Assembler::target_address_at(location, host_);
243 }
244 
245 
set_debug_call_address(Address target)246 void RelocInfo::set_debug_call_address(Address target) {
247   DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
248   Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset;
249   Assembler::set_target_address_at(isolate_, location, host_, target);
250   if (host() != NULL) {
251     Object* target_code = Code::GetCodeFromTargetAddress(target);
252     host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
253         host(), this, HeapObject::cast(target_code));
254   }
255 }
256 
257 
WipeOut()258 void RelocInfo::WipeOut() {
259   if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) ||
260       IsInternalReference(rmode_)) {
261     Memory::Address_at(pc_) = NULL;
262   } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) {
263     // Effectively write zero into the relocation.
264     Assembler::set_target_address_at(isolate_, pc_, host_,
265                                      pc_ + sizeof(int32_t));
266   } else {
267     UNREACHABLE();
268   }
269 }
270 
271 
IsPatchedReturnSequence()272 bool RelocInfo::IsPatchedReturnSequence() {
273   return *pc_ == kCallOpcode;
274 }
275 
276 
IsPatchedDebugBreakSlotSequence()277 bool RelocInfo::IsPatchedDebugBreakSlotSequence() {
278   return !Assembler::IsNop(pc());
279 }
280 
281 
Visit(Isolate * isolate,ObjectVisitor * visitor)282 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) {
283   RelocInfo::Mode mode = rmode();
284   if (mode == RelocInfo::EMBEDDED_OBJECT) {
285     visitor->VisitEmbeddedPointer(this);
286     Assembler::FlushICache(isolate, pc_, sizeof(Address));
287   } else if (RelocInfo::IsCodeTarget(mode)) {
288     visitor->VisitCodeTarget(this);
289   } else if (mode == RelocInfo::CELL) {
290     visitor->VisitCell(this);
291   } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
292     visitor->VisitExternalReference(this);
293   } else if (mode == RelocInfo::INTERNAL_REFERENCE) {
294     visitor->VisitInternalReference(this);
295   } else if (RelocInfo::IsCodeAgeSequence(mode)) {
296     visitor->VisitCodeAgeSequence(this);
297   } else if (RelocInfo::IsDebugBreakSlot(mode) &&
298              IsPatchedDebugBreakSlotSequence()) {
299     visitor->VisitDebugTarget(this);
300   } else if (IsRuntimeEntry(mode)) {
301     visitor->VisitRuntimeEntry(this);
302   }
303 }
304 
305 
306 template<typename StaticVisitor>
Visit(Heap * heap)307 void RelocInfo::Visit(Heap* heap) {
308   RelocInfo::Mode mode = rmode();
309   if (mode == RelocInfo::EMBEDDED_OBJECT) {
310     StaticVisitor::VisitEmbeddedPointer(heap, this);
311     Assembler::FlushICache(heap->isolate(), pc_, sizeof(Address));
312   } else if (RelocInfo::IsCodeTarget(mode)) {
313     StaticVisitor::VisitCodeTarget(heap, this);
314   } else if (mode == RelocInfo::CELL) {
315     StaticVisitor::VisitCell(heap, this);
316   } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
317     StaticVisitor::VisitExternalReference(this);
318   } else if (mode == RelocInfo::INTERNAL_REFERENCE) {
319     StaticVisitor::VisitInternalReference(this);
320   } else if (RelocInfo::IsCodeAgeSequence(mode)) {
321     StaticVisitor::VisitCodeAgeSequence(heap, this);
322   } else if (RelocInfo::IsDebugBreakSlot(mode) &&
323              IsPatchedDebugBreakSlotSequence()) {
324     StaticVisitor::VisitDebugTarget(heap, this);
325   } else if (IsRuntimeEntry(mode)) {
326     StaticVisitor::VisitRuntimeEntry(this);
327   }
328 }
329 
330 
331 
Immediate(int x)332 Immediate::Immediate(int x)  {
333   x_ = x;
334   rmode_ = RelocInfo::NONE32;
335 }
336 
337 
Immediate(const ExternalReference & ext)338 Immediate::Immediate(const ExternalReference& ext) {
339   x_ = reinterpret_cast<int32_t>(ext.address());
340   rmode_ = RelocInfo::EXTERNAL_REFERENCE;
341 }
342 
343 
Immediate(Label * internal_offset)344 Immediate::Immediate(Label* internal_offset) {
345   x_ = reinterpret_cast<int32_t>(internal_offset);
346   rmode_ = RelocInfo::INTERNAL_REFERENCE;
347 }
348 
349 
Immediate(Handle<Object> handle)350 Immediate::Immediate(Handle<Object> handle) {
351   AllowDeferredHandleDereference using_raw_address;
352   // Verify all Objects referred by code are NOT in new space.
353   Object* obj = *handle;
354   if (obj->IsHeapObject()) {
355     DCHECK(!HeapObject::cast(obj)->GetHeap()->InNewSpace(obj));
356     x_ = reinterpret_cast<intptr_t>(handle.location());
357     rmode_ = RelocInfo::EMBEDDED_OBJECT;
358   } else {
359     // no relocation needed
360     x_ =  reinterpret_cast<intptr_t>(obj);
361     rmode_ = RelocInfo::NONE32;
362   }
363 }
364 
365 
Immediate(Smi * value)366 Immediate::Immediate(Smi* value) {
367   x_ = reinterpret_cast<intptr_t>(value);
368   rmode_ = RelocInfo::NONE32;
369 }
370 
371 
Immediate(Address addr)372 Immediate::Immediate(Address addr) {
373   x_ = reinterpret_cast<int32_t>(addr);
374   rmode_ = RelocInfo::NONE32;
375 }
376 
377 
emit(uint32_t x)378 void Assembler::emit(uint32_t x) {
379   *reinterpret_cast<uint32_t*>(pc_) = x;
380   pc_ += sizeof(uint32_t);
381 }
382 
383 
emit_q(uint64_t x)384 void Assembler::emit_q(uint64_t x) {
385   *reinterpret_cast<uint64_t*>(pc_) = x;
386   pc_ += sizeof(uint64_t);
387 }
388 
389 
emit(Handle<Object> handle)390 void Assembler::emit(Handle<Object> handle) {
391   AllowDeferredHandleDereference heap_object_check;
392   // Verify all Objects referred by code are NOT in new space.
393   Object* obj = *handle;
394   DCHECK(!isolate()->heap()->InNewSpace(obj));
395   if (obj->IsHeapObject()) {
396     emit(reinterpret_cast<intptr_t>(handle.location()),
397          RelocInfo::EMBEDDED_OBJECT);
398   } else {
399     // no relocation needed
400     emit(reinterpret_cast<intptr_t>(obj));
401   }
402 }
403 
404 
emit(uint32_t x,RelocInfo::Mode rmode,TypeFeedbackId id)405 void Assembler::emit(uint32_t x, RelocInfo::Mode rmode, TypeFeedbackId id) {
406   if (rmode == RelocInfo::CODE_TARGET && !id.IsNone()) {
407     RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID, id.ToInt());
408   } else if (!RelocInfo::IsNone(rmode)
409       && rmode != RelocInfo::CODE_AGE_SEQUENCE) {
410     RecordRelocInfo(rmode);
411   }
412   emit(x);
413 }
414 
415 
emit(Handle<Code> code,RelocInfo::Mode rmode,TypeFeedbackId id)416 void Assembler::emit(Handle<Code> code,
417                      RelocInfo::Mode rmode,
418                      TypeFeedbackId id) {
419   AllowDeferredHandleDereference embedding_raw_address;
420   emit(reinterpret_cast<intptr_t>(code.location()), rmode, id);
421 }
422 
423 
emit(const Immediate & x)424 void Assembler::emit(const Immediate& x) {
425   if (x.rmode_ == RelocInfo::INTERNAL_REFERENCE) {
426     Label* label = reinterpret_cast<Label*>(x.x_);
427     emit_code_relative_offset(label);
428     return;
429   }
430   if (!RelocInfo::IsNone(x.rmode_)) RecordRelocInfo(x.rmode_);
431   emit(x.x_);
432 }
433 
434 
emit_code_relative_offset(Label * label)435 void Assembler::emit_code_relative_offset(Label* label) {
436   if (label->is_bound()) {
437     int32_t pos;
438     pos = label->pos() + Code::kHeaderSize - kHeapObjectTag;
439     emit(pos);
440   } else {
441     emit_disp(label, Displacement::CODE_RELATIVE);
442   }
443 }
444 
445 
emit_w(const Immediate & x)446 void Assembler::emit_w(const Immediate& x) {
447   DCHECK(RelocInfo::IsNone(x.rmode_));
448   uint16_t value = static_cast<uint16_t>(x.x_);
449   reinterpret_cast<uint16_t*>(pc_)[0] = value;
450   pc_ += sizeof(uint16_t);
451 }
452 
453 
target_address_at(Address pc,Address constant_pool)454 Address Assembler::target_address_at(Address pc, Address constant_pool) {
455   return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc);
456 }
457 
458 
set_target_address_at(Isolate * isolate,Address pc,Address constant_pool,Address target,ICacheFlushMode icache_flush_mode)459 void Assembler::set_target_address_at(Isolate* isolate, Address pc,
460                                       Address constant_pool, Address target,
461                                       ICacheFlushMode icache_flush_mode) {
462   int32_t* p = reinterpret_cast<int32_t*>(pc);
463   *p = target - (pc + sizeof(int32_t));
464   if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
465     Assembler::FlushICache(isolate, p, sizeof(int32_t));
466   }
467 }
468 
469 
target_address_from_return_address(Address pc)470 Address Assembler::target_address_from_return_address(Address pc) {
471   return pc - kCallTargetAddressOffset;
472 }
473 
474 
disp_at(Label * L)475 Displacement Assembler::disp_at(Label* L) {
476   return Displacement(long_at(L->pos()));
477 }
478 
479 
disp_at_put(Label * L,Displacement disp)480 void Assembler::disp_at_put(Label* L, Displacement disp) {
481   long_at_put(L->pos(), disp.data());
482 }
483 
484 
emit_disp(Label * L,Displacement::Type type)485 void Assembler::emit_disp(Label* L, Displacement::Type type) {
486   Displacement disp(L, type);
487   L->link_to(pc_offset());
488   emit(static_cast<int>(disp.data()));
489 }
490 
491 
emit_near_disp(Label * L)492 void Assembler::emit_near_disp(Label* L) {
493   byte disp = 0x00;
494   if (L->is_near_linked()) {
495     int offset = L->near_link_pos() - pc_offset();
496     DCHECK(is_int8(offset));
497     disp = static_cast<byte>(offset & 0xFF);
498   }
499   L->link_to(pc_offset(), Label::kNear);
500   *pc_++ = disp;
501 }
502 
503 
deserialization_set_target_internal_reference_at(Isolate * isolate,Address pc,Address target,RelocInfo::Mode mode)504 void Assembler::deserialization_set_target_internal_reference_at(
505     Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) {
506   Memory::Address_at(pc) = target;
507 }
508 
509 
set_modrm(int mod,Register rm)510 void Operand::set_modrm(int mod, Register rm) {
511   DCHECK((mod & -4) == 0);
512   buf_[0] = mod << 6 | rm.code();
513   len_ = 1;
514 }
515 
516 
set_sib(ScaleFactor scale,Register index,Register base)517 void Operand::set_sib(ScaleFactor scale, Register index, Register base) {
518   DCHECK(len_ == 1);
519   DCHECK((scale & -4) == 0);
520   // Use SIB with no index register only for base esp.
521   DCHECK(!index.is(esp) || base.is(esp));
522   buf_[1] = scale << 6 | index.code() << 3 | base.code();
523   len_ = 2;
524 }
525 
526 
set_disp8(int8_t disp)527 void Operand::set_disp8(int8_t disp) {
528   DCHECK(len_ == 1 || len_ == 2);
529   *reinterpret_cast<int8_t*>(&buf_[len_++]) = disp;
530 }
531 
532 
set_dispr(int32_t disp,RelocInfo::Mode rmode)533 void Operand::set_dispr(int32_t disp, RelocInfo::Mode rmode) {
534   DCHECK(len_ == 1 || len_ == 2);
535   int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]);
536   *p = disp;
537   len_ += sizeof(int32_t);
538   rmode_ = rmode;
539 }
540 
Operand(Register reg)541 Operand::Operand(Register reg) {
542   // reg
543   set_modrm(3, reg);
544 }
545 
546 
Operand(int32_t disp,RelocInfo::Mode rmode)547 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) {
548   // [disp/r]
549   set_modrm(0, ebp);
550   set_dispr(disp, rmode);
551 }
552 
553 
Operand(Immediate imm)554 Operand::Operand(Immediate imm) {
555   // [disp/r]
556   set_modrm(0, ebp);
557   set_dispr(imm.x_, imm.rmode_);
558 }
559 }  // namespace internal
560 }  // namespace v8
561 
562 #endif  // V8_X87_ASSEMBLER_X87_INL_H_
563