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

Side by Side Diff: src/x64/fast-codegen-x64.cc

Issue 651031: Begin using a list of bailouts instead of a singleton in the fast code generator. (Closed)
Patch Set: Created 10 years, 10 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
« src/ia32/fast-codegen-ia32.h ('K') | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (is_smi(accumulator0()) && is_smi(accumulator1())) { 149 if (is_smi(accumulator0()) && is_smi(accumulator1())) {
150 // If both operands are known to be a smi then there is no need to check 150 // If both operands are known to be a smi then there is no need to check
151 // the operands or result. 151 // the operands or result.
152 if (destination().is(no_reg)) { 152 if (destination().is(no_reg)) {
153 __ or_(accumulator1(), accumulator0()); 153 __ or_(accumulator1(), accumulator0());
154 } else { 154 } else {
155 // Leave the result in the destination register. Bitwise or is 155 // Leave the result in the destination register. Bitwise or is
156 // commutative. 156 // commutative.
157 __ or_(destination(), other_accumulator(destination())); 157 __ or_(destination(), other_accumulator(destination()));
158 } 158 }
159 } else if (destination().is(no_reg)) {
160 // Result is not needed but do not clobber the operands in case of
161 // bailout.
162 __ movq(scratch0(), accumulator1());
163 __ or_(scratch0(), accumulator0());
164 __ JumpIfNotSmi(scratch0(), bailout());
165 } else { 159 } else {
166 // Preserve the destination operand in a scratch register in case of 160 // Left is in accumulator1, right in accumulator0.
167 // bailout. 161 if (destination().is(accumulator0())) {
168 __ movq(scratch0(), destination()); 162 __ movq(scratch0(), accumulator0());
169 __ or_(destination(), other_accumulator(destination())); 163 __ or_(destination(), accumulator1()); // Or is commutative.
170 __ JumpIfNotSmi(destination(), bailout()); 164 Label* bailout =
165 info()->AddBailout(accumulator1(), scratch0()); // Left, right.
166 __ JumpIfNotSmi(destination(), bailout);
167 } else if (destination().is(accumulator1())) {
168 __ movq(scratch0(), accumulator1());
169 __ or_(destination(), accumulator0());
170 Label* bailout = info()->AddBailout(scratch0(), accumulator0());
171 __ JumpIfNotSmi(destination(), bailout);
172 } else {
173 ASSERT(destination().is(no_reg));
174 __ movq(scratch0(), accumulator1());
175 __ or_(scratch0(), accumulator0());
176 Label* bailout = info()->AddBailout(accumulator1(), accumulator0());
177 __ JumpIfNotSmi(scratch0(), bailout);
178 }
171 } 179 }
172 180
173
174 // If we didn't bailout, the result (in fact, both inputs too) is known to 181 // If we didn't bailout, the result (in fact, both inputs too) is known to
175 // be a smi. 182 // be a smi.
176 set_as_smi(accumulator0()); 183 set_as_smi(accumulator0());
177 set_as_smi(accumulator1()); 184 set_as_smi(accumulator1());
178 } 185 }
179 186
180 187
181 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) { 188 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) {
182 ASSERT(info_ == NULL); 189 ASSERT(info_ == NULL);
183 info_ = compilation_info; 190 info_ = compilation_info;
184 191
185 // Save the caller's frame pointer and set up our own. 192 // Save the caller's frame pointer and set up our own.
186 Comment prologue_cmnt(masm(), ";; Prologue"); 193 Comment prologue_cmnt(masm(), ";; Prologue");
187 __ push(rbp); 194 __ push(rbp);
188 __ movq(rbp, rsp); 195 __ movq(rbp, rsp);
189 __ push(rsi); // Context. 196 __ push(rsi); // Context.
190 __ push(rdi); // Closure. 197 __ push(rdi); // Closure.
191 // Note that we keep a live register reference to esi (context) at this 198 // Note that we keep a live register reference to esi (context) at this
192 // point. 199 // point.
193 200
201 Label* bailout_to_beginning = info()->AddBailout();
194 // Receiver (this) is allocated to a fixed register. 202 // Receiver (this) is allocated to a fixed register.
195 if (info()->has_this_properties()) { 203 if (info()->has_this_properties()) {
196 Comment cmnt(masm(), ";; MapCheck(this)"); 204 Comment cmnt(masm(), ";; MapCheck(this)");
197 if (FLAG_print_ir) { 205 if (FLAG_print_ir) {
198 PrintF("MapCheck(this)\n"); 206 PrintF("MapCheck(this)\n");
199 } 207 }
200 ASSERT(info()->has_receiver() && info()->receiver()->IsHeapObject()); 208 ASSERT(info()->has_receiver() && info()->receiver()->IsHeapObject());
201 Handle<HeapObject> object = Handle<HeapObject>::cast(info()->receiver()); 209 Handle<HeapObject> object = Handle<HeapObject>::cast(info()->receiver());
202 Handle<Map> map(object->map()); 210 Handle<Map> map(object->map());
203 EmitLoadReceiver(); 211 EmitLoadReceiver();
204 __ CheckMap(receiver_reg(), map, bailout(), false); 212 __ CheckMap(receiver_reg(), map, bailout_to_beginning, false);
205 } 213 }
206 214
207 // If there is a global variable access check if the global object is the 215 // If there is a global variable access check if the global object is the
208 // same as at lazy-compilation time. 216 // same as at lazy-compilation time.
209 if (info()->has_globals()) { 217 if (info()->has_globals()) {
210 Comment cmnt(masm(), ";; MapCheck(GLOBAL)"); 218 Comment cmnt(masm(), ";; MapCheck(GLOBAL)");
211 if (FLAG_print_ir) { 219 if (FLAG_print_ir) {
212 PrintF("MapCheck(GLOBAL)\n"); 220 PrintF("MapCheck(GLOBAL)\n");
213 } 221 }
214 ASSERT(info()->has_global_object()); 222 ASSERT(info()->has_global_object());
215 Handle<Map> map(info()->global_object()->map()); 223 Handle<Map> map(info()->global_object()->map());
216 __ movq(scratch0(), CodeGenerator::GlobalObject()); 224 __ movq(scratch0(), CodeGenerator::GlobalObject());
217 __ CheckMap(scratch0(), map, bailout(), true); 225 __ CheckMap(scratch0(), map, bailout_to_beginning, true);
218 } 226 }
219 227
220 VisitStatements(info()->function()->body()); 228 VisitStatements(info()->function()->body());
221 229
222 Comment return_cmnt(masm(), ";; Return(<undefined>)"); 230 Comment return_cmnt(masm(), ";; Return(<undefined>)");
223 if (FLAG_print_ir) { 231 if (FLAG_print_ir) {
224 PrintF("Return(<undefined>)\n"); 232 PrintF("Return(<undefined>)\n");
225 } 233 }
226 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 234 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
227 __ movq(rsp, rbp); 235 __ movq(rsp, rbp);
228 __ pop(rbp); 236 __ pop(rbp);
229 __ ret((scope()->num_parameters() + 1) * kPointerSize); 237 __ ret((scope()->num_parameters() + 1) * kPointerSize);
230
231 __ bind(&bailout_);
232 } 238 }
233 239
234 240
235 #undef __ 241 #undef __
236 242
237 243
238 } } // namespace v8::internal 244 } } // namespace v8::internal
OLDNEW
« src/ia32/fast-codegen-ia32.h ('K') | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698