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