OLD | NEW |
1 | 1 |
2 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 2 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
3 // All Rights Reserved. | 3 // All Rights Reserved. |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // - Redistributions of source code must retain the above copyright notice, | 9 // - Redistributions of source code must retain the above copyright notice, |
10 // this list of conditions and the following disclaimer. | 10 // this list of conditions and the following disclaimer. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (IsInternalReference(rmode_)) { | 132 if (IsInternalReference(rmode_)) { |
133 // Absolute code pointer inside code object moves with the code object. | 133 // Absolute code pointer inside code object moves with the code object. |
134 byte* p = reinterpret_cast<byte*>(pc_); | 134 byte* p = reinterpret_cast<byte*>(pc_); |
135 int count = Assembler::RelocateInternalReference(p, delta); | 135 int count = Assembler::RelocateInternalReference(p, delta); |
136 CPU::FlushICache(p, count * sizeof(uint32_t)); | 136 CPU::FlushICache(p, count * sizeof(uint32_t)); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 Address RelocInfo::target_address() { | 141 Address RelocInfo::target_address() { |
142 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 142 ASSERT(IsCodeTarget(rmode_) || rmode_ == EXTERNAL_REFERENCE); |
143 return Assembler::target_address_at(pc_); | 143 return Assembler::target_address_at(pc_); |
144 } | 144 } |
145 | 145 |
146 | 146 |
147 Address RelocInfo::target_address_address() { | 147 Address RelocInfo::target_address_address() { |
148 ASSERT(IsCodeTarget(rmode_) || | 148 ASSERT(IsCodeTarget(rmode_) || |
149 rmode_ == RUNTIME_ENTRY || | |
150 rmode_ == EMBEDDED_OBJECT || | 149 rmode_ == EMBEDDED_OBJECT || |
151 rmode_ == EXTERNAL_REFERENCE); | 150 rmode_ == EXTERNAL_REFERENCE); |
152 // Read the address of the word containing the target_address in an | 151 // Read the address of the word containing the target_address in an |
153 // instruction stream. | 152 // instruction stream. |
154 // The only architecture-independent user of this function is the serializer. | 153 // The only architecture-independent user of this function is the serializer. |
155 // The serializer uses it to find out how many raw bytes of instruction to | 154 // The serializer uses it to find out how many raw bytes of instruction to |
156 // output before the next target. | 155 // output before the next target. |
157 // For an instruction like LUI/ORI where the target bits are mixed into the | 156 // For an instruction like LUI/ORI where the target bits are mixed into the |
158 // instruction bits, the size of the target will be zero, indicating that the | 157 // instruction bits, the size of the target will be zero, indicating that the |
159 // serializer should not step forward in memory after a target is resolved | 158 // serializer should not step forward in memory after a target is resolved |
160 // and written. In this case the target_address_address function should | 159 // and written. In this case the target_address_address function should |
161 // return the end of the instructions to be patched, allowing the | 160 // return the end of the instructions to be patched, allowing the |
162 // deserializer to deserialize the instructions as raw bytes and put them in | 161 // deserializer to deserialize the instructions as raw bytes and put them in |
163 // place, ready to be patched with the target. After jump optimization, | 162 // place, ready to be patched with the target. After jump optimization, |
164 // that is the address of the instruction that follows J/JAL/JR/JALR | 163 // that is the address of the instruction that follows J/JAL/JR/JALR |
165 // instruction. | 164 // instruction. |
166 return reinterpret_cast<Address>( | 165 return reinterpret_cast<Address>( |
167 pc_ + Assembler::kInstructionsFor32BitConstant * Assembler::kInstrSize); | 166 pc_ + Assembler::kInstructionsFor32BitConstant * Assembler::kInstrSize); |
168 } | 167 } |
169 | 168 |
170 | 169 |
171 int RelocInfo::target_address_size() { | 170 int RelocInfo::target_address_size() { |
172 return Assembler::kSpecialTargetSize; | 171 return Assembler::kSpecialTargetSize; |
173 } | 172 } |
174 | 173 |
175 | 174 |
176 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { | 175 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { |
177 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 176 ASSERT(IsCodeTarget(rmode_) || rmode_ == EXTERNAL_REFERENCE); |
178 Assembler::set_target_address_at(pc_, target); | 177 Assembler::set_target_address_at(pc_, target); |
179 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { | 178 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { |
180 Object* target_code = Code::GetCodeFromTargetAddress(target); | 179 Object* target_code = Code::GetCodeFromTargetAddress(target); |
181 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 180 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
182 host(), this, HeapObject::cast(target_code)); | 181 host(), this, HeapObject::cast(target_code)); |
183 } | 182 } |
184 } | 183 } |
185 | 184 |
186 | 185 |
187 Address Assembler::target_address_from_return_address(Address pc) { | 186 Address Assembler::target_address_from_return_address(Address pc) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 #ifdef ENABLE_DEBUGGER_SUPPORT | 352 #ifdef ENABLE_DEBUGGER_SUPPORT |
354 // TODO(isolates): Get a cached isolate below. | 353 // TODO(isolates): Get a cached isolate below. |
355 } else if (((RelocInfo::IsJSReturn(mode) && | 354 } else if (((RelocInfo::IsJSReturn(mode) && |
356 IsPatchedReturnSequence()) || | 355 IsPatchedReturnSequence()) || |
357 (RelocInfo::IsDebugBreakSlot(mode) && | 356 (RelocInfo::IsDebugBreakSlot(mode) && |
358 IsPatchedDebugBreakSlotSequence())) && | 357 IsPatchedDebugBreakSlotSequence())) && |
359 Isolate::Current()->debug()->has_break_points()) { | 358 Isolate::Current()->debug()->has_break_points()) { |
360 visitor->VisitDebugTarget(this); | 359 visitor->VisitDebugTarget(this); |
361 #endif | 360 #endif |
362 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 361 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 362 UNREACHABLE(); |
363 visitor->VisitRuntimeEntry(this); | 363 visitor->VisitRuntimeEntry(this); |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 | 367 |
368 template<typename StaticVisitor> | 368 template<typename StaticVisitor> |
369 void RelocInfo::Visit(Heap* heap) { | 369 void RelocInfo::Visit(Heap* heap) { |
370 RelocInfo::Mode mode = rmode(); | 370 RelocInfo::Mode mode = rmode(); |
371 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 371 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
372 StaticVisitor::VisitEmbeddedPointer(heap, this); | 372 StaticVisitor::VisitEmbeddedPointer(heap, this); |
373 } else if (RelocInfo::IsCodeTarget(mode)) { | 373 } else if (RelocInfo::IsCodeTarget(mode)) { |
374 StaticVisitor::VisitCodeTarget(heap, this); | 374 StaticVisitor::VisitCodeTarget(heap, this); |
375 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 375 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
376 StaticVisitor::VisitGlobalPropertyCell(heap, this); | 376 StaticVisitor::VisitGlobalPropertyCell(heap, this); |
377 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 377 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
378 StaticVisitor::VisitExternalReference(this); | 378 StaticVisitor::VisitExternalReference(this); |
379 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 379 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
380 StaticVisitor::VisitCodeAgeSequence(heap, this); | 380 StaticVisitor::VisitCodeAgeSequence(heap, this); |
381 #ifdef ENABLE_DEBUGGER_SUPPORT | 381 #ifdef ENABLE_DEBUGGER_SUPPORT |
382 } else if (heap->isolate()->debug()->has_break_points() && | 382 } else if (heap->isolate()->debug()->has_break_points() && |
383 ((RelocInfo::IsJSReturn(mode) && | 383 ((RelocInfo::IsJSReturn(mode) && |
384 IsPatchedReturnSequence()) || | 384 IsPatchedReturnSequence()) || |
385 (RelocInfo::IsDebugBreakSlot(mode) && | 385 (RelocInfo::IsDebugBreakSlot(mode) && |
386 IsPatchedDebugBreakSlotSequence()))) { | 386 IsPatchedDebugBreakSlotSequence()))) { |
387 StaticVisitor::VisitDebugTarget(heap, this); | 387 StaticVisitor::VisitDebugTarget(heap, this); |
388 #endif | 388 #endif |
389 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 389 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 390 UNREACHABLE(); |
390 StaticVisitor::VisitRuntimeEntry(this); | 391 StaticVisitor::VisitRuntimeEntry(this); |
391 } | 392 } |
392 } | 393 } |
393 | 394 |
394 | 395 |
395 // ----------------------------------------------------------------------------- | 396 // ----------------------------------------------------------------------------- |
396 // Assembler. | 397 // Assembler. |
397 | 398 |
398 | 399 |
399 void Assembler::CheckBuffer() { | 400 void Assembler::CheckBuffer() { |
(...skipping 16 matching lines...) Expand all Loading... |
416 } | 417 } |
417 *reinterpret_cast<Instr*>(pc_) = x; | 418 *reinterpret_cast<Instr*>(pc_) = x; |
418 pc_ += kInstrSize; | 419 pc_ += kInstrSize; |
419 CheckTrampolinePoolQuick(); | 420 CheckTrampolinePoolQuick(); |
420 } | 421 } |
421 | 422 |
422 | 423 |
423 } } // namespace v8::internal | 424 } } // namespace v8::internal |
424 | 425 |
425 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ | 426 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
OLD | NEW |