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_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 1027 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
1028 | 1028 |
1029 SetStatementPosition(stmt); | 1029 SetStatementPosition(stmt); |
1030 | 1030 |
1031 Label loop, exit; | 1031 Label loop, exit; |
1032 ForIn loop_statement(this, stmt); | 1032 ForIn loop_statement(this, stmt); |
1033 increment_loop_depth(); | 1033 increment_loop_depth(); |
1034 | 1034 |
1035 // Get the object to enumerate over. If the object is null or undefined, skip | 1035 // Get the object to enumerate over. If the object is null or undefined, skip |
1036 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1036 // over the loop. See ECMA-262 version 5, section 12.6.4. |
| 1037 SetExpressionPosition(stmt->enumerable()); |
1037 VisitForAccumulatorValue(stmt->enumerable()); | 1038 VisitForAccumulatorValue(stmt->enumerable()); |
1038 __ cmp(eax, isolate()->factory()->undefined_value()); | 1039 __ cmp(eax, isolate()->factory()->undefined_value()); |
1039 __ j(equal, &exit); | 1040 __ j(equal, &exit); |
1040 __ cmp(eax, isolate()->factory()->null_value()); | 1041 __ cmp(eax, isolate()->factory()->null_value()); |
1041 __ j(equal, &exit); | 1042 __ j(equal, &exit); |
1042 | 1043 |
1043 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1044 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1044 | 1045 |
1045 // Convert the object to a JS object. | 1046 // Convert the object to a JS object. |
1046 Label convert, done_convert; | 1047 Label convert, done_convert; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 __ bind(&non_proxy); | 1122 __ bind(&non_proxy); |
1122 __ push(ebx); // Smi | 1123 __ push(ebx); // Smi |
1123 __ push(eax); // Array | 1124 __ push(eax); // Array |
1124 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); | 1125 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); |
1125 __ push(eax); // Fixed array length (as smi). | 1126 __ push(eax); // Fixed array length (as smi). |
1126 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1127 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
1127 | 1128 |
1128 // Generate code for doing the condition check. | 1129 // Generate code for doing the condition check. |
1129 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1130 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
1130 __ bind(&loop); | 1131 __ bind(&loop); |
| 1132 SetExpressionPosition(stmt->each()); |
| 1133 |
1131 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. | 1134 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. |
1132 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. | 1135 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. |
1133 __ j(above_equal, loop_statement.break_label()); | 1136 __ j(above_equal, loop_statement.break_label()); |
1134 | 1137 |
1135 // Get the current entry of the array into register ebx. | 1138 // Get the current entry of the array into register ebx. |
1136 __ mov(ebx, Operand(esp, 2 * kPointerSize)); | 1139 __ mov(ebx, Operand(esp, 2 * kPointerSize)); |
1137 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); | 1140 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); |
1138 | 1141 |
1139 // Get the expected map from the stack or a smi in the | 1142 // Get the expected map from the stack or a smi in the |
1140 // permanent slow case into register edx. | 1143 // permanent slow case into register edx. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 __ bind(loop_statement.break_label()); | 1190 __ bind(loop_statement.break_label()); |
1188 __ add(esp, Immediate(5 * kPointerSize)); | 1191 __ add(esp, Immediate(5 * kPointerSize)); |
1189 | 1192 |
1190 // Exit and decrement the loop depth. | 1193 // Exit and decrement the loop depth. |
1191 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1194 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1192 __ bind(&exit); | 1195 __ bind(&exit); |
1193 decrement_loop_depth(); | 1196 decrement_loop_depth(); |
1194 } | 1197 } |
1195 | 1198 |
1196 | 1199 |
1197 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { | |
1198 Comment cmnt(masm_, "[ ForOfStatement"); | |
1199 SetStatementPosition(stmt); | |
1200 | |
1201 Iteration loop_statement(this, stmt); | |
1202 increment_loop_depth(); | |
1203 | |
1204 // var iterator = iterable[Symbol.iterator](); | |
1205 VisitForEffect(stmt->assign_iterator()); | |
1206 | |
1207 // Loop entry. | |
1208 __ bind(loop_statement.continue_label()); | |
1209 | |
1210 // result = iterator.next() | |
1211 VisitForEffect(stmt->next_result()); | |
1212 | |
1213 // if (result.done) break; | |
1214 Label result_not_done; | |
1215 VisitForControl(stmt->result_done(), | |
1216 loop_statement.break_label(), | |
1217 &result_not_done, | |
1218 &result_not_done); | |
1219 __ bind(&result_not_done); | |
1220 | |
1221 // each = result.value | |
1222 VisitForEffect(stmt->assign_each()); | |
1223 | |
1224 // Generate code for the body of the loop. | |
1225 Visit(stmt->body()); | |
1226 | |
1227 // Check stack before looping. | |
1228 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); | |
1229 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); | |
1230 __ jmp(loop_statement.continue_label()); | |
1231 | |
1232 // Exit and decrement the loop depth. | |
1233 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1234 __ bind(loop_statement.break_label()); | |
1235 decrement_loop_depth(); | |
1236 } | |
1237 | |
1238 | |
1239 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1200 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1240 bool pretenure) { | 1201 bool pretenure) { |
1241 // Use the fast case closure allocation code that allocates in new | 1202 // Use the fast case closure allocation code that allocates in new |
1242 // space for nested functions that don't need literals cloning. If | 1203 // space for nested functions that don't need literals cloning. If |
1243 // we're running with the --always-opt or the --prepare-always-opt | 1204 // we're running with the --always-opt or the --prepare-always-opt |
1244 // flag, we need to use the runtime function so that the new function | 1205 // flag, we need to use the runtime function so that the new function |
1245 // we are creating here gets a chance to have its code optimized and | 1206 // we are creating here gets a chance to have its code optimized and |
1246 // doesn't just get a copy of the existing unoptimized code. | 1207 // doesn't just get a copy of the existing unoptimized code. |
1247 if (!FLAG_always_opt && | 1208 if (!FLAG_always_opt && |
1248 !FLAG_prepare_always_opt && | 1209 !FLAG_prepare_always_opt && |
(...skipping 3955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5204 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5165 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5205 Assembler::target_address_at(call_target_address, | 5166 Assembler::target_address_at(call_target_address, |
5206 unoptimized_code)); | 5167 unoptimized_code)); |
5207 return OSR_AFTER_STACK_CHECK; | 5168 return OSR_AFTER_STACK_CHECK; |
5208 } | 5169 } |
5209 | 5170 |
5210 | 5171 |
5211 } } // namespace v8::internal | 5172 } } // namespace v8::internal |
5212 | 5173 |
5213 #endif // V8_TARGET_ARCH_X87 | 5174 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |