OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
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 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 1102 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
1103 // TODO(all): This visitor probably needs better comments and a revisit. | 1103 // TODO(all): This visitor probably needs better comments and a revisit. |
1104 SetStatementPosition(stmt); | 1104 SetStatementPosition(stmt); |
1105 | 1105 |
1106 Label loop, exit; | 1106 Label loop, exit; |
1107 ForIn loop_statement(this, stmt); | 1107 ForIn loop_statement(this, stmt); |
1108 increment_loop_depth(); | 1108 increment_loop_depth(); |
1109 | 1109 |
1110 // Get the object to enumerate over. If the object is null or undefined, skip | 1110 // Get the object to enumerate over. If the object is null or undefined, skip |
1111 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1111 // over the loop. See ECMA-262 version 5, section 12.6.4. |
1112 SetExpressionPosition(stmt->enumerable()); | |
1113 VisitForAccumulatorValue(stmt->enumerable()); | 1112 VisitForAccumulatorValue(stmt->enumerable()); |
1114 __ JumpIfRoot(x0, Heap::kUndefinedValueRootIndex, &exit); | 1113 __ JumpIfRoot(x0, Heap::kUndefinedValueRootIndex, &exit); |
1115 Register null_value = x15; | 1114 Register null_value = x15; |
1116 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 1115 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
1117 __ Cmp(x0, null_value); | 1116 __ Cmp(x0, null_value); |
1118 __ B(eq, &exit); | 1117 __ B(eq, &exit); |
1119 | 1118 |
1120 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1119 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1121 | 1120 |
1122 // Convert the object to a JS object. | 1121 // Convert the object to a JS object. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); | 1236 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); |
1238 __ Mov(x3, x0); | 1237 __ Mov(x3, x0); |
1239 __ Cbz(x0, loop_statement.continue_label()); | 1238 __ Cbz(x0, loop_statement.continue_label()); |
1240 | 1239 |
1241 // Update the 'each' property or variable from the possibly filtered | 1240 // Update the 'each' property or variable from the possibly filtered |
1242 // entry in register x3. | 1241 // entry in register x3. |
1243 __ Bind(&update_each); | 1242 __ Bind(&update_each); |
1244 __ Mov(result_register(), x3); | 1243 __ Mov(result_register(), x3); |
1245 // Perform the assignment as if via '='. | 1244 // Perform the assignment as if via '='. |
1246 { EffectContext context(this); | 1245 { EffectContext context(this); |
1247 SetExpressionPosition(stmt->each()); | |
1248 EmitAssignment(stmt->each()); | 1246 EmitAssignment(stmt->each()); |
1249 } | 1247 } |
1250 | 1248 |
1251 // Generate code for the body of the loop. | 1249 // Generate code for the body of the loop. |
1252 Visit(stmt->body()); | 1250 Visit(stmt->body()); |
1253 | 1251 |
1254 // Generate code for going to the next element by incrementing | 1252 // Generate code for going to the next element by incrementing |
1255 // the index (smi) stored on top of the stack. | 1253 // the index (smi) stored on top of the stack. |
1256 __ Bind(loop_statement.continue_label()); | 1254 __ Bind(loop_statement.continue_label()); |
1257 // TODO(all): We could use a callee saved register to avoid popping. | 1255 // TODO(all): We could use a callee saved register to avoid popping. |
1258 __ Pop(x0); | 1256 __ Pop(x0); |
1259 __ Add(x0, x0, Smi::FromInt(1)); | 1257 __ Add(x0, x0, Smi::FromInt(1)); |
1260 __ Push(x0); | 1258 __ Push(x0); |
1261 | 1259 |
1262 EmitBackEdgeBookkeeping(stmt, &loop); | 1260 EmitBackEdgeBookkeeping(stmt, &loop); |
1263 __ B(&loop); | 1261 __ B(&loop); |
1264 | 1262 |
1265 // Remove the pointers stored on the stack. | 1263 // Remove the pointers stored on the stack. |
1266 __ Bind(loop_statement.break_label()); | 1264 __ Bind(loop_statement.break_label()); |
1267 __ Drop(5); | 1265 __ Drop(5); |
1268 | 1266 |
1269 // Exit and decrement the loop depth. | 1267 // Exit and decrement the loop depth. |
1270 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1268 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1271 __ Bind(&exit); | 1269 __ Bind(&exit); |
1272 decrement_loop_depth(); | 1270 decrement_loop_depth(); |
1273 } | 1271 } |
1274 | 1272 |
1275 | 1273 |
| 1274 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
| 1275 Comment cmnt(masm_, "[ ForOfStatement"); |
| 1276 SetStatementPosition(stmt); |
| 1277 |
| 1278 Iteration loop_statement(this, stmt); |
| 1279 increment_loop_depth(); |
| 1280 |
| 1281 // var iterator = iterable[Symbol.iterator](); |
| 1282 VisitForEffect(stmt->assign_iterator()); |
| 1283 |
| 1284 // Loop entry. |
| 1285 __ Bind(loop_statement.continue_label()); |
| 1286 |
| 1287 // result = iterator.next() |
| 1288 VisitForEffect(stmt->next_result()); |
| 1289 |
| 1290 // if (result.done) break; |
| 1291 Label result_not_done; |
| 1292 VisitForControl(stmt->result_done(), |
| 1293 loop_statement.break_label(), |
| 1294 &result_not_done, |
| 1295 &result_not_done); |
| 1296 __ Bind(&result_not_done); |
| 1297 |
| 1298 // each = result.value |
| 1299 VisitForEffect(stmt->assign_each()); |
| 1300 |
| 1301 // Generate code for the body of the loop. |
| 1302 Visit(stmt->body()); |
| 1303 |
| 1304 // Check stack before looping. |
| 1305 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
| 1306 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); |
| 1307 __ B(loop_statement.continue_label()); |
| 1308 |
| 1309 // Exit and decrement the loop depth. |
| 1310 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 1311 __ Bind(loop_statement.break_label()); |
| 1312 decrement_loop_depth(); |
| 1313 } |
| 1314 |
| 1315 |
1276 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1316 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1277 bool pretenure) { | 1317 bool pretenure) { |
1278 // Use the fast case closure allocation code that allocates in new space for | 1318 // Use the fast case closure allocation code that allocates in new space for |
1279 // nested functions that don't need literals cloning. If we're running with | 1319 // nested functions that don't need literals cloning. If we're running with |
1280 // the --always-opt or the --prepare-always-opt flag, we need to use the | 1320 // the --always-opt or the --prepare-always-opt flag, we need to use the |
1281 // runtime function so that the new function we are creating here gets a | 1321 // runtime function so that the new function we are creating here gets a |
1282 // chance to have its code optimized and doesn't just get a copy of the | 1322 // chance to have its code optimized and doesn't just get a copy of the |
1283 // existing unoptimized code. | 1323 // existing unoptimized code. |
1284 if (!FLAG_always_opt && | 1324 if (!FLAG_always_opt && |
1285 !FLAG_prepare_always_opt && | 1325 !FLAG_prepare_always_opt && |
(...skipping 3997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5283 return previous_; | 5323 return previous_; |
5284 } | 5324 } |
5285 | 5325 |
5286 | 5326 |
5287 #undef __ | 5327 #undef __ |
5288 | 5328 |
5289 | 5329 |
5290 } } // namespace v8::internal | 5330 } } // namespace v8::internal |
5291 | 5331 |
5292 #endif // V8_TARGET_ARCH_ARM64 | 5332 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |