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_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
10 // | 10 // |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 Comment cmnt(masm_, "[ ForInStatement"); | 1095 Comment cmnt(masm_, "[ ForInStatement"); |
1096 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 1096 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
1097 SetStatementPosition(stmt); | 1097 SetStatementPosition(stmt); |
1098 | 1098 |
1099 Label loop, exit; | 1099 Label loop, exit; |
1100 ForIn loop_statement(this, stmt); | 1100 ForIn loop_statement(this, stmt); |
1101 increment_loop_depth(); | 1101 increment_loop_depth(); |
1102 | 1102 |
1103 // Get the object to enumerate over. If the object is null or undefined, skip | 1103 // Get the object to enumerate over. If the object is null or undefined, skip |
1104 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1104 // over the loop. See ECMA-262 version 5, section 12.6.4. |
1105 SetExpressionPosition(stmt->enumerable()); | |
1106 VisitForAccumulatorValue(stmt->enumerable()); | 1105 VisitForAccumulatorValue(stmt->enumerable()); |
1107 __ mov(a0, result_register()); // Result as param to InvokeBuiltin below. | 1106 __ mov(a0, result_register()); // Result as param to InvokeBuiltin below. |
1108 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 1107 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
1109 __ Branch(&exit, eq, a0, Operand(at)); | 1108 __ Branch(&exit, eq, a0, Operand(at)); |
1110 Register null_value = t1; | 1109 Register null_value = t1; |
1111 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 1110 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
1112 __ Branch(&exit, eq, a0, Operand(null_value)); | 1111 __ Branch(&exit, eq, a0, Operand(null_value)); |
1113 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1112 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1114 __ mov(a0, v0); | 1113 __ mov(a0, v0); |
1115 // Convert the object to a JS object. | 1114 // Convert the object to a JS object. |
(...skipping 121 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(a3, result_register()); | 1237 __ mov(a3, result_register()); |
1239 __ Branch(loop_statement.continue_label(), eq, a3, Operand(zero_reg)); | 1238 __ Branch(loop_statement.continue_label(), eq, a3, Operand(zero_reg)); |
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 a3. | 1241 // entry in register a3. |
1243 __ bind(&update_each); | 1242 __ bind(&update_each); |
1244 __ mov(result_register(), a3); | 1243 __ mov(result_register(), a3); |
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 the going to the next element by incrementing | 1252 // Generate code for the 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 __ pop(a0); | 1255 __ pop(a0); |
1258 __ Addu(a0, a0, Operand(Smi::FromInt(1))); | 1256 __ Addu(a0, a0, Operand(Smi::FromInt(1))); |
1259 __ push(a0); | 1257 __ push(a0); |
1260 | 1258 |
1261 EmitBackEdgeBookkeeping(stmt, &loop); | 1259 EmitBackEdgeBookkeeping(stmt, &loop); |
1262 __ Branch(&loop); | 1260 __ Branch(&loop); |
1263 | 1261 |
1264 // Remove the pointers stored on the stack. | 1262 // Remove the pointers stored on the stack. |
1265 __ bind(loop_statement.break_label()); | 1263 __ bind(loop_statement.break_label()); |
1266 __ Drop(5); | 1264 __ Drop(5); |
1267 | 1265 |
1268 // Exit and decrement the loop depth. | 1266 // Exit and decrement the loop depth. |
1269 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1267 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1270 __ bind(&exit); | 1268 __ bind(&exit); |
1271 decrement_loop_depth(); | 1269 decrement_loop_depth(); |
1272 } | 1270 } |
1273 | 1271 |
1274 | 1272 |
| 1273 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
| 1274 Comment cmnt(masm_, "[ ForOfStatement"); |
| 1275 SetStatementPosition(stmt); |
| 1276 |
| 1277 Iteration loop_statement(this, stmt); |
| 1278 increment_loop_depth(); |
| 1279 |
| 1280 // var iterator = iterable[Symbol.iterator](); |
| 1281 VisitForEffect(stmt->assign_iterator()); |
| 1282 |
| 1283 // Loop entry. |
| 1284 __ bind(loop_statement.continue_label()); |
| 1285 |
| 1286 // result = iterator.next() |
| 1287 VisitForEffect(stmt->next_result()); |
| 1288 |
| 1289 // if (result.done) break; |
| 1290 Label result_not_done; |
| 1291 VisitForControl(stmt->result_done(), |
| 1292 loop_statement.break_label(), |
| 1293 &result_not_done, |
| 1294 &result_not_done); |
| 1295 __ bind(&result_not_done); |
| 1296 |
| 1297 // each = result.value |
| 1298 VisitForEffect(stmt->assign_each()); |
| 1299 |
| 1300 // Generate code for the body of the loop. |
| 1301 Visit(stmt->body()); |
| 1302 |
| 1303 // Check stack before looping. |
| 1304 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
| 1305 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); |
| 1306 __ jmp(loop_statement.continue_label()); |
| 1307 |
| 1308 // Exit and decrement the loop depth. |
| 1309 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 1310 __ bind(loop_statement.break_label()); |
| 1311 decrement_loop_depth(); |
| 1312 } |
| 1313 |
| 1314 |
1275 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1315 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1276 bool pretenure) { | 1316 bool pretenure) { |
1277 // Use the fast case closure allocation code that allocates in new | 1317 // Use the fast case closure allocation code that allocates in new |
1278 // space for nested functions that don't need literals cloning. If | 1318 // space for nested functions that don't need literals cloning. If |
1279 // we're running with the --always-opt or the --prepare-always-opt | 1319 // we're running with the --always-opt or the --prepare-always-opt |
1280 // flag, we need to use the runtime function so that the new function | 1320 // flag, we need to use the runtime function so that the new function |
1281 // we are creating here gets a chance to have its code optimized and | 1321 // we are creating here gets a chance to have its code optimized and |
1282 // doesn't just get a copy of the existing unoptimized code. | 1322 // doesn't just get a copy of the existing unoptimized code. |
1283 if (!FLAG_always_opt && | 1323 if (!FLAG_always_opt && |
1284 !FLAG_prepare_always_opt && | 1324 !FLAG_prepare_always_opt && |
(...skipping 3954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5239 Assembler::target_address_at(pc_immediate_load_address)) == | 5279 Assembler::target_address_at(pc_immediate_load_address)) == |
5240 reinterpret_cast<uint32_t>( | 5280 reinterpret_cast<uint32_t>( |
5241 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5281 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5242 return OSR_AFTER_STACK_CHECK; | 5282 return OSR_AFTER_STACK_CHECK; |
5243 } | 5283 } |
5244 | 5284 |
5245 | 5285 |
5246 } } // namespace v8::internal | 5286 } } // namespace v8::internal |
5247 | 5287 |
5248 #endif // V8_TARGET_ARCH_MIPS | 5288 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |