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()); |
1112 VisitForAccumulatorValue(stmt->enumerable()); | 1113 VisitForAccumulatorValue(stmt->enumerable()); |
1113 __ JumpIfRoot(x0, Heap::kUndefinedValueRootIndex, &exit); | 1114 __ JumpIfRoot(x0, Heap::kUndefinedValueRootIndex, &exit); |
1114 Register null_value = x15; | 1115 Register null_value = x15; |
1115 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 1116 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
1116 __ Cmp(x0, null_value); | 1117 __ Cmp(x0, null_value); |
1117 __ B(eq, &exit); | 1118 __ B(eq, &exit); |
1118 | 1119 |
1119 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1120 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1120 | 1121 |
1121 // Convert the object to a JS object. | 1122 // Convert the object to a JS object. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 __ CompareObjectType(x10, x11, x12, LAST_JS_PROXY_TYPE); | 1196 __ CompareObjectType(x10, x11, x12, LAST_JS_PROXY_TYPE); |
1196 DCHECK(Smi::FromInt(0) == 0); | 1197 DCHECK(Smi::FromInt(0) == 0); |
1197 __ CzeroX(x1, le); // Zero indicates proxy. | 1198 __ CzeroX(x1, le); // Zero indicates proxy. |
1198 __ Ldr(x2, FieldMemOperand(x0, FixedArray::kLengthOffset)); | 1199 __ Ldr(x2, FieldMemOperand(x0, FixedArray::kLengthOffset)); |
1199 // Smi and array, fixed array length (as smi) and initial index. | 1200 // Smi and array, fixed array length (as smi) and initial index. |
1200 __ Push(x1, x0, x2, xzr); | 1201 __ Push(x1, x0, x2, xzr); |
1201 | 1202 |
1202 // Generate code for doing the condition check. | 1203 // Generate code for doing the condition check. |
1203 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1204 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
1204 __ Bind(&loop); | 1205 __ Bind(&loop); |
| 1206 SetExpressionPosition(stmt->each()); |
| 1207 |
1205 // Load the current count to x0, load the length to x1. | 1208 // Load the current count to x0, load the length to x1. |
1206 __ PeekPair(x0, x1, 0); | 1209 __ PeekPair(x0, x1, 0); |
1207 __ Cmp(x0, x1); // Compare to the array length. | 1210 __ Cmp(x0, x1); // Compare to the array length. |
1208 __ B(hs, loop_statement.break_label()); | 1211 __ B(hs, loop_statement.break_label()); |
1209 | 1212 |
1210 // Get the current entry of the array into register r3. | 1213 // Get the current entry of the array into register r3. |
1211 __ Peek(x10, 2 * kXRegSize); | 1214 __ Peek(x10, 2 * kXRegSize); |
1212 __ Add(x10, x10, Operand::UntagSmiAndScale(x0, kPointerSizeLog2)); | 1215 __ Add(x10, x10, Operand::UntagSmiAndScale(x0, kPointerSizeLog2)); |
1213 __ Ldr(x3, MemOperand(x10, FixedArray::kHeaderSize - kHeapObjectTag)); | 1216 __ Ldr(x3, MemOperand(x10, FixedArray::kHeaderSize - kHeapObjectTag)); |
1214 | 1217 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 __ Bind(loop_statement.break_label()); | 1267 __ Bind(loop_statement.break_label()); |
1265 __ Drop(5); | 1268 __ Drop(5); |
1266 | 1269 |
1267 // Exit and decrement the loop depth. | 1270 // Exit and decrement the loop depth. |
1268 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1271 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1269 __ Bind(&exit); | 1272 __ Bind(&exit); |
1270 decrement_loop_depth(); | 1273 decrement_loop_depth(); |
1271 } | 1274 } |
1272 | 1275 |
1273 | 1276 |
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 | |
1316 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1277 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1317 bool pretenure) { | 1278 bool pretenure) { |
1318 // Use the fast case closure allocation code that allocates in new space for | 1279 // Use the fast case closure allocation code that allocates in new space for |
1319 // nested functions that don't need literals cloning. If we're running with | 1280 // nested functions that don't need literals cloning. If we're running with |
1320 // the --always-opt or the --prepare-always-opt flag, we need to use the | 1281 // the --always-opt or the --prepare-always-opt flag, we need to use the |
1321 // runtime function so that the new function we are creating here gets a | 1282 // runtime function so that the new function we are creating here gets a |
1322 // chance to have its code optimized and doesn't just get a copy of the | 1283 // chance to have its code optimized and doesn't just get a copy of the |
1323 // existing unoptimized code. | 1284 // existing unoptimized code. |
1324 if (!FLAG_always_opt && | 1285 if (!FLAG_always_opt && |
1325 !FLAG_prepare_always_opt && | 1286 !FLAG_prepare_always_opt && |
(...skipping 3997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5323 return previous_; | 5284 return previous_; |
5324 } | 5285 } |
5325 | 5286 |
5326 | 5287 |
5327 #undef __ | 5288 #undef __ |
5328 | 5289 |
5329 | 5290 |
5330 } } // namespace v8::internal | 5291 } } // namespace v8::internal |
5331 | 5292 |
5332 #endif // V8_TARGET_ARCH_ARM64 | 5293 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |