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

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

Issue 688243005: Reland "Fix stepping in for-loops." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 1 month 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/parser.cc ('k') | src/x87/full-codegen-x87.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 Comment cmnt(masm_, "[ ForInStatement"); 1060 Comment cmnt(masm_, "[ ForInStatement");
1061 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); 1061 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot();
1062 SetStatementPosition(stmt); 1062 SetStatementPosition(stmt);
1063 1063
1064 Label loop, exit; 1064 Label loop, exit;
1065 ForIn loop_statement(this, stmt); 1065 ForIn loop_statement(this, stmt);
1066 increment_loop_depth(); 1066 increment_loop_depth();
1067 1067
1068 // Get the object to enumerate over. If the object is null or undefined, skip 1068 // Get the object to enumerate over. If the object is null or undefined, skip
1069 // over the loop. See ECMA-262 version 5, section 12.6.4. 1069 // over the loop. See ECMA-262 version 5, section 12.6.4.
1070 SetExpressionPosition(stmt->enumerable());
1070 VisitForAccumulatorValue(stmt->enumerable()); 1071 VisitForAccumulatorValue(stmt->enumerable());
1071 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); 1072 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
1072 __ j(equal, &exit); 1073 __ j(equal, &exit);
1073 Register null_value = rdi; 1074 Register null_value = rdi;
1074 __ LoadRoot(null_value, Heap::kNullValueRootIndex); 1075 __ LoadRoot(null_value, Heap::kNullValueRootIndex);
1075 __ cmpp(rax, null_value); 1076 __ cmpp(rax, null_value);
1076 __ j(equal, &exit); 1077 __ j(equal, &exit);
1077 1078
1078 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); 1079 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG);
1079 1080
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 __ bind(&non_proxy); 1164 __ bind(&non_proxy);
1164 __ Push(rbx); // Smi 1165 __ Push(rbx); // Smi
1165 __ Push(rax); // Array 1166 __ Push(rax); // Array
1166 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset)); 1167 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset));
1167 __ Push(rax); // Fixed array length (as smi). 1168 __ Push(rax); // Fixed array length (as smi).
1168 __ Push(Smi::FromInt(0)); // Initial index. 1169 __ Push(Smi::FromInt(0)); // Initial index.
1169 1170
1170 // Generate code for doing the condition check. 1171 // Generate code for doing the condition check.
1171 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); 1172 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS);
1172 __ bind(&loop); 1173 __ bind(&loop);
1174 SetExpressionPosition(stmt->each());
1175
1173 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index. 1176 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index.
1174 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length. 1177 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length.
1175 __ j(above_equal, loop_statement.break_label()); 1178 __ j(above_equal, loop_statement.break_label());
1176 1179
1177 // Get the current entry of the array into register rbx. 1180 // Get the current entry of the array into register rbx.
1178 __ movp(rbx, Operand(rsp, 2 * kPointerSize)); 1181 __ movp(rbx, Operand(rsp, 2 * kPointerSize));
1179 SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2); 1182 SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2);
1180 __ movp(rbx, FieldOperand(rbx, 1183 __ movp(rbx, FieldOperand(rbx,
1181 index.reg, 1184 index.reg,
1182 index.scale, 1185 index.scale,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 __ bind(loop_statement.break_label()); 1235 __ bind(loop_statement.break_label());
1233 __ addp(rsp, Immediate(5 * kPointerSize)); 1236 __ addp(rsp, Immediate(5 * kPointerSize));
1234 1237
1235 // Exit and decrement the loop depth. 1238 // Exit and decrement the loop depth.
1236 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1239 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1237 __ bind(&exit); 1240 __ bind(&exit);
1238 decrement_loop_depth(); 1241 decrement_loop_depth();
1239 } 1242 }
1240 1243
1241 1244
1242 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) {
1243 Comment cmnt(masm_, "[ ForOfStatement");
1244 SetStatementPosition(stmt);
1245
1246 Iteration loop_statement(this, stmt);
1247 increment_loop_depth();
1248
1249 // var iterator = iterable[Symbol.iterator]();
1250 VisitForEffect(stmt->assign_iterator());
1251
1252 // Loop entry.
1253 __ bind(loop_statement.continue_label());
1254
1255 // result = iterator.next()
1256 VisitForEffect(stmt->next_result());
1257
1258 // if (result.done) break;
1259 Label result_not_done;
1260 VisitForControl(stmt->result_done(),
1261 loop_statement.break_label(),
1262 &result_not_done,
1263 &result_not_done);
1264 __ bind(&result_not_done);
1265
1266 // each = result.value
1267 VisitForEffect(stmt->assign_each());
1268
1269 // Generate code for the body of the loop.
1270 Visit(stmt->body());
1271
1272 // Check stack before looping.
1273 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS);
1274 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label());
1275 __ jmp(loop_statement.continue_label());
1276
1277 // Exit and decrement the loop depth.
1278 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1279 __ bind(loop_statement.break_label());
1280 decrement_loop_depth();
1281 }
1282
1283
1284 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, 1245 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
1285 bool pretenure) { 1246 bool pretenure) {
1286 // Use the fast case closure allocation code that allocates in new 1247 // Use the fast case closure allocation code that allocates in new
1287 // space for nested functions that don't need literals cloning. If 1248 // space for nested functions that don't need literals cloning. If
1288 // we're running with the --always-opt or the --prepare-always-opt 1249 // we're running with the --always-opt or the --prepare-always-opt
1289 // flag, we need to use the runtime function so that the new function 1250 // flag, we need to use the runtime function so that the new function
1290 // we are creating here gets a chance to have its code optimized and 1251 // we are creating here gets a chance to have its code optimized and
1291 // doesn't just get a copy of the existing unoptimized code. 1252 // doesn't just get a copy of the existing unoptimized code.
1292 if (!FLAG_always_opt && 1253 if (!FLAG_always_opt &&
1293 !FLAG_prepare_always_opt && 1254 !FLAG_prepare_always_opt &&
(...skipping 3940 matching lines...) Expand 10 before | Expand all | Expand 10 after
5234 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5195 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5235 Assembler::target_address_at(call_target_address, 5196 Assembler::target_address_at(call_target_address,
5236 unoptimized_code)); 5197 unoptimized_code));
5237 return OSR_AFTER_STACK_CHECK; 5198 return OSR_AFTER_STACK_CHECK;
5238 } 5199 }
5239 5200
5240 5201
5241 } } // namespace v8::internal 5202 } } // namespace v8::internal
5242 5203
5243 #endif // V8_TARGET_ARCH_X64 5204 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/x87/full-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698