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_ARM | 7 #if V8_TARGET_ARCH_ARM |
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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 Comment cmnt(masm_, "[ ForInStatement"); | 1104 Comment cmnt(masm_, "[ ForInStatement"); |
1105 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 1105 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
1106 SetStatementPosition(stmt); | 1106 SetStatementPosition(stmt); |
1107 | 1107 |
1108 Label loop, exit; | 1108 Label loop, exit; |
1109 ForIn loop_statement(this, stmt); | 1109 ForIn loop_statement(this, stmt); |
1110 increment_loop_depth(); | 1110 increment_loop_depth(); |
1111 | 1111 |
1112 // Get the object to enumerate over. If the object is null or undefined, skip | 1112 // Get the object to enumerate over. If the object is null or undefined, skip |
1113 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1113 // over the loop. See ECMA-262 version 5, section 12.6.4. |
1114 SetExpressionPosition(stmt->enumerable()); | |
1115 VisitForAccumulatorValue(stmt->enumerable()); | 1114 VisitForAccumulatorValue(stmt->enumerable()); |
1116 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 1115 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
1117 __ cmp(r0, ip); | 1116 __ cmp(r0, ip); |
1118 __ b(eq, &exit); | 1117 __ b(eq, &exit); |
1119 Register null_value = r5; | 1118 Register null_value = r5; |
1120 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 1119 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
1121 __ cmp(r0, null_value); | 1120 __ cmp(r0, null_value); |
1122 __ b(eq, &exit); | 1121 __ b(eq, &exit); |
1123 | 1122 |
1124 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1123 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); | 1249 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); |
1251 __ mov(r3, Operand(r0), SetCC); | 1250 __ mov(r3, Operand(r0), SetCC); |
1252 __ b(eq, loop_statement.continue_label()); | 1251 __ b(eq, loop_statement.continue_label()); |
1253 | 1252 |
1254 // Update the 'each' property or variable from the possibly filtered | 1253 // Update the 'each' property or variable from the possibly filtered |
1255 // entry in register r3. | 1254 // entry in register r3. |
1256 __ bind(&update_each); | 1255 __ bind(&update_each); |
1257 __ mov(result_register(), r3); | 1256 __ mov(result_register(), r3); |
1258 // Perform the assignment as if via '='. | 1257 // Perform the assignment as if via '='. |
1259 { EffectContext context(this); | 1258 { EffectContext context(this); |
1260 SetExpressionPosition(stmt->each()); | |
1261 EmitAssignment(stmt->each()); | 1259 EmitAssignment(stmt->each()); |
1262 } | 1260 } |
1263 | 1261 |
1264 // Generate code for the body of the loop. | 1262 // Generate code for the body of the loop. |
1265 Visit(stmt->body()); | 1263 Visit(stmt->body()); |
1266 | 1264 |
1267 // Generate code for the going to the next element by incrementing | 1265 // Generate code for the going to the next element by incrementing |
1268 // the index (smi) stored on top of the stack. | 1266 // the index (smi) stored on top of the stack. |
1269 __ bind(loop_statement.continue_label()); | 1267 __ bind(loop_statement.continue_label()); |
1270 __ pop(r0); | 1268 __ pop(r0); |
1271 __ add(r0, r0, Operand(Smi::FromInt(1))); | 1269 __ add(r0, r0, Operand(Smi::FromInt(1))); |
1272 __ push(r0); | 1270 __ push(r0); |
1273 | 1271 |
1274 EmitBackEdgeBookkeeping(stmt, &loop); | 1272 EmitBackEdgeBookkeeping(stmt, &loop); |
1275 __ b(&loop); | 1273 __ b(&loop); |
1276 | 1274 |
1277 // Remove the pointers stored on the stack. | 1275 // Remove the pointers stored on the stack. |
1278 __ bind(loop_statement.break_label()); | 1276 __ bind(loop_statement.break_label()); |
1279 __ Drop(5); | 1277 __ Drop(5); |
1280 | 1278 |
1281 // Exit and decrement the loop depth. | 1279 // Exit and decrement the loop depth. |
1282 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1280 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1283 __ bind(&exit); | 1281 __ bind(&exit); |
1284 decrement_loop_depth(); | 1282 decrement_loop_depth(); |
1285 } | 1283 } |
1286 | 1284 |
1287 | 1285 |
| 1286 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
| 1287 Comment cmnt(masm_, "[ ForOfStatement"); |
| 1288 SetStatementPosition(stmt); |
| 1289 |
| 1290 Iteration loop_statement(this, stmt); |
| 1291 increment_loop_depth(); |
| 1292 |
| 1293 // var iterator = iterable[Symbol.iterator](); |
| 1294 VisitForEffect(stmt->assign_iterator()); |
| 1295 |
| 1296 // Loop entry. |
| 1297 __ bind(loop_statement.continue_label()); |
| 1298 |
| 1299 // result = iterator.next() |
| 1300 VisitForEffect(stmt->next_result()); |
| 1301 |
| 1302 // if (result.done) break; |
| 1303 Label result_not_done; |
| 1304 VisitForControl(stmt->result_done(), |
| 1305 loop_statement.break_label(), |
| 1306 &result_not_done, |
| 1307 &result_not_done); |
| 1308 __ bind(&result_not_done); |
| 1309 |
| 1310 // each = result.value |
| 1311 VisitForEffect(stmt->assign_each()); |
| 1312 |
| 1313 // Generate code for the body of the loop. |
| 1314 Visit(stmt->body()); |
| 1315 |
| 1316 // Check stack before looping. |
| 1317 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
| 1318 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); |
| 1319 __ jmp(loop_statement.continue_label()); |
| 1320 |
| 1321 // Exit and decrement the loop depth. |
| 1322 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 1323 __ bind(loop_statement.break_label()); |
| 1324 decrement_loop_depth(); |
| 1325 } |
| 1326 |
| 1327 |
1288 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1328 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1289 bool pretenure) { | 1329 bool pretenure) { |
1290 // Use the fast case closure allocation code that allocates in new | 1330 // Use the fast case closure allocation code that allocates in new |
1291 // space for nested functions that don't need literals cloning. If | 1331 // space for nested functions that don't need literals cloning. If |
1292 // we're running with the --always-opt or the --prepare-always-opt | 1332 // we're running with the --always-opt or the --prepare-always-opt |
1293 // flag, we need to use the runtime function so that the new function | 1333 // flag, we need to use the runtime function so that the new function |
1294 // we are creating here gets a chance to have its code optimized and | 1334 // we are creating here gets a chance to have its code optimized and |
1295 // doesn't just get a copy of the existing unoptimized code. | 1335 // doesn't just get a copy of the existing unoptimized code. |
1296 if (!FLAG_always_opt && | 1336 if (!FLAG_always_opt && |
1297 !FLAG_prepare_always_opt && | 1337 !FLAG_prepare_always_opt && |
(...skipping 4003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5301 | 5341 |
5302 DCHECK(interrupt_address == | 5342 DCHECK(interrupt_address == |
5303 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5343 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5304 return OSR_AFTER_STACK_CHECK; | 5344 return OSR_AFTER_STACK_CHECK; |
5305 } | 5345 } |
5306 | 5346 |
5307 | 5347 |
5308 } } // namespace v8::internal | 5348 } } // namespace v8::internal |
5309 | 5349 |
5310 #endif // V8_TARGET_ARCH_ARM | 5350 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |