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

Side by Side Diff: src/x64/deoptimizer-x64.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/runtime-profiler.cc ('k') | src/x64/full-codegen-x64.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ASSERT(prev_call_address == NULL || 75 ASSERT(prev_call_address == NULL ||
76 call_address >= prev_call_address + patch_size()); 76 call_address >= prev_call_address + patch_size());
77 ASSERT(call_address + patch_size() <= code->instruction_end()); 77 ASSERT(call_address + patch_size() <= code->instruction_end());
78 #ifdef DEBUG 78 #ifdef DEBUG
79 prev_call_address = call_address; 79 prev_call_address = call_address;
80 #endif 80 #endif
81 } 81 }
82 } 82 }
83 83
84 84
85 static const byte kJnsInstruction = 0x79;
86 static const byte kJnsOffset = 0x1d;
87 static const byte kCallInstruction = 0xe8;
88 static const byte kNopByteOne = 0x66;
89 static const byte kNopByteTwo = 0x90;
90
91 // The back edge bookkeeping code matches the pattern:
92 //
93 // add <profiling_counter>, <-delta>
94 // jns ok
95 // call <stack guard>
96 // ok:
97 //
98 // We will patch away the branch so the code is:
99 //
100 // add <profiling_counter>, <-delta> ;; Not changed
101 // nop
102 // nop
103 // call <on-stack replacment>
104 // ok:
105
106 void Deoptimizer::PatchInterruptCodeAt(Code* unoptimized_code,
107 Address pc_after,
108 Code* replacement_code) {
109 // Turn the jump into nops.
110 Address call_target_address = pc_after - kIntSize;
111 *(call_target_address - 3) = kNopByteOne;
112 *(call_target_address - 2) = kNopByteTwo;
113 // Replace the call address.
114 Assembler::set_target_address_at(call_target_address,
115 replacement_code->entry());
116
117 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
118 unoptimized_code, call_target_address, replacement_code);
119 }
120
121
122 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code,
123 Address pc_after,
124 Code* interrupt_code) {
125 // Restore the original jump.
126 Address call_target_address = pc_after - kIntSize;
127 *(call_target_address - 3) = kJnsInstruction;
128 *(call_target_address - 2) = kJnsOffset;
129 // Restore the original call address.
130 Assembler::set_target_address_at(call_target_address,
131 interrupt_code->entry());
132
133 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
134 unoptimized_code, call_target_address, interrupt_code);
135 }
136
137
138 #ifdef DEBUG
139 Deoptimizer::InterruptPatchState Deoptimizer::GetInterruptPatchState(
140 Isolate* isolate,
141 Code* unoptimized_code,
142 Address pc_after) {
143 Address call_target_address = pc_after - kIntSize;
144 ASSERT_EQ(kCallInstruction, *(call_target_address - 1));
145 if (*(call_target_address - 3) == kNopByteOne) {
146 ASSERT_EQ(kNopByteTwo, *(call_target_address - 2));
147 Code* osr_builtin =
148 isolate->builtins()->builtin(Builtins::kOnStackReplacement);
149 ASSERT_EQ(osr_builtin->entry(),
150 Assembler::target_address_at(call_target_address));
151 return PATCHED_FOR_OSR;
152 } else {
153 // Get the interrupt stub code object to match against from cache.
154 Code* interrupt_builtin =
155 isolate->builtins()->builtin(Builtins::kInterruptCheck);
156 ASSERT_EQ(interrupt_builtin->entry(),
157 Assembler::target_address_at(call_target_address));
158 ASSERT_EQ(kJnsInstruction, *(call_target_address - 3));
159 ASSERT_EQ(kJnsOffset, *(call_target_address - 2));
160 return NOT_PATCHED;
161 }
162 }
163 #endif // DEBUG
164
165
166 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { 85 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) {
167 // Set the register values. The values are not important as there are no 86 // Set the register values. The values are not important as there are no
168 // callee saved registers in JavaScript frames, so all registers are 87 // callee saved registers in JavaScript frames, so all registers are
169 // spilled. Registers rbp and rsp are set to the correct values though. 88 // spilled. Registers rbp and rsp are set to the correct values though.
170 for (int i = 0; i < Register::kNumRegisters; i++) { 89 for (int i = 0; i < Register::kNumRegisters; i++) {
171 input_->SetRegister(i, i * 4); 90 input_->SetRegister(i, i * 4);
172 } 91 }
173 input_->SetRegister(rsp.code(), reinterpret_cast<intptr_t>(frame->sp())); 92 input_->SetRegister(rsp.code(), reinterpret_cast<intptr_t>(frame->sp()));
174 input_->SetRegister(rbp.code(), reinterpret_cast<intptr_t>(frame->fp())); 93 input_->SetRegister(rbp.code(), reinterpret_cast<intptr_t>(frame->fp()));
175 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { 94 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 SetFrameSlot(offset, value); 332 SetFrameSlot(offset, value);
414 } 333 }
415 334
416 335
417 #undef __ 336 #undef __
418 337
419 338
420 } } // namespace v8::internal 339 } } // namespace v8::internal
421 340
422 #endif // V8_TARGET_ARCH_X64 341 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime-profiler.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698