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

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

Issue 15740007: Add for-of Crankshaft support Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase onto master; fix AstTyper for ForOfStatement Created 7 years, 6 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/typing.cc ('k') | test/mjsunit/harmony/iteration-optimization.js » ('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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1232
1233 // var iterator = iterable[@@iterator]() 1233 // var iterator = iterable[@@iterator]()
1234 VisitForAccumulatorValue(stmt->assign_iterator()); 1234 VisitForAccumulatorValue(stmt->assign_iterator());
1235 1235
1236 // As with for-in, skip the loop if the iterator is null or undefined. 1236 // As with for-in, skip the loop if the iterator is null or undefined.
1237 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); 1237 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
1238 __ j(equal, loop_statement.break_label()); 1238 __ j(equal, loop_statement.break_label());
1239 __ CompareRoot(rax, Heap::kNullValueRootIndex); 1239 __ CompareRoot(rax, Heap::kNullValueRootIndex);
1240 __ j(equal, loop_statement.break_label()); 1240 __ j(equal, loop_statement.break_label());
1241 1241
1242 // Convert the iterator to a JS object.
1243 Label convert, done_convert;
1244 __ JumpIfSmi(rax, &convert);
1245 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx);
1246 __ j(above_equal, &done_convert);
1247 __ bind(&convert);
1248 __ push(rax);
1249 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
1250 __ bind(&done_convert);
1251
1252 // Loop entry. 1242 // Loop entry.
1253 __ bind(loop_statement.continue_label()); 1243 __ bind(loop_statement.continue_label());
1254 1244
1255 // result = iterator.next() 1245 // result = iterator.next()
1256 VisitForEffect(stmt->next_result()); 1246 VisitForEffect(stmt->next_result());
1257 1247
1258 // if (result.done) break; 1248 // if (result.done) break;
1259 Label result_not_done; 1249 Label result_not_done;
1260 VisitForControl(stmt->result_done(), 1250 VisitForControl(stmt->result_done(),
1261 loop_statement.break_label(), 1251 loop_statement.break_label(),
1262 &result_not_done, 1252 &result_not_done,
1263 &result_not_done); 1253 &result_not_done);
1264 __ bind(&result_not_done); 1254 __ bind(&result_not_done);
1265 1255
1256 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS);
1257
1266 // each = result.value 1258 // each = result.value
1267 VisitForEffect(stmt->assign_each()); 1259 VisitForEffect(stmt->assign_each());
1268 1260
1269 // Generate code for the body of the loop. 1261 // Generate code for the body of the loop.
1270 Visit(stmt->body()); 1262 Visit(stmt->body());
1271 1263
1272 // Check stack before looping. 1264 // Loop.
1273 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS);
1274 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); 1265 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label());
1275 __ jmp(loop_statement.continue_label()); 1266 __ jmp(loop_statement.continue_label());
1276 1267
1277 // Exit and decrement the loop depth. 1268 // Exit and decrement the loop depth.
1278 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1269 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1279 __ bind(loop_statement.break_label()); 1270 __ bind(loop_statement.break_label());
1280 decrement_loop_depth(); 1271 decrement_loop_depth();
1281 } 1272 }
1282 1273
1283 1274
(...skipping 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after
4916 *context_length = 0; 4907 *context_length = 0;
4917 return previous_; 4908 return previous_;
4918 } 4909 }
4919 4910
4920 4911
4921 #undef __ 4912 #undef __
4922 4913
4923 } } // namespace v8::internal 4914 } } // namespace v8::internal
4924 4915
4925 #endif // V8_TARGET_ARCH_X64 4916 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/typing.cc ('k') | test/mjsunit/harmony/iteration-optimization.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698