OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "codegen.h" | 9 #include "codegen.h" |
10 #include "heap.h" | 10 #include "heap.h" |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 __ movsd(double_scratch, Operand::StaticArray( | 1043 __ movsd(double_scratch, Operand::StaticArray( |
1044 temp2, times_8, ExternalReference::math_exp_log_table())); | 1044 temp2, times_8, ExternalReference::math_exp_log_table())); |
1045 __ orps(input, double_scratch); | 1045 __ orps(input, double_scratch); |
1046 __ mulsd(result, input); | 1046 __ mulsd(result, input); |
1047 __ bind(&done); | 1047 __ bind(&done); |
1048 } | 1048 } |
1049 | 1049 |
1050 #undef __ | 1050 #undef __ |
1051 | 1051 |
1052 | 1052 |
1053 static byte* GetNoCodeAgeSequence(uint32_t* length) { | 1053 NoCodeAgeSequence::NoCodeAgeSequence() { |
1054 static bool initialized = false; | 1054 ASSERT(sequence_.length() == kNoCodeAgeSequenceLength); |
1055 static byte sequence[kNoCodeAgeSequenceLength]; | 1055 CodePatcher patcher(sequence_.start(), sequence_.length()); |
1056 *length = kNoCodeAgeSequenceLength; | 1056 patcher.masm()->push(ebp); |
1057 if (!initialized) { | 1057 patcher.masm()->mov(ebp, esp); |
1058 // The sequence of instructions that is patched out for aging code is the | 1058 patcher.masm()->push(esi); |
1059 // following boilerplate stack-building prologue that is found both in | 1059 patcher.masm()->push(edi); |
1060 // FUNCTION and OPTIMIZED_FUNCTION code: | |
1061 CodePatcher patcher(sequence, kNoCodeAgeSequenceLength); | |
1062 patcher.masm()->push(ebp); | |
1063 patcher.masm()->mov(ebp, esp); | |
1064 patcher.masm()->push(esi); | |
1065 patcher.masm()->push(edi); | |
1066 initialized = true; | |
1067 } | |
1068 return sequence; | |
1069 } | 1060 } |
1070 | 1061 |
1071 | 1062 |
1072 bool Code::IsYoungSequence(byte* sequence) { | 1063 bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { |
1073 uint32_t young_length; | 1064 bool result = isolate->no_code_age_sequence()->Match(sequence); |
1074 byte* young_sequence = GetNoCodeAgeSequence(&young_length); | |
1075 bool result = (!memcmp(sequence, young_sequence, young_length)); | |
1076 ASSERT(result || *sequence == kCallOpcode); | 1065 ASSERT(result || *sequence == kCallOpcode); |
1077 return result; | 1066 return result; |
1078 } | 1067 } |
1079 | 1068 |
1080 | 1069 |
1081 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, | 1070 void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age, |
1082 MarkingParity* parity) { | 1071 MarkingParity* parity) { |
1083 if (IsYoungSequence(sequence)) { | 1072 if (IsYoungSequence(isolate, sequence)) { |
1084 *age = kNoAgeCodeAge; | 1073 *age = kNoAgeCodeAge; |
1085 *parity = NO_MARKING_PARITY; | 1074 *parity = NO_MARKING_PARITY; |
1086 } else { | 1075 } else { |
1087 sequence++; // Skip the kCallOpcode byte | 1076 sequence++; // Skip the kCallOpcode byte |
1088 Address target_address = sequence + *reinterpret_cast<int*>(sequence) + | 1077 Address target_address = sequence + *reinterpret_cast<int*>(sequence) + |
1089 Assembler::kCallTargetAddressOffset; | 1078 Assembler::kCallTargetAddressOffset; |
1090 Code* stub = GetCodeFromTargetAddress(target_address); | 1079 Code* stub = GetCodeFromTargetAddress(target_address); |
1091 GetCodeAgeAndParity(stub, age, parity); | 1080 GetCodeAgeAndParity(stub, age, parity); |
1092 } | 1081 } |
1093 } | 1082 } |
1094 | 1083 |
1095 | 1084 |
1096 void Code::PatchPlatformCodeAge(Isolate* isolate, | 1085 void Code::PatchPlatformCodeAge(Isolate* isolate, |
1097 byte* sequence, | 1086 byte* sequence, |
1098 Code::Age age, | 1087 Code::Age age, |
1099 MarkingParity parity) { | 1088 MarkingParity parity) { |
1100 uint32_t young_length; | 1089 uint32_t young_length = isolate->no_code_age_sequence()->length(); |
1101 byte* young_sequence = GetNoCodeAgeSequence(&young_length); | |
1102 if (age == kNoAgeCodeAge) { | 1090 if (age == kNoAgeCodeAge) { |
1103 CopyBytes(sequence, young_sequence, young_length); | 1091 isolate->no_code_age_sequence()->CopyTo(sequence); |
1104 CPU::FlushICache(sequence, young_length); | 1092 CPU::FlushICache(sequence, young_length); |
1105 } else { | 1093 } else { |
1106 Code* stub = GetCodeAgeStub(isolate, age, parity); | 1094 Code* stub = GetCodeAgeStub(isolate, age, parity); |
1107 CodePatcher patcher(sequence, young_length); | 1095 CodePatcher patcher(sequence, young_length); |
1108 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 1096 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
1109 } | 1097 } |
1110 } | 1098 } |
1111 | 1099 |
1112 | 1100 |
1113 } } // namespace v8::internal | 1101 } } // namespace v8::internal |
1114 | 1102 |
1115 #endif // V8_TARGET_ARCH_IA32 | 1103 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |