OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/s390/codegen-s390.h" | 5 #include "src/s390/codegen-s390.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_S390 | 7 #if V8_TARGET_ARCH_S390 |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 return Assembler::IsNop(Assembler::instr_at(candidate)); | 180 return Assembler::IsNop(Assembler::instr_at(candidate)); |
181 } | 181 } |
182 #endif | 182 #endif |
183 | 183 |
184 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { | 184 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { |
185 bool result = isolate->code_aging_helper()->IsYoung(sequence); | 185 bool result = isolate->code_aging_helper()->IsYoung(sequence); |
186 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); | 186 DCHECK(result || isolate->code_aging_helper()->IsOld(sequence)); |
187 return result; | 187 return result; |
188 } | 188 } |
189 | 189 |
190 void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age, | 190 Code::Age Code::GetCodeAge(Isolate* isolate, byte* sequence) { |
191 MarkingParity* parity) { | 191 if (IsYoungSequence(isolate, sequence)) return kNoAgeCodeAge; |
192 if (IsYoungSequence(isolate, sequence)) { | 192 |
193 *age = kNoAgeCodeAge; | 193 Code* code = NULL; |
194 *parity = NO_MARKING_PARITY; | 194 Address target_address = |
195 } else { | 195 Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); |
196 Code* code = NULL; | 196 Code* stub = GetCodeFromTargetAddress(target_address); |
197 Address target_address = | 197 return GetAgeOfCodeAgeStub(stub); |
198 Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); | |
199 Code* stub = GetCodeFromTargetAddress(target_address); | |
200 GetCodeAgeAndParity(stub, age, parity); | |
201 } | |
202 } | 198 } |
203 | 199 |
204 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, Code::Age age, | 200 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, |
205 MarkingParity parity) { | 201 Code::Age age) { |
206 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 202 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
207 if (age == kNoAgeCodeAge) { | 203 if (age == kNoAgeCodeAge) { |
208 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 204 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
209 Assembler::FlushICache(isolate, sequence, young_length); | 205 Assembler::FlushICache(isolate, sequence, young_length); |
210 } else { | 206 } else { |
211 // FIXED_SEQUENCE | 207 // FIXED_SEQUENCE |
212 Code* stub = GetCodeAgeStub(isolate, age, parity); | 208 Code* stub = GetCodeAgeStub(isolate, age); |
213 CodePatcher patcher(isolate, sequence, young_length); | 209 CodePatcher patcher(isolate, sequence, young_length); |
214 intptr_t target = reinterpret_cast<intptr_t>(stub->instruction_start()); | 210 intptr_t target = reinterpret_cast<intptr_t>(stub->instruction_start()); |
215 // We need to push lr on stack so that GenerateMakeCodeYoungAgainCommon | 211 // We need to push lr on stack so that GenerateMakeCodeYoungAgainCommon |
216 // knows where to pick up the return address | 212 // knows where to pick up the return address |
217 // | 213 // |
218 // Since we can no longer guarentee ip will hold the branch address | 214 // Since we can no longer guarentee ip will hold the branch address |
219 // because of BRASL, use Call so that GenerateMakeCodeYoungAgainCommon | 215 // because of BRASL, use Call so that GenerateMakeCodeYoungAgainCommon |
220 // can calculate the branch address offset | 216 // can calculate the branch address offset |
221 patcher.masm()->nop(); // marker to detect sequence (see IsOld) | 217 patcher.masm()->nop(); // marker to detect sequence (see IsOld) |
222 patcher.masm()->CleanseP(r14); | 218 patcher.masm()->CleanseP(r14); |
223 patcher.masm()->Push(r14); | 219 patcher.masm()->Push(r14); |
224 patcher.masm()->mov(r2, Operand(target)); | 220 patcher.masm()->mov(r2, Operand(target)); |
225 patcher.masm()->Call(r2); | 221 patcher.masm()->Call(r2); |
226 for (int i = 0; i < kNoCodeAgeSequenceLength - kCodeAgingSequenceLength; | 222 for (int i = 0; i < kNoCodeAgeSequenceLength - kCodeAgingSequenceLength; |
227 i += 2) { | 223 i += 2) { |
228 // TODO(joransiu): Create nop function to pad | 224 // TODO(joransiu): Create nop function to pad |
229 // (kNoCodeAgeSequenceLength - kCodeAgingSequenceLength) bytes. | 225 // (kNoCodeAgeSequenceLength - kCodeAgingSequenceLength) bytes. |
230 patcher.masm()->nop(); // 2-byte nops(). | 226 patcher.masm()->nop(); // 2-byte nops(). |
231 } | 227 } |
232 } | 228 } |
233 } | 229 } |
234 | 230 |
235 } // namespace internal | 231 } // namespace internal |
236 } // namespace v8 | 232 } // namespace v8 |
237 | 233 |
238 #endif // V8_TARGET_ARCH_S390 | 234 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |