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()); |
1105 VisitForAccumulatorValue(stmt->enumerable()); | 1106 VisitForAccumulatorValue(stmt->enumerable()); |
1106 __ mov(a0, result_register()); // Result as param to InvokeBuiltin below. | 1107 __ mov(a0, result_register()); // Result as param to InvokeBuiltin below. |
1107 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 1108 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
1108 __ Branch(&exit, eq, a0, Operand(at)); | 1109 __ Branch(&exit, eq, a0, Operand(at)); |
1109 Register null_value = t1; | 1110 Register null_value = t1; |
1110 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 1111 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
1111 __ Branch(&exit, eq, a0, Operand(null_value)); | 1112 __ Branch(&exit, eq, a0, Operand(null_value)); |
1112 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1113 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1113 __ mov(a0, v0); | 1114 __ mov(a0, v0); |
1114 // Convert the object to a JS object. | 1115 // Convert the object to a JS object. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 __ li(a1, Operand(Smi::FromInt(0))); // Zero indicates proxy | 1195 __ li(a1, Operand(Smi::FromInt(0))); // Zero indicates proxy |
1195 __ bind(&non_proxy); | 1196 __ bind(&non_proxy); |
1196 __ Push(a1, v0); // Smi and array | 1197 __ Push(a1, v0); // Smi and array |
1197 __ lw(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); | 1198 __ lw(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); |
1198 __ li(a0, Operand(Smi::FromInt(0))); | 1199 __ li(a0, Operand(Smi::FromInt(0))); |
1199 __ Push(a1, a0); // Fixed array length (as smi) and initial index. | 1200 __ Push(a1, a0); // Fixed array length (as smi) and initial index. |
1200 | 1201 |
1201 // Generate code for doing the condition check. | 1202 // Generate code for doing the condition check. |
1202 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1203 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
1203 __ bind(&loop); | 1204 __ bind(&loop); |
| 1205 SetExpressionPosition(stmt->each()); |
| 1206 |
1204 // Load the current count to a0, load the length to a1. | 1207 // Load the current count to a0, load the length to a1. |
1205 __ lw(a0, MemOperand(sp, 0 * kPointerSize)); | 1208 __ lw(a0, MemOperand(sp, 0 * kPointerSize)); |
1206 __ lw(a1, MemOperand(sp, 1 * kPointerSize)); | 1209 __ lw(a1, MemOperand(sp, 1 * kPointerSize)); |
1207 __ Branch(loop_statement.break_label(), hs, a0, Operand(a1)); | 1210 __ Branch(loop_statement.break_label(), hs, a0, Operand(a1)); |
1208 | 1211 |
1209 // Get the current entry of the array into register a3. | 1212 // Get the current entry of the array into register a3. |
1210 __ lw(a2, MemOperand(sp, 2 * kPointerSize)); | 1213 __ lw(a2, MemOperand(sp, 2 * kPointerSize)); |
1211 __ Addu(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 1214 __ Addu(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
1212 __ sll(t0, a0, kPointerSizeLog2 - kSmiTagSize); | 1215 __ sll(t0, a0, kPointerSizeLog2 - kSmiTagSize); |
1213 __ addu(t0, a2, t0); // Array base + scaled (smi) index. | 1216 __ addu(t0, a2, t0); // Array base + scaled (smi) index. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 __ bind(loop_statement.break_label()); | 1266 __ bind(loop_statement.break_label()); |
1264 __ Drop(5); | 1267 __ Drop(5); |
1265 | 1268 |
1266 // Exit and decrement the loop depth. | 1269 // Exit and decrement the loop depth. |
1267 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1270 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1268 __ bind(&exit); | 1271 __ bind(&exit); |
1269 decrement_loop_depth(); | 1272 decrement_loop_depth(); |
1270 } | 1273 } |
1271 | 1274 |
1272 | 1275 |
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 | |
1315 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1276 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1316 bool pretenure) { | 1277 bool pretenure) { |
1317 // Use the fast case closure allocation code that allocates in new | 1278 // Use the fast case closure allocation code that allocates in new |
1318 // space for nested functions that don't need literals cloning. If | 1279 // space for nested functions that don't need literals cloning. If |
1319 // we're running with the --always-opt or the --prepare-always-opt | 1280 // we're running with the --always-opt or the --prepare-always-opt |
1320 // flag, we need to use the runtime function so that the new function | 1281 // flag, we need to use the runtime function so that the new function |
1321 // we are creating here gets a chance to have its code optimized and | 1282 // we are creating here gets a chance to have its code optimized and |
1322 // doesn't just get a copy of the existing unoptimized code. | 1283 // doesn't just get a copy of the existing unoptimized code. |
1323 if (!FLAG_always_opt && | 1284 if (!FLAG_always_opt && |
1324 !FLAG_prepare_always_opt && | 1285 !FLAG_prepare_always_opt && |
(...skipping 3954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5279 Assembler::target_address_at(pc_immediate_load_address)) == | 5240 Assembler::target_address_at(pc_immediate_load_address)) == |
5280 reinterpret_cast<uint32_t>( | 5241 reinterpret_cast<uint32_t>( |
5281 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5242 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5282 return OSR_AFTER_STACK_CHECK; | 5243 return OSR_AFTER_STACK_CHECK; |
5283 } | 5244 } |
5284 | 5245 |
5285 | 5246 |
5286 } } // namespace v8::internal | 5247 } } // namespace v8::internal |
5287 | 5248 |
5288 #endif // V8_TARGET_ARCH_MIPS | 5249 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |