Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 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. |
Ben Murdoch | c7cc028 | 2012-03-05 14:35:55 +0000 | [diff] [blame^] | 33 | // Copyright 2012 the V8 project authors. All rights reserved. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 34 | |
| 35 | |
| 36 | #ifndef V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
| 37 | #define V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
| 38 | |
| 39 | #include "mips/assembler-mips.h" |
Ben Murdoch | c7cc028 | 2012-03-05 14:35:55 +0000 | [diff] [blame^] | 40 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 41 | #include "cpu.h" |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 42 | #include "debug.h" |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | namespace v8 { |
| 46 | namespace internal { |
| 47 | |
| 48 | // ----------------------------------------------------------------------------- |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 49 | // Operand and MemOperand. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 50 | |
| 51 | Operand::Operand(int32_t immediate, RelocInfo::Mode rmode) { |
| 52 | rm_ = no_reg; |
| 53 | imm32_ = immediate; |
| 54 | rmode_ = rmode; |
| 55 | } |
| 56 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 57 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 58 | Operand::Operand(const ExternalReference& f) { |
| 59 | rm_ = no_reg; |
| 60 | imm32_ = reinterpret_cast<int32_t>(f.address()); |
| 61 | rmode_ = RelocInfo::EXTERNAL_REFERENCE; |
| 62 | } |
| 63 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 64 | |
| 65 | Operand::Operand(Smi* value) { |
| 66 | rm_ = no_reg; |
| 67 | imm32_ = reinterpret_cast<intptr_t>(value); |
| 68 | rmode_ = RelocInfo::NONE; |
| 69 | } |
| 70 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 71 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 72 | Operand::Operand(Register rm) { |
| 73 | rm_ = rm; |
| 74 | } |
| 75 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 76 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 77 | bool Operand::is_reg() const { |
| 78 | return rm_.is_valid(); |
| 79 | } |
| 80 | |
| 81 | |
Ben Murdoch | c7cc028 | 2012-03-05 14:35:55 +0000 | [diff] [blame^] | 82 | int FPURegister::ToAllocationIndex(FPURegister reg) { |
| 83 | ASSERT(reg.code() % 2 == 0); |
| 84 | ASSERT(reg.code() / 2 < kNumAllocatableRegisters); |
| 85 | ASSERT(reg.is_valid()); |
| 86 | ASSERT(!reg.is(kDoubleRegZero)); |
| 87 | ASSERT(!reg.is(kLithiumScratchDouble)); |
| 88 | return (reg.code() / 2); |
| 89 | } |
| 90 | |
| 91 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 92 | // ----------------------------------------------------------------------------- |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 93 | // RelocInfo. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 94 | |
| 95 | void RelocInfo::apply(intptr_t delta) { |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 96 | if (IsCodeTarget(rmode_)) { |
| 97 | uint32_t scope1 = (uint32_t) target_address() & ~kImm28Mask; |
| 98 | uint32_t scope2 = reinterpret_cast<uint32_t>(pc_) & ~kImm28Mask; |
| 99 | |
| 100 | if (scope1 != scope2) { |
| 101 | Assembler::JumpLabelToJumpRegister(pc_); |
| 102 | } |
| 103 | } |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 104 | if (IsInternalReference(rmode_)) { |
| 105 | // Absolute code pointer inside code object moves with the code object. |
| 106 | byte* p = reinterpret_cast<byte*>(pc_); |
| 107 | int count = Assembler::RelocateInternalReference(p, delta); |
| 108 | CPU::FlushICache(p, count * sizeof(uint32_t)); |
| 109 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | |
| 113 | Address RelocInfo::target_address() { |
| 114 | ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 115 | return Assembler::target_address_at(pc_); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | Address RelocInfo::target_address_address() { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 120 | ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 121 | return reinterpret_cast<Address>(pc_); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | |
| 125 | int RelocInfo::target_address_size() { |
| 126 | return Assembler::kExternalTargetSize; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 130 | void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 131 | ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 132 | Assembler::set_target_address_at(pc_, target); |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 133 | if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { |
| 134 | Object* target_code = Code::GetCodeFromTargetAddress(target); |
| 135 | host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
| 136 | host(), this, HeapObject::cast(target_code)); |
| 137 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | |
| 141 | Object* RelocInfo::target_object() { |
| 142 | ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 143 | return reinterpret_cast<Object*>(Assembler::target_address_at(pc_)); |
| 144 | } |
| 145 | |
| 146 | |
Ben Murdoch | c7cc028 | 2012-03-05 14:35:55 +0000 | [diff] [blame^] | 147 | Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 148 | ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 149 | return Handle<Object>(reinterpret_cast<Object**>( |
| 150 | Assembler::target_address_at(pc_))); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | Object** RelocInfo::target_object_address() { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 155 | // Provide a "natural pointer" to the embedded object, |
| 156 | // which can be de-referenced during heap iteration. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 157 | ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 158 | reconstructed_obj_ptr_ = |
| 159 | reinterpret_cast<Object*>(Assembler::target_address_at(pc_)); |
| 160 | return &reconstructed_obj_ptr_; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 164 | void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 165 | ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 166 | Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target)); |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 167 | if (mode == UPDATE_WRITE_BARRIER && |
| 168 | host() != NULL && |
| 169 | target->IsHeapObject()) { |
| 170 | host()->GetHeap()->incremental_marking()->RecordWrite( |
| 171 | host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
| 172 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | |
| 176 | Address* RelocInfo::target_reference_address() { |
| 177 | ASSERT(rmode_ == EXTERNAL_REFERENCE); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 178 | reconstructed_adr_ptr_ = Assembler::target_address_at(pc_); |
| 179 | return &reconstructed_adr_ptr_; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | |
| 183 | Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| 184 | ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 185 | Address address = Memory::Address_at(pc_); |
| 186 | return Handle<JSGlobalPropertyCell>( |
| 187 | reinterpret_cast<JSGlobalPropertyCell**>(address)); |
| 188 | } |
| 189 | |
| 190 | |
| 191 | JSGlobalPropertyCell* RelocInfo::target_cell() { |
| 192 | ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 193 | Address address = Memory::Address_at(pc_); |
| 194 | Object* object = HeapObject::FromAddress( |
| 195 | address - JSGlobalPropertyCell::kValueOffset); |
| 196 | return reinterpret_cast<JSGlobalPropertyCell*>(object); |
| 197 | } |
| 198 | |
| 199 | |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 200 | void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell, |
| 201 | WriteBarrierMode mode) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 202 | ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 203 | Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; |
| 204 | Memory::Address_at(pc_) = address; |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 205 | if (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 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | |
| 214 | Address RelocInfo::call_address() { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 215 | ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
| 216 | (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
| 217 | // The pc_ offset of 0 assumes mips patched return sequence per |
| 218 | // debug-mips.cc BreakLocationIterator::SetDebugBreakAtReturn(), or |
| 219 | // debug break slot per BreakLocationIterator::SetDebugBreakAtSlot(). |
| 220 | return Assembler::target_address_at(pc_); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | |
| 224 | void RelocInfo::set_call_address(Address target) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 225 | ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
| 226 | (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
| 227 | // The pc_ offset of 0 assumes mips patched return sequence per |
| 228 | // debug-mips.cc BreakLocationIterator::SetDebugBreakAtReturn(), or |
| 229 | // debug break slot per BreakLocationIterator::SetDebugBreakAtSlot(). |
| 230 | Assembler::set_target_address_at(pc_, target); |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 231 | if (host() != NULL) { |
| 232 | Object* target_code = Code::GetCodeFromTargetAddress(target); |
| 233 | host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
| 234 | host(), this, HeapObject::cast(target_code)); |
| 235 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | |
| 239 | Object* RelocInfo::call_object() { |
| 240 | return *call_object_address(); |
| 241 | } |
| 242 | |
| 243 | |
| 244 | Object** RelocInfo::call_object_address() { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 245 | ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
| 246 | (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 247 | return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); |
| 248 | } |
| 249 | |
| 250 | |
| 251 | void RelocInfo::set_call_object(Object* target) { |
| 252 | *call_object_address() = target; |
| 253 | } |
| 254 | |
| 255 | |
| 256 | bool RelocInfo::IsPatchedReturnSequence() { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 257 | Instr instr0 = Assembler::instr_at(pc_); |
| 258 | Instr instr1 = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); |
| 259 | Instr instr2 = Assembler::instr_at(pc_ + 2 * Assembler::kInstrSize); |
| 260 | bool patched_return = ((instr0 & kOpcodeMask) == LUI && |
| 261 | (instr1 & kOpcodeMask) == ORI && |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 262 | ((instr2 & kOpcodeMask) == JAL || |
| 263 | ((instr2 & kOpcodeMask) == SPECIAL && |
| 264 | (instr2 & kFunctionFieldMask) == JALR))); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 265 | return patched_return; |
| 266 | } |
| 267 | |
| 268 | |
| 269 | bool RelocInfo::IsPatchedDebugBreakSlotSequence() { |
| 270 | Instr current_instr = Assembler::instr_at(pc_); |
| 271 | return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | void RelocInfo::Visit(ObjectVisitor* visitor) { |
| 276 | RelocInfo::Mode mode = rmode(); |
| 277 | if (mode == RelocInfo::EMBEDDED_OBJECT) { |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 278 | visitor->VisitEmbeddedPointer(this); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 279 | } else if (RelocInfo::IsCodeTarget(mode)) { |
| 280 | visitor->VisitCodeTarget(this); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 281 | } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 282 | visitor->VisitGlobalPropertyCell(this); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 283 | } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 284 | visitor->VisitExternalReference(target_reference_address()); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 285 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 286 | // TODO(isolates): Get a cached isolate below. |
| 287 | } else if (((RelocInfo::IsJSReturn(mode) && |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 288 | IsPatchedReturnSequence()) || |
| 289 | (RelocInfo::IsDebugBreakSlot(mode) && |
| 290 | IsPatchedDebugBreakSlotSequence())) && |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 291 | Isolate::Current()->debug()->has_break_points()) { |
| 292 | visitor->VisitDebugTarget(this); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 293 | #endif |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 294 | } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 295 | visitor->VisitRuntimeEntry(this); |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | |
| 300 | template<typename StaticVisitor> |
| 301 | void RelocInfo::Visit(Heap* heap) { |
| 302 | RelocInfo::Mode mode = rmode(); |
| 303 | if (mode == RelocInfo::EMBEDDED_OBJECT) { |
Ben Murdoch | 592a9fc | 2012-03-05 11:04:45 +0000 | [diff] [blame] | 304 | StaticVisitor::VisitEmbeddedPointer(heap, this); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 305 | } else if (RelocInfo::IsCodeTarget(mode)) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 306 | StaticVisitor::VisitCodeTarget(heap, this); |
| 307 | } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 308 | StaticVisitor::VisitGlobalPropertyCell(heap, this); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 309 | } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
| 310 | StaticVisitor::VisitExternalReference(target_reference_address()); |
| 311 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 312 | } else if (heap->isolate()->debug()->has_break_points() && |
| 313 | ((RelocInfo::IsJSReturn(mode) && |
| 314 | IsPatchedReturnSequence()) || |
| 315 | (RelocInfo::IsDebugBreakSlot(mode) && |
| 316 | IsPatchedDebugBreakSlotSequence()))) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 317 | StaticVisitor::VisitDebugTarget(heap, this); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 318 | #endif |
| 319 | } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 320 | StaticVisitor::VisitRuntimeEntry(this); |
| 321 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | |
| 325 | // ----------------------------------------------------------------------------- |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 326 | // Assembler. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 327 | |
| 328 | |
| 329 | void Assembler::CheckBuffer() { |
| 330 | if (buffer_space() <= kGap) { |
| 331 | GrowBuffer(); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 336 | void Assembler::CheckTrampolinePoolQuick() { |
| 337 | if (pc_offset() >= next_buffer_check_) { |
| 338 | CheckTrampolinePool(); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 343 | void Assembler::emit(Instr x) { |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 344 | if (!is_buffer_growth_blocked()) { |
| 345 | CheckBuffer(); |
| 346 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 347 | *reinterpret_cast<Instr*>(pc_) = x; |
| 348 | pc_ += kInstrSize; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 349 | CheckTrampolinePoolQuick(); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | |
| 353 | } } // namespace v8::internal |
| 354 | |
| 355 | #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |