Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 if (FLAG_trace_deopt) { | 109 if (FLAG_trace_deopt) { |
| 110 PrintF("[forced deoptimization: "); | 110 PrintF("[forced deoptimization: "); |
| 111 function->PrintName(); | 111 function->PrintName(); |
| 112 PrintF(" / %" V8PRIxPTR "]\n", reinterpret_cast<intptr_t>(function)); | 112 PrintF(" / %" V8PRIxPTR "]\n", reinterpret_cast<intptr_t>(function)); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 | 116 |
| 117 static const byte kJnsInstruction = 0x79; | 117 static const byte kJnsInstruction = 0x79; |
| 118 static const byte kJnsOffset = 0x1f; | 118 static const byte kJnsOffset = 0x1f; |
| 119 static const byte kJaeInstruction = 0x73; | 119 static const byte kJaeInstruction = 0x73; |
|
Jakob Kummerow
2012/12/06 16:25:41
not needed anymore, please remove.
Sven Panne
2012/12/07 08:54:56
Done.
| |
| 120 static const byte kJaeOffset = 0x07; | 120 static const byte kJaeOffset = 0x07; |
|
Jakob Kummerow
2012/12/06 16:25:41
not needed anymore, please remove.
Sven Panne
2012/12/07 08:54:56
Done.
| |
| 121 static const byte kCallInstruction = 0xe8; | 121 static const byte kCallInstruction = 0xe8; |
| 122 static const byte kNopByteOne = 0x66; | 122 static const byte kNopByteOne = 0x66; |
| 123 static const byte kNopByteTwo = 0x90; | 123 static const byte kNopByteTwo = 0x90; |
| 124 | 124 |
| 125 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code, | 125 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code, |
| 126 Address pc_after, | 126 Address pc_after, |
| 127 Code* check_code, | 127 Code* check_code, |
| 128 Code* replacement_code) { | 128 Code* replacement_code) { |
| 129 Address call_target_address = pc_after - kIntSize; | 129 Address call_target_address = pc_after - kIntSize; |
| 130 ASSERT_EQ(check_code->entry(), | 130 ASSERT_EQ(check_code->entry(), |
| 131 Assembler::target_address_at(call_target_address)); | 131 Assembler::target_address_at(call_target_address)); |
| 132 // The stack check code matches the pattern: | 132 // The stack check code matches the pattern: |
| 133 // | 133 // |
| 134 // cmp rsp, <limit> | 134 // cmp rsp, <limit> |
|
Jakob Kummerow
2012/12/06 16:25:41
please update this comment
Sven Panne
2012/12/07 08:54:56
Done.
| |
| 135 // jae ok | 135 // jae ok |
| 136 // call <stack guard> | 136 // call <stack guard> |
| 137 // test rax, <loop nesting depth> | 137 // test rax, <loop nesting depth> |
| 138 // ok: ... | 138 // ok: ... |
| 139 // | 139 // |
| 140 // We will patch away the branch so the code is: | 140 // We will patch away the branch so the code is: |
| 141 // | 141 // |
| 142 // cmp rsp, <limit> ;; Not changed | 142 // cmp rsp, <limit> ;; Not changed |
| 143 // nop | 143 // nop |
| 144 // nop | 144 // nop |
| 145 // call <on-stack replacment> | 145 // call <on-stack replacment> |
| 146 // test rax, <loop nesting depth> | 146 // test rax, <loop nesting depth> |
| 147 // ok: | 147 // ok: |
| 148 // | 148 // |
| 149 if (FLAG_count_based_interrupts) { | 149 ASSERT_EQ(kJnsInstruction, *(call_target_address - 3)); |
| 150 ASSERT_EQ(kJnsInstruction, *(call_target_address - 3)); | 150 ASSERT_EQ(kJnsOffset, *(call_target_address - 2)); |
| 151 ASSERT_EQ(kJnsOffset, *(call_target_address - 2)); | 151 ASSERT_EQ(kCallInstruction, *(call_target_address - 1)); |
| 152 } else { | |
| 153 ASSERT_EQ(kJaeInstruction, *(call_target_address - 3)); | |
| 154 ASSERT_EQ(kJaeOffset, *(call_target_address - 2)); | |
| 155 } | |
| 156 ASSERT_EQ(kCallInstruction, *(call_target_address - 1)); | |
| 157 *(call_target_address - 3) = kNopByteOne; | 152 *(call_target_address - 3) = kNopByteOne; |
| 158 *(call_target_address - 2) = kNopByteTwo; | 153 *(call_target_address - 2) = kNopByteTwo; |
| 159 Assembler::set_target_address_at(call_target_address, | 154 Assembler::set_target_address_at(call_target_address, |
| 160 replacement_code->entry()); | 155 replacement_code->entry()); |
| 161 | 156 |
| 162 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 157 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
| 163 unoptimized_code, call_target_address, replacement_code); | 158 unoptimized_code, call_target_address, replacement_code); |
| 164 } | 159 } |
| 165 | 160 |
| 166 | 161 |
| 167 void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code, | 162 void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code, |
| 168 Address pc_after, | 163 Address pc_after, |
| 169 Code* check_code, | 164 Code* check_code, |
| 170 Code* replacement_code) { | 165 Code* replacement_code) { |
| 171 Address call_target_address = pc_after - kIntSize; | 166 Address call_target_address = pc_after - kIntSize; |
| 172 ASSERT(replacement_code->entry() == | 167 ASSERT(replacement_code->entry() == |
| 173 Assembler::target_address_at(call_target_address)); | 168 Assembler::target_address_at(call_target_address)); |
| 174 // Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to | 169 // Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to |
| 175 // restore the conditional branch. | 170 // restore the conditional branch. |
| 176 ASSERT_EQ(kNopByteOne, *(call_target_address - 3)); | 171 ASSERT_EQ(kNopByteOne, *(call_target_address - 3)); |
| 177 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2)); | 172 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2)); |
| 178 ASSERT_EQ(kCallInstruction, *(call_target_address - 1)); | 173 ASSERT_EQ(kCallInstruction, *(call_target_address - 1)); |
| 179 if (FLAG_count_based_interrupts) { | 174 *(call_target_address - 3) = kJnsInstruction; |
| 180 *(call_target_address - 3) = kJnsInstruction; | 175 *(call_target_address - 2) = kJnsOffset; |
| 181 *(call_target_address - 2) = kJnsOffset; | |
| 182 } else { | |
| 183 *(call_target_address - 3) = kJaeInstruction; | |
| 184 *(call_target_address - 2) = kJaeOffset; | |
| 185 } | |
| 186 Assembler::set_target_address_at(call_target_address, | 176 Assembler::set_target_address_at(call_target_address, |
| 187 check_code->entry()); | 177 check_code->entry()); |
| 188 | 178 |
| 189 check_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 179 check_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
| 190 unoptimized_code, call_target_address, check_code); | 180 unoptimized_code, call_target_address, check_code); |
| 191 } | 181 } |
| 192 | 182 |
| 193 | 183 |
| 194 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { | 184 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { |
| 195 ByteArray* translations = data->TranslationByteArray(); | 185 ByteArray* translations = data->TranslationByteArray(); |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 } | 1167 } |
| 1178 __ bind(&done); | 1168 __ bind(&done); |
| 1179 } | 1169 } |
| 1180 | 1170 |
| 1181 #undef __ | 1171 #undef __ |
| 1182 | 1172 |
| 1183 | 1173 |
| 1184 } } // namespace v8::internal | 1174 } } // namespace v8::internal |
| 1185 | 1175 |
| 1186 #endif // V8_TARGET_ARCH_X64 | 1176 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |