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

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

Issue 15288011: Baseline for-of implementation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: s/syntax/semantics/ 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 | « no previous file | src/ast.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 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 1074
1075 1075
1076 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { 1076 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
1077 Comment cmnt(masm_, "[ ForInStatement"); 1077 Comment cmnt(masm_, "[ ForInStatement");
1078 SetStatementPosition(stmt); 1078 SetStatementPosition(stmt);
1079 1079
1080 Label loop, exit; 1080 Label loop, exit;
1081 ForIn loop_statement(this, stmt); 1081 ForIn loop_statement(this, stmt);
1082 increment_loop_depth(); 1082 increment_loop_depth();
1083 1083
1084 // Get the object to enumerate over. Both SpiderMonkey and JSC 1084 // Get the object to enumerate over. If the object is null or undefined, skip
1085 // ignore null and undefined in contrast to the specification; see 1085 // over the loop. See ECMA-262 version 5, section 12.6.4.
1086 // ECMA-262 section 12.6.4.
1087 VisitForAccumulatorValue(stmt->enumerable()); 1086 VisitForAccumulatorValue(stmt->enumerable());
1088 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 1087 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
1089 __ cmp(r0, ip); 1088 __ cmp(r0, ip);
1090 __ b(eq, &exit); 1089 __ b(eq, &exit);
1091 Register null_value = r5; 1090 Register null_value = r5;
1092 __ LoadRoot(null_value, Heap::kNullValueRootIndex); 1091 __ LoadRoot(null_value, Heap::kNullValueRootIndex);
1093 __ cmp(r0, null_value); 1092 __ cmp(r0, null_value);
1094 __ b(eq, &exit); 1093 __ b(eq, &exit);
1095 1094
1096 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); 1095 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 __ bind(loop_statement.break_label()); 1251 __ bind(loop_statement.break_label());
1253 __ Drop(5); 1252 __ Drop(5);
1254 1253
1255 // Exit and decrement the loop depth. 1254 // Exit and decrement the loop depth.
1256 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1255 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1257 __ bind(&exit); 1256 __ bind(&exit);
1258 decrement_loop_depth(); 1257 decrement_loop_depth();
1259 } 1258 }
1260 1259
1261 1260
1261 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) {
1262 Comment cmnt(masm_, "[ ForOfStatement");
1263 SetStatementPosition(stmt);
1264
1265 Iteration loop_statement(this, stmt);
1266 increment_loop_depth();
1267
1268 // var iterator = iterable[@@iterator]()
1269 VisitForAccumulatorValue(stmt->assign_iterator());
1270
1271 // As with for-in, skip the loop if the iterator is null or undefined.
1272 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex);
1273 __ b(eq, loop_statement.break_label());
1274 __ CompareRoot(r0, Heap::kNullValueRootIndex);
1275 __ b(eq, loop_statement.break_label());
1276
1277 // Convert the iterator to a JS object.
1278 Label convert, done_convert;
1279 __ JumpIfSmi(r0, &convert);
1280 __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE);
1281 __ b(ge, &done_convert);
1282 __ bind(&convert);
1283 __ push(r0);
1284 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
1285 __ bind(&done_convert);
1286 __ push(r0);
1287
1288 // Loop entry.
1289 __ bind(loop_statement.continue_label());
1290
1291 // result = iterator.next()
1292 VisitForEffect(stmt->next_result());
1293
1294 // if (result.done) break;
1295 Label result_not_done;
1296 VisitForControl(stmt->result_done(),
1297 loop_statement.break_label(),
1298 &result_not_done,
1299 &result_not_done);
1300 __ bind(&result_not_done);
1301
1302 // each = result.value
1303 VisitForEffect(stmt->assign_each());
1304
1305 // Generate code for the body of the loop.
1306 Visit(stmt->body());
1307
1308 // Check stack before looping.
1309 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS);
1310 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label());
1311 __ jmp(loop_statement.continue_label());
1312
1313 // Exit and decrement the loop depth.
1314 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1315 __ bind(loop_statement.break_label());
1316 decrement_loop_depth();
1317 }
1318
1319
1262 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, 1320 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
1263 bool pretenure) { 1321 bool pretenure) {
1264 // Use the fast case closure allocation code that allocates in new 1322 // Use the fast case closure allocation code that allocates in new
1265 // space for nested functions that don't need literals cloning. If 1323 // space for nested functions that don't need literals cloning. If
1266 // we're running with the --always-opt or the --prepare-always-opt 1324 // we're running with the --always-opt or the --prepare-always-opt
1267 // flag, we need to use the runtime function so that the new function 1325 // flag, we need to use the runtime function so that the new function
1268 // we are creating here gets a chance to have its code optimized and 1326 // we are creating here gets a chance to have its code optimized and
1269 // doesn't just get a copy of the existing unoptimized code. 1327 // doesn't just get a copy of the existing unoptimized code.
1270 if (!FLAG_always_opt && 1328 if (!FLAG_always_opt &&
1271 !FLAG_prepare_always_opt && 1329 !FLAG_prepare_always_opt &&
(...skipping 3605 matching lines...) Expand 10 before | Expand all | Expand 10 after
4877 *context_length = 0; 4935 *context_length = 0;
4878 return previous_; 4936 return previous_;
4879 } 4937 }
4880 4938
4881 4939
4882 #undef __ 4940 #undef __
4883 4941
4884 } } // namespace v8::internal 4942 } } // namespace v8::internal
4885 4943
4886 #endif // V8_TARGET_ARCH_ARM 4944 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698