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

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

Issue 682413004: Fix stepping in for-loops. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/full-codegen.cc ('k') | src/mips/full-codegen-mips.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_IA32 7 #if V8_TARGET_ARCH_IA32
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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); 1038 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot();
1039 1039
1040 SetStatementPosition(stmt); 1040 SetStatementPosition(stmt);
1041 1041
1042 Label loop, exit; 1042 Label loop, exit;
1043 ForIn loop_statement(this, stmt); 1043 ForIn loop_statement(this, stmt);
1044 increment_loop_depth(); 1044 increment_loop_depth();
1045 1045
1046 // Get the object to enumerate over. If the object is null or undefined, skip 1046 // Get the object to enumerate over. If the object is null or undefined, skip
1047 // over the loop. See ECMA-262 version 5, section 12.6.4. 1047 // over the loop. See ECMA-262 version 5, section 12.6.4.
1048 SetExpressionPosition(stmt->enumerable());
1048 VisitForAccumulatorValue(stmt->enumerable()); 1049 VisitForAccumulatorValue(stmt->enumerable());
1049 __ cmp(eax, isolate()->factory()->undefined_value()); 1050 __ cmp(eax, isolate()->factory()->undefined_value());
1050 __ j(equal, &exit); 1051 __ j(equal, &exit);
1051 __ cmp(eax, isolate()->factory()->null_value()); 1052 __ cmp(eax, isolate()->factory()->null_value());
1052 __ j(equal, &exit); 1053 __ j(equal, &exit);
1053 1054
1054 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); 1055 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG);
1055 1056
1056 // Convert the object to a JS object. 1057 // Convert the object to a JS object.
1057 Label convert, done_convert; 1058 Label convert, done_convert;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 __ test(eax, eax); 1174 __ test(eax, eax);
1174 __ j(equal, loop_statement.continue_label()); 1175 __ j(equal, loop_statement.continue_label());
1175 __ mov(ebx, eax); 1176 __ mov(ebx, eax);
1176 1177
1177 // Update the 'each' property or variable from the possibly filtered 1178 // Update the 'each' property or variable from the possibly filtered
1178 // entry in register ebx. 1179 // entry in register ebx.
1179 __ bind(&update_each); 1180 __ bind(&update_each);
1180 __ mov(result_register(), ebx); 1181 __ mov(result_register(), ebx);
1181 // Perform the assignment as if via '='. 1182 // Perform the assignment as if via '='.
1182 { EffectContext context(this); 1183 { EffectContext context(this);
1184 SetExpressionPosition(stmt->each());
1183 EmitAssignment(stmt->each()); 1185 EmitAssignment(stmt->each());
1184 } 1186 }
1185 1187
1186 // Generate code for the body of the loop. 1188 // Generate code for the body of the loop.
1187 Visit(stmt->body()); 1189 Visit(stmt->body());
1188 1190
1189 // Generate code for going to the next element by incrementing the 1191 // Generate code for going to the next element by incrementing the
1190 // index (smi) stored on top of the stack. 1192 // index (smi) stored on top of the stack.
1191 __ bind(loop_statement.continue_label()); 1193 __ bind(loop_statement.continue_label());
1192 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); 1194 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1)));
1193 1195
1194 EmitBackEdgeBookkeeping(stmt, &loop); 1196 EmitBackEdgeBookkeeping(stmt, &loop);
1195 __ jmp(&loop); 1197 __ jmp(&loop);
1196 1198
1197 // Remove the pointers stored on the stack. 1199 // Remove the pointers stored on the stack.
1198 __ bind(loop_statement.break_label()); 1200 __ bind(loop_statement.break_label());
1199 __ add(esp, Immediate(5 * kPointerSize)); 1201 __ add(esp, Immediate(5 * kPointerSize));
1200 1202
1201 // Exit and decrement the loop depth. 1203 // Exit and decrement the loop depth.
1202 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1204 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1203 __ bind(&exit); 1205 __ bind(&exit);
1204 decrement_loop_depth(); 1206 decrement_loop_depth();
1205 } 1207 }
1206 1208
1207 1209
1208 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) {
1209 Comment cmnt(masm_, "[ ForOfStatement");
1210 SetStatementPosition(stmt);
1211
1212 Iteration loop_statement(this, stmt);
1213 increment_loop_depth();
1214
1215 // var iterator = iterable[Symbol.iterator]();
1216 VisitForEffect(stmt->assign_iterator());
1217
1218 // Loop entry.
1219 __ bind(loop_statement.continue_label());
1220
1221 // result = iterator.next()
1222 VisitForEffect(stmt->next_result());
1223
1224 // if (result.done) break;
1225 Label result_not_done;
1226 VisitForControl(stmt->result_done(),
1227 loop_statement.break_label(),
1228 &result_not_done,
1229 &result_not_done);
1230 __ bind(&result_not_done);
1231
1232 // each = result.value
1233 VisitForEffect(stmt->assign_each());
1234
1235 // Generate code for the body of the loop.
1236 Visit(stmt->body());
1237
1238 // Check stack before looping.
1239 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS);
1240 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label());
1241 __ jmp(loop_statement.continue_label());
1242
1243 // Exit and decrement the loop depth.
1244 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1245 __ bind(loop_statement.break_label());
1246 decrement_loop_depth();
1247 }
1248
1249
1250 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, 1210 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
1251 bool pretenure) { 1211 bool pretenure) {
1252 // Use the fast case closure allocation code that allocates in new 1212 // Use the fast case closure allocation code that allocates in new
1253 // space for nested functions that don't need literals cloning. If 1213 // space for nested functions that don't need literals cloning. If
1254 // we're running with the --always-opt or the --prepare-always-opt 1214 // we're running with the --always-opt or the --prepare-always-opt
1255 // flag, we need to use the runtime function so that the new function 1215 // flag, we need to use the runtime function so that the new function
1256 // we are creating here gets a chance to have its code optimized and 1216 // we are creating here gets a chance to have its code optimized and
1257 // doesn't just get a copy of the existing unoptimized code. 1217 // doesn't just get a copy of the existing unoptimized code.
1258 if (!FLAG_always_opt && 1218 if (!FLAG_always_opt &&
1259 !FLAG_prepare_always_opt && 1219 !FLAG_prepare_always_opt &&
(...skipping 3958 matching lines...) Expand 10 before | Expand all | Expand 10 after
5218 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5178 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5219 Assembler::target_address_at(call_target_address, 5179 Assembler::target_address_at(call_target_address,
5220 unoptimized_code)); 5180 unoptimized_code));
5221 return OSR_AFTER_STACK_CHECK; 5181 return OSR_AFTER_STACK_CHECK;
5222 } 5182 }
5223 5183
5224 5184
5225 } } // namespace v8::internal 5185 } } // namespace v8::internal
5226 5186
5227 #endif // V8_TARGET_ARCH_IA32 5187 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698