OLD | NEW |
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 Loading... |
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()); | |
1071 VisitForAccumulatorValue(stmt->enumerable()); | 1070 VisitForAccumulatorValue(stmt->enumerable()); |
1072 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 1071 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
1073 __ j(equal, &exit); | 1072 __ j(equal, &exit); |
1074 Register null_value = rdi; | 1073 Register null_value = rdi; |
1075 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 1074 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
1076 __ cmpp(rax, null_value); | 1075 __ cmpp(rax, null_value); |
1077 __ j(equal, &exit); | 1076 __ j(equal, &exit); |
1078 | 1077 |
1079 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1078 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1080 | 1079 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 __ Cmp(rax, Smi::FromInt(0)); | 1207 __ Cmp(rax, Smi::FromInt(0)); |
1209 __ j(equal, loop_statement.continue_label()); | 1208 __ j(equal, loop_statement.continue_label()); |
1210 __ movp(rbx, rax); | 1209 __ movp(rbx, rax); |
1211 | 1210 |
1212 // Update the 'each' property or variable from the possibly filtered | 1211 // Update the 'each' property or variable from the possibly filtered |
1213 // entry in register rbx. | 1212 // entry in register rbx. |
1214 __ bind(&update_each); | 1213 __ bind(&update_each); |
1215 __ movp(result_register(), rbx); | 1214 __ movp(result_register(), rbx); |
1216 // Perform the assignment as if via '='. | 1215 // Perform the assignment as if via '='. |
1217 { EffectContext context(this); | 1216 { EffectContext context(this); |
1218 SetExpressionPosition(stmt->each()); | |
1219 EmitAssignment(stmt->each()); | 1217 EmitAssignment(stmt->each()); |
1220 } | 1218 } |
1221 | 1219 |
1222 // Generate code for the body of the loop. | 1220 // Generate code for the body of the loop. |
1223 Visit(stmt->body()); | 1221 Visit(stmt->body()); |
1224 | 1222 |
1225 // Generate code for going to the next element by incrementing the | 1223 // Generate code for going to the next element by incrementing the |
1226 // index (smi) stored on top of the stack. | 1224 // index (smi) stored on top of the stack. |
1227 __ bind(loop_statement.continue_label()); | 1225 __ bind(loop_statement.continue_label()); |
1228 __ SmiAddConstant(Operand(rsp, 0 * kPointerSize), Smi::FromInt(1)); | 1226 __ SmiAddConstant(Operand(rsp, 0 * kPointerSize), Smi::FromInt(1)); |
1229 | 1227 |
1230 EmitBackEdgeBookkeeping(stmt, &loop); | 1228 EmitBackEdgeBookkeeping(stmt, &loop); |
1231 __ jmp(&loop); | 1229 __ jmp(&loop); |
1232 | 1230 |
1233 // Remove the pointers stored on the stack. | 1231 // Remove the pointers stored on the stack. |
1234 __ bind(loop_statement.break_label()); | 1232 __ bind(loop_statement.break_label()); |
1235 __ addp(rsp, Immediate(5 * kPointerSize)); | 1233 __ addp(rsp, Immediate(5 * kPointerSize)); |
1236 | 1234 |
1237 // Exit and decrement the loop depth. | 1235 // Exit and decrement the loop depth. |
1238 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1236 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1239 __ bind(&exit); | 1237 __ bind(&exit); |
1240 decrement_loop_depth(); | 1238 decrement_loop_depth(); |
1241 } | 1239 } |
1242 | 1240 |
1243 | 1241 |
| 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 |
1244 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1284 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1245 bool pretenure) { | 1285 bool pretenure) { |
1246 // Use the fast case closure allocation code that allocates in new | 1286 // Use the fast case closure allocation code that allocates in new |
1247 // space for nested functions that don't need literals cloning. If | 1287 // space for nested functions that don't need literals cloning. If |
1248 // we're running with the --always-opt or the --prepare-always-opt | 1288 // we're running with the --always-opt or the --prepare-always-opt |
1249 // flag, we need to use the runtime function so that the new function | 1289 // flag, we need to use the runtime function so that the new function |
1250 // we are creating here gets a chance to have its code optimized and | 1290 // we are creating here gets a chance to have its code optimized and |
1251 // doesn't just get a copy of the existing unoptimized code. | 1291 // doesn't just get a copy of the existing unoptimized code. |
1252 if (!FLAG_always_opt && | 1292 if (!FLAG_always_opt && |
1253 !FLAG_prepare_always_opt && | 1293 !FLAG_prepare_always_opt && |
(...skipping 3940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5194 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5234 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5195 Assembler::target_address_at(call_target_address, | 5235 Assembler::target_address_at(call_target_address, |
5196 unoptimized_code)); | 5236 unoptimized_code)); |
5197 return OSR_AFTER_STACK_CHECK; | 5237 return OSR_AFTER_STACK_CHECK; |
5198 } | 5238 } |
5199 | 5239 |
5200 | 5240 |
5201 } } // namespace v8::internal | 5241 } } // namespace v8::internal |
5202 | 5242 |
5203 #endif // V8_TARGET_ARCH_X64 | 5243 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |