OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ppc/codegen-ppc.h" | 5 #include "src/ppc/codegen-ppc.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 #endif | 189 #endif |
190 | 190 |
191 | 191 |
192 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { | 192 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { |
193 bool result = isolate->code_aging_helper()->IsYoung(sequence); | 193 bool result = isolate->code_aging_helper()->IsYoung(sequence); |
194 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); | 194 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); |
195 return result; | 195 return result; |
196 } | 196 } |
197 | 197 |
| 198 Code::Age Code::GetCodeAge(Isolate* isolate, byte* sequence) { |
| 199 if (IsYoungSequence(isolate, sequence)) return kNoAgeCodeAge; |
198 | 200 |
199 void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age, | 201 Code* code = NULL; |
200 MarkingParity* parity) { | 202 Address target_address = |
201 if (IsYoungSequence(isolate, sequence)) { | 203 Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); |
202 *age = kNoAgeCodeAge; | 204 Code* stub = GetCodeFromTargetAddress(target_address); |
203 *parity = NO_MARKING_PARITY; | 205 return GetAgeOfCodeAgeStub(stub); |
204 } else { | |
205 Code* code = NULL; | |
206 Address target_address = | |
207 Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); | |
208 Code* stub = GetCodeFromTargetAddress(target_address); | |
209 GetCodeAgeAndParity(stub, age, parity); | |
210 } | |
211 } | 206 } |
212 | 207 |
213 | 208 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, |
214 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, Code::Age age, | 209 Code::Age age) { |
215 MarkingParity parity) { | |
216 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 210 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
217 if (age == kNoAgeCodeAge) { | 211 if (age == kNoAgeCodeAge) { |
218 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 212 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
219 Assembler::FlushICache(isolate, sequence, young_length); | 213 Assembler::FlushICache(isolate, sequence, young_length); |
220 } else { | 214 } else { |
221 // FIXED_SEQUENCE | 215 // FIXED_SEQUENCE |
222 Code* stub = GetCodeAgeStub(isolate, age, parity); | 216 Code* stub = GetCodeAgeStub(isolate, age); |
223 CodePatcher patcher(isolate, sequence, | 217 CodePatcher patcher(isolate, sequence, |
224 young_length / Assembler::kInstrSize); | 218 young_length / Assembler::kInstrSize); |
225 Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); | 219 Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); |
226 intptr_t target = reinterpret_cast<intptr_t>(stub->instruction_start()); | 220 intptr_t target = reinterpret_cast<intptr_t>(stub->instruction_start()); |
227 // Don't use Call -- we need to preserve ip and lr. | 221 // Don't use Call -- we need to preserve ip and lr. |
228 // GenerateMakeCodeYoungAgainCommon for the stub code. | 222 // GenerateMakeCodeYoungAgainCommon for the stub code. |
229 patcher.masm()->nop(); // marker to detect sequence (see IsOld) | 223 patcher.masm()->nop(); // marker to detect sequence (see IsOld) |
230 patcher.masm()->mov(r3, Operand(target)); | 224 patcher.masm()->mov(r3, Operand(target)); |
231 patcher.masm()->Jump(r3); | 225 patcher.masm()->Jump(r3); |
232 for (int i = 0; i < kCodeAgingSequenceNops; i++) { | 226 for (int i = 0; i < kCodeAgingSequenceNops; i++) { |
233 patcher.masm()->nop(); | 227 patcher.masm()->nop(); |
234 } | 228 } |
235 } | 229 } |
236 } | 230 } |
237 } // namespace internal | 231 } // namespace internal |
238 } // namespace v8 | 232 } // namespace v8 |
239 | 233 |
240 #endif // V8_TARGET_ARCH_PPC | 234 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |