Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: src/ia32/deoptimizer-ia32.cc

Issue 23608004: Refactor interrupt check patching for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/deoptimizer.cc ('k') | src/mips/deoptimizer-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // The patched back edge looks like this: 193 // The patched back edge looks like this:
194 // 194 //
195 // sub <profiling_counter>, <delta> ;; Not changed 195 // sub <profiling_counter>, <delta> ;; Not changed
196 // nop 196 // nop
197 // nop 197 // nop
198 // call <on-stack replacment> 198 // call <on-stack replacment>
199 // ok: 199 // ok:
200 200
201 void Deoptimizer::PatchInterruptCodeAt(Code* unoptimized_code, 201 void Deoptimizer::PatchInterruptCodeAt(Code* unoptimized_code,
202 Address pc_after, 202 Address pc_after,
203 Code* interrupt_code,
204 Code* replacement_code) { 203 Code* replacement_code) {
205 ASSERT(!InterruptCodeIsPatched(unoptimized_code,
206 pc_after,
207 interrupt_code,
208 replacement_code));
209 // Turn the jump into nops. 204 // Turn the jump into nops.
210 Address call_target_address = pc_after - kIntSize; 205 Address call_target_address = pc_after - kIntSize;
211 *(call_target_address - 3) = kNopByteOne; 206 *(call_target_address - 3) = kNopByteOne;
212 *(call_target_address - 2) = kNopByteTwo; 207 *(call_target_address - 2) = kNopByteTwo;
213 // Replace the call address. 208 // Replace the call address.
214 Assembler::set_target_address_at(call_target_address, 209 Assembler::set_target_address_at(call_target_address,
215 replacement_code->entry()); 210 replacement_code->entry());
216 211
217 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 212 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
218 unoptimized_code, call_target_address, replacement_code); 213 unoptimized_code, call_target_address, replacement_code);
219 } 214 }
220 215
221 216
222 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code, 217 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code,
223 Address pc_after, 218 Address pc_after,
224 Code* interrupt_code, 219 Code* interrupt_code) {
225 Code* replacement_code) {
226 ASSERT(InterruptCodeIsPatched(unoptimized_code,
227 pc_after,
228 interrupt_code,
229 replacement_code));
230 // Restore the original jump. 220 // Restore the original jump.
231 Address call_target_address = pc_after - kIntSize; 221 Address call_target_address = pc_after - kIntSize;
232 *(call_target_address - 3) = kJnsInstruction; 222 *(call_target_address - 3) = kJnsInstruction;
233 *(call_target_address - 2) = kJnsOffset; 223 *(call_target_address - 2) = kJnsOffset;
234 // Restore the original call address. 224 // Restore the original call address.
235 Assembler::set_target_address_at(call_target_address, 225 Assembler::set_target_address_at(call_target_address,
236 interrupt_code->entry()); 226 interrupt_code->entry());
237 227
238 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 228 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
239 unoptimized_code, call_target_address, interrupt_code); 229 unoptimized_code, call_target_address, interrupt_code);
240 } 230 }
241 231
242 232
243 #ifdef DEBUG 233 #ifdef DEBUG
244 bool Deoptimizer::InterruptCodeIsPatched(Code* unoptimized_code, 234 Deoptimizer::InterruptPatchState Deoptimizer::GetInterruptPatchState(
245 Address pc_after, 235 Isolate* isolate,
246 Code* interrupt_code, 236 Code* unoptimized_code,
247 Code* replacement_code) { 237 Address pc_after) {
248 Address call_target_address = pc_after - kIntSize; 238 Address call_target_address = pc_after - kIntSize;
249 ASSERT_EQ(kCallInstruction, *(call_target_address - 1)); 239 ASSERT_EQ(kCallInstruction, *(call_target_address - 1));
250 if (*(call_target_address - 3) == kNopByteOne) { 240 if (*(call_target_address - 3) == kNopByteOne) {
251 ASSERT_EQ(replacement_code->entry(),
252 Assembler::target_address_at(call_target_address));
253 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2)); 241 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2));
254 return true; 242 Code* osr_builtin =
243 isolate->builtins()->builtin(Builtins::kOnStackReplacement);
244 ASSERT_EQ(osr_builtin->entry(),
245 Assembler::target_address_at(call_target_address));
246 return PATCHED_FOR_OSR;
255 } else { 247 } else {
248 // Get the interrupt stub code object to match against from cache.
249 Code* interrupt_code = NULL;
250 InterruptStub stub;
251 if (!stub.FindCodeInCache(&interrupt_code, isolate)) UNREACHABLE();
256 ASSERT_EQ(interrupt_code->entry(), 252 ASSERT_EQ(interrupt_code->entry(),
257 Assembler::target_address_at(call_target_address)); 253 Assembler::target_address_at(call_target_address));
258 ASSERT_EQ(kJnsInstruction, *(call_target_address - 3)); 254 ASSERT_EQ(kJnsInstruction, *(call_target_address - 3));
259 ASSERT_EQ(kJnsOffset, *(call_target_address - 2)); 255 ASSERT_EQ(kJnsOffset, *(call_target_address - 2));
260 return false; 256 return NOT_PATCHED;
261 } 257 }
262 } 258 }
263 #endif // DEBUG 259 #endif // DEBUG
264 260
265 261
266 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { 262 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) {
267 ByteArray* translations = data->TranslationByteArray(); 263 ByteArray* translations = data->TranslationByteArray();
268 int length = data->DeoptCount(); 264 int length = data->DeoptCount();
269 for (int i = 0; i < length; i++) { 265 for (int i = 0; i < length; i++) {
270 if (data->AstId(i) == ast_id) { 266 if (data->AstId(i) == ast_id) {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 SetFrameSlot(offset, value); 714 SetFrameSlot(offset, value);
719 } 715 }
720 716
721 717
722 #undef __ 718 #undef __
723 719
724 720
725 } } // namespace v8::internal 721 } } // namespace v8::internal
726 722
727 #endif // V8_TARGET_ARCH_IA32 723 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/mips/deoptimizer-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698