| 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) { | |
| 192 if (IsYoungSequence(isolate, sequence)) { | 191 if (IsYoungSequence(isolate, sequence)) { |
| 193 *age = kNoAgeCodeAge; | 192 return kNoAgeCodeAge; |
| 194 *parity = NO_MARKING_PARITY; | |
| 195 } else { | 193 } else { |
| 196 Code* code = NULL; | 194 Code* code = NULL; |
| 197 Address target_address = | 195 Address target_address = |
| 198 Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); | 196 Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); |
| 199 Code* stub = GetCodeFromTargetAddress(target_address); | 197 Code* stub = GetCodeFromTargetAddress(target_address); |
| 200 GetCodeAgeAndParity(stub, age, parity); | 198 return GetAgeOfCodeAgeStub(stub); |
| 201 } | 199 } |
| 202 } | 200 } |
| 203 | 201 |
| 204 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, Code::Age age, | 202 void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, |
| 205 MarkingParity parity) { | 203 Code::Age age) { |
| 206 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 204 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
| 207 if (age == kNoAgeCodeAge) { | 205 if (age == kNoAgeCodeAge) { |
| 208 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 206 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
| 209 Assembler::FlushICache(isolate, sequence, young_length); | 207 Assembler::FlushICache(isolate, sequence, young_length); |
| 210 } else { | 208 } else { |
| 211 // FIXED_SEQUENCE | 209 // FIXED_SEQUENCE |
| 212 Code* stub = GetCodeAgeStub(isolate, age, parity); | 210 Code* stub = GetCodeAgeStub(isolate, age); |
| 213 CodePatcher patcher(isolate, sequence, young_length); | 211 CodePatcher patcher(isolate, sequence, young_length); |
| 214 intptr_t target = reinterpret_cast<intptr_t>(stub->instruction_start()); | 212 intptr_t target = reinterpret_cast<intptr_t>(stub->instruction_start()); |
| 215 // We need to push lr on stack so that GenerateMakeCodeYoungAgainCommon | 213 // We need to push lr on stack so that GenerateMakeCodeYoungAgainCommon |
| 216 // knows where to pick up the return address | 214 // knows where to pick up the return address |
| 217 // | 215 // |
| 218 // Since we can no longer guarentee ip will hold the branch address | 216 // Since we can no longer guarentee ip will hold the branch address |
| 219 // because of BRASL, use Call so that GenerateMakeCodeYoungAgainCommon | 217 // because of BRASL, use Call so that GenerateMakeCodeYoungAgainCommon |
| 220 // can calculate the branch address offset | 218 // can calculate the branch address offset |
| 221 patcher.masm()->nop(); // marker to detect sequence (see IsOld) | 219 patcher.masm()->nop(); // marker to detect sequence (see IsOld) |
| 222 patcher.masm()->CleanseP(r14); | 220 patcher.masm()->CleanseP(r14); |
| 223 patcher.masm()->Push(r14); | 221 patcher.masm()->Push(r14); |
| 224 patcher.masm()->mov(r2, Operand(target)); | 222 patcher.masm()->mov(r2, Operand(target)); |
| 225 patcher.masm()->Call(r2); | 223 patcher.masm()->Call(r2); |
| 226 for (int i = 0; i < kNoCodeAgeSequenceLength - kCodeAgingSequenceLength; | 224 for (int i = 0; i < kNoCodeAgeSequenceLength - kCodeAgingSequenceLength; |
| 227 i += 2) { | 225 i += 2) { |
| 228 // TODO(joransiu): Create nop function to pad | 226 // TODO(joransiu): Create nop function to pad |
| 229 // (kNoCodeAgeSequenceLength - kCodeAgingSequenceLength) bytes. | 227 // (kNoCodeAgeSequenceLength - kCodeAgingSequenceLength) bytes. |
| 230 patcher.masm()->nop(); // 2-byte nops(). | 228 patcher.masm()->nop(); // 2-byte nops(). |
| 231 } | 229 } |
| 232 } | 230 } |
| 233 } | 231 } |
| 234 | 232 |
| 235 } // namespace internal | 233 } // namespace internal |
| 236 } // namespace v8 | 234 } // namespace v8 |
| 237 | 235 |
| 238 #endif // V8_TARGET_ARCH_S390 | 236 #endif // V8_TARGET_ARCH_S390 |
| OLD | NEW |