OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 function->ReplaceCode(function->shared()->code()); | 129 function->ReplaceCode(function->shared()->code()); |
130 | 130 |
131 if (FLAG_trace_deopt) { | 131 if (FLAG_trace_deopt) { |
132 PrintF("[forced deoptimization: "); | 132 PrintF("[forced deoptimization: "); |
133 function->PrintName(); | 133 function->PrintName(); |
134 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); | 134 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 void Deoptimizer::PatchStackCheckCodeAt(Address pc_after, | 139 void Deoptimizer::PatchStackCheckCodeAt(Code* code, |
| 140 Address pc_after, |
140 Code* check_code, | 141 Code* check_code, |
141 Code* replacement_code) { | 142 Code* replacement_code) { |
142 Address call_target_address = pc_after - kIntSize; | 143 Address call_target_address = pc_after - kIntSize; |
143 ASSERT(check_code->entry() == | 144 ASSERT(check_code->entry() == |
144 Assembler::target_address_at(call_target_address)); | 145 Assembler::target_address_at(call_target_address)); |
145 // The stack check code matches the pattern: | 146 // The stack check code matches the pattern: |
146 // | 147 // |
147 // cmp esp, <limit> | 148 // cmp esp, <limit> |
148 // jae ok | 149 // jae ok |
149 // call <stack guard> | 150 // call <stack guard> |
150 // test eax, <loop nesting depth> | 151 // test eax, <loop nesting depth> |
151 // ok: ... | 152 // ok: ... |
152 // | 153 // |
153 // We will patch away the branch so the code is: | 154 // We will patch away the branch so the code is: |
154 // | 155 // |
155 // cmp esp, <limit> ;; Not changed | 156 // cmp esp, <limit> ;; Not changed |
156 // nop | 157 // nop |
157 // nop | 158 // nop |
158 // call <on-stack replacment> | 159 // call <on-stack replacment> |
159 // test eax, <loop nesting depth> | 160 // test eax, <loop nesting depth> |
160 // ok: | 161 // ok: |
161 ASSERT(*(call_target_address - 3) == 0x73 && // jae | 162 ASSERT(*(call_target_address - 3) == 0x73 && // jae |
162 *(call_target_address - 2) == 0x07 && // offset | 163 *(call_target_address - 2) == 0x07 && // offset |
163 *(call_target_address - 1) == 0xe8); // call | 164 *(call_target_address - 1) == 0xe8); // call |
164 *(call_target_address - 3) = 0x90; // nop | 165 *(call_target_address - 3) = 0x90; // nop |
165 *(call_target_address - 2) = 0x90; // nop | 166 *(call_target_address - 2) = 0x90; // nop |
166 Assembler::set_target_address_at(call_target_address, | 167 Assembler::set_target_address_at(call_target_address, |
167 replacement_code->entry()); | 168 replacement_code->entry()); |
| 169 IncrementalMarking::RecordWrite(code, replacement_code); |
168 } | 170 } |
169 | 171 |
170 | 172 |
171 void Deoptimizer::RevertStackCheckCodeAt(Address pc_after, | 173 void Deoptimizer::RevertStackCheckCodeAt(Address pc_after, |
172 Code* check_code, | 174 Code* check_code, |
173 Code* replacement_code) { | 175 Code* replacement_code) { |
174 Address call_target_address = pc_after - kIntSize; | 176 Address call_target_address = pc_after - kIntSize; |
175 ASSERT(replacement_code->entry() == | 177 ASSERT(replacement_code->entry() == |
176 Assembler::target_address_at(call_target_address)); | 178 Assembler::target_address_at(call_target_address)); |
177 // Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to | 179 // Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to |
178 // restore the conditional branch. | 180 // restore the conditional branch. |
179 ASSERT(*(call_target_address - 3) == 0x90 && // nop | 181 ASSERT(*(call_target_address - 3) == 0x90 && // nop |
180 *(call_target_address - 2) == 0x90 && // nop | 182 *(call_target_address - 2) == 0x90 && // nop |
181 *(call_target_address - 1) == 0xe8); // call | 183 *(call_target_address - 1) == 0xe8); // call |
182 *(call_target_address - 3) = 0x73; // jae | 184 *(call_target_address - 3) = 0x73; // jae |
183 *(call_target_address - 2) = 0x07; // offset | 185 *(call_target_address - 2) = 0x07; // offset |
184 Assembler::set_target_address_at(call_target_address, | 186 Assembler::set_target_address_at(call_target_address, |
185 check_code->entry()); | 187 check_code->entry()); |
| 188 IncrementalMarking::RecordWriteOf(check_code); |
186 } | 189 } |
187 | 190 |
188 | 191 |
189 static int LookupBailoutId(DeoptimizationInputData* data, unsigned ast_id) { | 192 static int LookupBailoutId(DeoptimizationInputData* data, unsigned ast_id) { |
190 ByteArray* translations = data->TranslationByteArray(); | 193 ByteArray* translations = data->TranslationByteArray(); |
191 int length = data->DeoptCount(); | 194 int length = data->DeoptCount(); |
192 for (int i = 0; i < length; i++) { | 195 for (int i = 0; i < length; i++) { |
193 if (static_cast<unsigned>(data->AstId(i)->value()) == ast_id) { | 196 if (static_cast<unsigned>(data->AstId(i)->value()) == ast_id) { |
194 TranslationIterator it(translations, data->TranslationIndex(i)->value()); | 197 TranslationIterator it(translations, data->TranslationIndex(i)->value()); |
195 int value = it.Next(); | 198 int value = it.Next(); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 } | 656 } |
654 __ bind(&done); | 657 __ bind(&done); |
655 } | 658 } |
656 | 659 |
657 #undef __ | 660 #undef __ |
658 | 661 |
659 | 662 |
660 } } // namespace v8::internal | 663 } } // namespace v8::internal |
661 | 664 |
662 #endif // V8_TARGET_ARCH_IA32 | 665 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |