Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 Address RelocInfo::target_address() { | 91 Address RelocInfo::target_address() { |
| 92 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 92 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 93 return Assembler::target_address_at(pc_); | 93 return Assembler::target_address_at(pc_); |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 Address RelocInfo::target_address_address() { | 97 Address RelocInfo::target_address_address() { |
| 98 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY | 98 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 99 || rmode_ == EMBEDDED_OBJECT | 99 return reinterpret_cast<Address>(pc_); |
| 100 || rmode_ == EXTERNAL_REFERENCE); | |
| 101 // Read the address of the word containing the target_address in an | |
| 102 // instruction stream. | |
| 103 // The only architecture-independent user of this function is the serializer. | |
| 104 // The serializer uses it to find out how many raw bytes of instruction to | |
| 105 // output before the next target. | |
| 106 // For an instructions like LUI/ORI where the target bits are mixed into the | |
| 107 // instruction bits, the size of the target will be zero, indicating that the | |
| 108 // serializer should not step forward in memory after a target is resolved | |
| 109 // and written. In this case the target_address_address function should | |
| 110 // return the end of the instructions to be patched, allowing the | |
| 111 // deserializer to deserialize the instructions as raw bytes and put them in | |
| 112 // place, ready to be patched with the target. In our case, that is the | |
| 113 // address of the instruction that follows LUI/ORI instruction pair. | |
| 114 return reinterpret_cast<Address>( | |
| 115 pc_ + Assembler::kInstructionsFor32BitConstant * Assembler::kInstrSize); | |
| 116 } | 100 } |
| 117 | 101 |
| 118 | 102 |
| 119 int RelocInfo::target_address_size() { | 103 int RelocInfo::target_address_size() { |
| 120 return Assembler::kExternalTargetSize; | 104 return Assembler::kExternalTargetSize; |
| 121 } | 105 } |
| 122 | 106 |
| 123 | 107 |
| 124 void RelocInfo::set_target_address(Address target) { | 108 void RelocInfo::set_target_address(Address target) { |
| 125 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 109 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 137 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 121 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 138 return Handle<Object>(reinterpret_cast<Object**>( | 122 return Handle<Object>(reinterpret_cast<Object**>( |
| 139 Assembler::target_address_at(pc_))); | 123 Assembler::target_address_at(pc_))); |
| 140 } | 124 } |
| 141 | 125 |
| 142 | 126 |
| 143 Object** RelocInfo::target_object_address() { | 127 Object** RelocInfo::target_object_address() { |
| 144 // Provide a "natural pointer" to the embedded object, | 128 // Provide a "natural pointer" to the embedded object, |
| 145 // which can be de-referenced during heap iteration. | 129 // which can be de-referenced during heap iteration. |
| 146 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 130 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 147 // TODO(mips): Commenting out, to simplify arch-independent changes. | 131 reconstructed_obj_ptr_ = |
| 148 // GC won't work like this, but this commit is for asm/disasm/sim. | 132 reinterpret_cast<Object*>(Assembler::target_address_at(pc_)); |
| 149 // reconstructed_obj_ptr_ = | 133 return &reconstructed_obj_ptr_; |
| 150 // reinterpret_cast<Object*>(Assembler::target_address_at(pc_)); | |
| 151 // return &reconstructed_obj_ptr_; | |
| 152 return NULL; | |
| 153 } | 134 } |
| 154 | 135 |
| 155 | 136 |
| 156 void RelocInfo::set_target_object(Object* target) { | 137 void RelocInfo::set_target_object(Object* target) { |
| 157 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 138 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 158 Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target)); | 139 Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target)); |
| 159 } | 140 } |
| 160 | 141 |
| 161 | 142 |
| 162 Address* RelocInfo::target_reference_address() { | 143 Address* RelocInfo::target_reference_address() { |
| 163 ASSERT(rmode_ == EXTERNAL_REFERENCE); | 144 ASSERT(rmode_ == EXTERNAL_REFERENCE); |
| 164 // TODO(mips): Commenting out, to simplify arch-independent changes. | 145 reconstructed_adr_ptr_ = Assembler::target_address_at(pc_); |
| 165 // GC won't work like this, but this commit is for asm/disasm/sim. | 146 return &reconstructed_adr_ptr_; |
| 166 // reconstructed_adr_ptr_ = Assembler::target_address_at(pc_); | |
| 167 // return &reconstructed_adr_ptr_; | |
| 168 return NULL; | |
| 169 } | 147 } |
| 170 | 148 |
| 171 | 149 |
| 172 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { | 150 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| 173 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 151 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 174 Address address = Memory::Address_at(pc_); | 152 Address address = Memory::Address_at(pc_); |
| 175 return Handle<JSGlobalPropertyCell>( | 153 return Handle<JSGlobalPropertyCell>( |
| 176 reinterpret_cast<JSGlobalPropertyCell**>(address)); | 154 reinterpret_cast<JSGlobalPropertyCell**>(address)); |
| 177 } | 155 } |
| 178 | 156 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 | 222 |
| 245 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { | 223 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { |
| 246 Instr current_instr = Assembler::instr_at(pc_); | 224 Instr current_instr = Assembler::instr_at(pc_); |
| 247 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); | 225 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); |
| 248 } | 226 } |
| 249 | 227 |
| 250 | 228 |
| 251 void RelocInfo::Visit(ObjectVisitor* visitor) { | 229 void RelocInfo::Visit(ObjectVisitor* visitor) { |
| 252 RelocInfo::Mode mode = rmode(); | 230 RelocInfo::Mode mode = rmode(); |
| 253 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 231 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
| 254 // RelocInfo is needed when pointer must be updated/serialized, such as | 232 // RelocInfo is needed when pointer must be updated, such as |
| 255 // UpdatingVisitor in mark-compact.cc or Serializer in serialize.cc. | 233 // UpdatingVisitor in mark-compact.cc. It ignored by visitors |
| 256 // It is ignored by visitors that do not need it. | 234 // that do not need it. |
|
Søren Thygesen Gjesse
2011/05/23 09:20:58
I think we should try to avoid adding this overloa
Paul Lind
2011/05/24 06:30:22
Nice idea, much cleaner than my approach. Implemen
| |
| 257 // TODO(mips): Commenting out, to simplify arch-independent changes. | 235 visitor->VisitPointer(target_object_address(), this); |
| 258 // GC won't work like this, but this commit is for asm/disasm/sim. | |
| 259 // visitor->VisitPointer(target_object_address(), this); | |
| 260 } else if (RelocInfo::IsCodeTarget(mode)) { | 236 } else if (RelocInfo::IsCodeTarget(mode)) { |
| 261 visitor->VisitCodeTarget(this); | 237 visitor->VisitCodeTarget(this); |
| 262 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 238 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 263 visitor->VisitGlobalPropertyCell(this); | 239 visitor->VisitGlobalPropertyCell(this); |
| 264 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 240 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
| 265 // RelocInfo is needed when external-references must be serialized by | 241 visitor->VisitExternalReference(target_reference_address()); |
| 266 // Serializer Visitor in serialize.cc. It is ignored by visitors that | |
| 267 // do not need it. | |
| 268 // TODO(mips): Commenting out, to simplify arch-independent changes. | |
| 269 // Serializer won't work like this, but this commit is for asm/disasm/sim. | |
| 270 // visitor->VisitExternalReference(target_reference_address(), this); | |
| 271 #ifdef ENABLE_DEBUGGER_SUPPORT | 242 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 272 // TODO(isolates): Get a cached isolate below. | 243 // TODO(isolates): Get a cached isolate below. |
| 273 } else if (((RelocInfo::IsJSReturn(mode) && | 244 } else if (((RelocInfo::IsJSReturn(mode) && |
| 274 IsPatchedReturnSequence()) || | 245 IsPatchedReturnSequence()) || |
| 275 (RelocInfo::IsDebugBreakSlot(mode) && | 246 (RelocInfo::IsDebugBreakSlot(mode) && |
| 276 IsPatchedDebugBreakSlotSequence())) && | 247 IsPatchedDebugBreakSlotSequence())) && |
| 277 Isolate::Current()->debug()->has_break_points()) { | 248 Isolate::Current()->debug()->has_break_points()) { |
| 278 visitor->VisitDebugTarget(this); | 249 visitor->VisitDebugTarget(this); |
| 279 #endif | 250 #endif |
| 280 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 251 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 CheckBuffer(); | 301 CheckBuffer(); |
| 331 *reinterpret_cast<Instr*>(pc_) = x; | 302 *reinterpret_cast<Instr*>(pc_) = x; |
| 332 pc_ += kInstrSize; | 303 pc_ += kInstrSize; |
| 333 CheckTrampolinePoolQuick(); | 304 CheckTrampolinePoolQuick(); |
| 334 } | 305 } |
| 335 | 306 |
| 336 | 307 |
| 337 } } // namespace v8::internal | 308 } } // namespace v8::internal |
| 338 | 309 |
| 339 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ | 310 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
| OLD | NEW |