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

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

Issue 19638014: Factor out common code from platform-specific deoptimization. Fix Deoptimizer not to need to partit… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Cleanups post-review. Created 7 years, 4 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/mark-compact.h » ('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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 reloc_info_writer.Write(&rinfo); 107 reloc_info_writer.Write(&rinfo);
108 ASSERT(RelocInfo::kMinRelocCommentSize == 108 ASSERT(RelocInfo::kMinRelocCommentSize ==
109 pos_before - reloc_info_writer.pos()); 109 pos_before - reloc_info_writer.pos());
110 } 110 }
111 // Replace relocation information on the code object. 111 // Replace relocation information on the code object.
112 code->set_relocation_info(*new_reloc); 112 code->set_relocation_info(*new_reloc);
113 } 113 }
114 } 114 }
115 115
116 116
117 void Deoptimizer::DeoptimizeFunctionWithPreparedFunctionList( 117 void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) {
118 JSFunction* function) {
119 Isolate* isolate = function->GetIsolate();
120 HandleScope scope(isolate);
121 DisallowHeapAllocation nha;
122
123 ASSERT(function->IsOptimized());
124 ASSERT(function->FunctionsInFunctionListShareSameCode());
125
126 // Get the optimized code.
127 Code* code = function->code();
128 Address code_start_address = code->instruction_start(); 118 Address code_start_address = code->instruction_start();
129
130 // The optimized code is going to be patched, so we cannot use it any more.
131 function->shared()->EvictFromOptimizedCodeMap(code, "deoptimized function");
132
133 // We will overwrite the code's relocation info in-place. Relocation info 119 // We will overwrite the code's relocation info in-place. Relocation info
134 // is written backward. The relocation info is the payload of a byte 120 // is written backward. The relocation info is the payload of a byte
135 // array. Later on we will slide this to the start of the byte array and 121 // array. Later on we will slide this to the start of the byte array and
136 // create a filler object in the remaining space. 122 // create a filler object in the remaining space.
137 ByteArray* reloc_info = code->relocation_info(); 123 ByteArray* reloc_info = code->relocation_info();
138 Address reloc_end_address = reloc_info->address() + reloc_info->Size(); 124 Address reloc_end_address = reloc_info->address() + reloc_info->Size();
139 RelocInfoWriter reloc_info_writer(reloc_end_address, code_start_address); 125 RelocInfoWriter reloc_info_writer(reloc_end_address, code_start_address);
140 126
141 // For each LLazyBailout instruction insert a call to the corresponding 127 // For each LLazyBailout instruction insert a call to the corresponding
142 // deoptimization entry. 128 // deoptimization entry.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 167
182 // The relocation info is in place, update the size. 168 // The relocation info is in place, update the size.
183 reloc_info->set_length(new_reloc_size); 169 reloc_info->set_length(new_reloc_size);
184 170
185 // 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
186 // 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.
187 Address junk_address = reloc_info->address() + reloc_info->Size(); 173 Address junk_address = reloc_info->address() + reloc_info->Size();
188 ASSERT(junk_address <= reloc_end_address); 174 ASSERT(junk_address <= reloc_end_address);
189 isolate->heap()->CreateFillerObjectAt(junk_address, 175 isolate->heap()->CreateFillerObjectAt(junk_address,
190 reloc_end_address - junk_address); 176 reloc_end_address - junk_address);
191
192 // Add the deoptimizing code to the list.
193 DeoptimizingCodeListNode* node = new DeoptimizingCodeListNode(code);
194 DeoptimizerData* data = isolate->deoptimizer_data();
195 node->set_next(data->deoptimizing_code_list_);
196 data->deoptimizing_code_list_ = node;
197
198 // We might be in the middle of incremental marking with compaction.
199 // Tell collector to treat this code object in a special way and
200 // ignore all slots that might have been recorded on it.
201 isolate->heap()->mark_compact_collector()->InvalidateCode(code);
202
203 ReplaceCodeForRelatedFunctions(function, code);
204
205 if (FLAG_trace_deopt) {
206 PrintF("[forced deoptimization: ");
207 function->PrintName();
208 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function));
209 }
210 } 177 }
211 178
212 179
213 static const byte kJnsInstruction = 0x79; 180 static const byte kJnsInstruction = 0x79;
214 static const byte kJnsOffset = 0x11; 181 static const byte kJnsOffset = 0x11;
215 static const byte kCallInstruction = 0xe8; 182 static const byte kCallInstruction = 0xe8;
216 static const byte kNopByteOne = 0x66; 183 static const byte kNopByteOne = 0x66;
217 static const byte kNopByteTwo = 0x90; 184 static const byte kNopByteTwo = 0x90;
218 185
219 // The back edge bookkeeping code matches the pattern: 186 // The back edge bookkeeping code matches the pattern:
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } 707 }
741 __ bind(&done); 708 __ bind(&done);
742 } 709 }
743 710
744 #undef __ 711 #undef __
745 712
746 713
747 } } // namespace v8::internal 714 } } // namespace v8::internal
748 715
749 #endif // V8_TARGET_ARCH_IA32 716 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698