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

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

Issue 23526069: Refactor back edge table related code into a new class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/full-codegen.cc ('k') | src/ia32/full-codegen-ia32.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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 // Handle the junk part after the new relocation info. We will create 171 // Handle the junk part after the new relocation info. We will create
172 // a non-live object in the extra space at the end of the former reloc info. 172 // a non-live object in the extra space at the end of the former reloc info.
173 Address junk_address = reloc_info->address() + reloc_info->Size(); 173 Address junk_address = reloc_info->address() + reloc_info->Size();
174 ASSERT(junk_address <= reloc_end_address); 174 ASSERT(junk_address <= reloc_end_address);
175 isolate->heap()->CreateFillerObjectAt(junk_address, 175 isolate->heap()->CreateFillerObjectAt(junk_address,
176 reloc_end_address - junk_address); 176 reloc_end_address - junk_address);
177 } 177 }
178 178
179 179
180 static const byte kJnsInstruction = 0x79;
181 static const byte kJnsOffset = 0x11;
182 static const byte kCallInstruction = 0xe8;
183 static const byte kNopByteOne = 0x66;
184 static const byte kNopByteTwo = 0x90;
185
186 // The back edge bookkeeping code matches the pattern:
187 //
188 // sub <profiling_counter>, <delta>
189 // jns ok
190 // call <interrupt stub>
191 // ok:
192 //
193 // The patched back edge looks like this:
194 //
195 // sub <profiling_counter>, <delta> ;; Not changed
196 // nop
197 // nop
198 // call <on-stack replacment>
199 // ok:
200
201 void Deoptimizer::PatchInterruptCodeAt(Code* unoptimized_code,
202 Address pc_after,
203 Code* replacement_code) {
204 // Turn the jump into nops.
205 Address call_target_address = pc_after - kIntSize;
206 *(call_target_address - 3) = kNopByteOne;
207 *(call_target_address - 2) = kNopByteTwo;
208 // Replace the call address.
209 Assembler::set_target_address_at(call_target_address,
210 replacement_code->entry());
211
212 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
213 unoptimized_code, call_target_address, replacement_code);
214 }
215
216
217 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code,
218 Address pc_after,
219 Code* interrupt_code) {
220 // Restore the original jump.
221 Address call_target_address = pc_after - kIntSize;
222 *(call_target_address - 3) = kJnsInstruction;
223 *(call_target_address - 2) = kJnsOffset;
224 // Restore the original call address.
225 Assembler::set_target_address_at(call_target_address,
226 interrupt_code->entry());
227
228 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
229 unoptimized_code, call_target_address, interrupt_code);
230 }
231
232
233 #ifdef DEBUG
234 Deoptimizer::InterruptPatchState Deoptimizer::GetInterruptPatchState(
235 Isolate* isolate,
236 Code* unoptimized_code,
237 Address pc_after) {
238 Address call_target_address = pc_after - kIntSize;
239 ASSERT_EQ(kCallInstruction, *(call_target_address - 1));
240 if (*(call_target_address - 3) == kNopByteOne) {
241 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2));
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;
247 } else {
248 // Get the interrupt stub code object to match against from cache.
249 Code* interrupt_builtin =
250 isolate->builtins()->builtin(Builtins::kInterruptCheck);
251 ASSERT_EQ(interrupt_builtin->entry(),
252 Assembler::target_address_at(call_target_address));
253 ASSERT_EQ(kJnsInstruction, *(call_target_address - 3));
254 ASSERT_EQ(kJnsOffset, *(call_target_address - 2));
255 return NOT_PATCHED;
256 }
257 }
258 #endif // DEBUG
259
260
261 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { 180 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) {
262 // Set the register values. The values are not important as there are no 181 // Set the register values. The values are not important as there are no
263 // callee saved registers in JavaScript frames, so all registers are 182 // callee saved registers in JavaScript frames, so all registers are
264 // spilled. Registers ebp and esp are set to the correct values though. 183 // spilled. Registers ebp and esp are set to the correct values though.
265 184
266 for (int i = 0; i < Register::kNumRegisters; i++) { 185 for (int i = 0; i < Register::kNumRegisters; i++) {
267 input_->SetRegister(i, i * 4); 186 input_->SetRegister(i, i * 4);
268 } 187 }
269 input_->SetRegister(esp.code(), reinterpret_cast<intptr_t>(frame->sp())); 188 input_->SetRegister(esp.code(), reinterpret_cast<intptr_t>(frame->sp()));
270 input_->SetRegister(ebp.code(), reinterpret_cast<intptr_t>(frame->fp())); 189 input_->SetRegister(ebp.code(), reinterpret_cast<intptr_t>(frame->fp()));
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 SetFrameSlot(offset, value); 434 SetFrameSlot(offset, value);
516 } 435 }
517 436
518 437
519 #undef __ 438 #undef __
520 439
521 440
522 } } // namespace v8::internal 441 } } // namespace v8::internal
523 442
524 #endif // V8_TARGET_ARCH_IA32 443 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698