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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 1038 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
1039 | 1039 |
1040 SetStatementPosition(stmt); | 1040 SetStatementPosition(stmt); |
1041 | 1041 |
1042 Label loop, exit; | 1042 Label loop, exit; |
1043 ForIn loop_statement(this, stmt); | 1043 ForIn loop_statement(this, stmt); |
1044 increment_loop_depth(); | 1044 increment_loop_depth(); |
1045 | 1045 |
1046 // Get the object to enumerate over. If the object is null or undefined, skip | 1046 // Get the object to enumerate over. If the object is null or undefined, skip |
1047 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1047 // over the loop. See ECMA-262 version 5, section 12.6.4. |
| 1048 SetExpressionPosition(stmt->enumerable()); |
1048 VisitForAccumulatorValue(stmt->enumerable()); | 1049 VisitForAccumulatorValue(stmt->enumerable()); |
1049 __ cmp(eax, isolate()->factory()->undefined_value()); | 1050 __ cmp(eax, isolate()->factory()->undefined_value()); |
1050 __ j(equal, &exit); | 1051 __ j(equal, &exit); |
1051 __ cmp(eax, isolate()->factory()->null_value()); | 1052 __ cmp(eax, isolate()->factory()->null_value()); |
1052 __ j(equal, &exit); | 1053 __ j(equal, &exit); |
1053 | 1054 |
1054 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 1055 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
1055 | 1056 |
1056 // Convert the object to a JS object. | 1057 // Convert the object to a JS object. |
1057 Label convert, done_convert; | 1058 Label convert, done_convert; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 __ bind(&non_proxy); | 1133 __ bind(&non_proxy); |
1133 __ push(ebx); // Smi | 1134 __ push(ebx); // Smi |
1134 __ push(eax); // Array | 1135 __ push(eax); // Array |
1135 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); | 1136 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); |
1136 __ push(eax); // Fixed array length (as smi). | 1137 __ push(eax); // Fixed array length (as smi). |
1137 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1138 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
1138 | 1139 |
1139 // Generate code for doing the condition check. | 1140 // Generate code for doing the condition check. |
1140 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1141 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
1141 __ bind(&loop); | 1142 __ bind(&loop); |
| 1143 SetExpressionPosition(stmt->each()); |
| 1144 |
1142 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. | 1145 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. |
1143 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. | 1146 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. |
1144 __ j(above_equal, loop_statement.break_label()); | 1147 __ j(above_equal, loop_statement.break_label()); |
1145 | 1148 |
1146 // Get the current entry of the array into register ebx. | 1149 // Get the current entry of the array into register ebx. |
1147 __ mov(ebx, Operand(esp, 2 * kPointerSize)); | 1150 __ mov(ebx, Operand(esp, 2 * kPointerSize)); |
1148 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); | 1151 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); |
1149 | 1152 |
1150 // Get the expected map from the stack or a smi in the | 1153 // Get the expected map from the stack or a smi in the |
1151 // permanent slow case into register edx. | 1154 // permanent slow case into register edx. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 __ bind(loop_statement.break_label()); | 1201 __ bind(loop_statement.break_label()); |
1199 __ add(esp, Immediate(5 * kPointerSize)); | 1202 __ add(esp, Immediate(5 * kPointerSize)); |
1200 | 1203 |
1201 // Exit and decrement the loop depth. | 1204 // Exit and decrement the loop depth. |
1202 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1205 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1203 __ bind(&exit); | 1206 __ bind(&exit); |
1204 decrement_loop_depth(); | 1207 decrement_loop_depth(); |
1205 } | 1208 } |
1206 | 1209 |
1207 | 1210 |
1208 void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { | |
1209 Comment cmnt(masm_, "[ ForOfStatement"); | |
1210 SetStatementPosition(stmt); | |
1211 | |
1212 Iteration loop_statement(this, stmt); | |
1213 increment_loop_depth(); | |
1214 | |
1215 // var iterator = iterable[Symbol.iterator](); | |
1216 VisitForEffect(stmt->assign_iterator()); | |
1217 | |
1218 // Loop entry. | |
1219 __ bind(loop_statement.continue_label()); | |
1220 | |
1221 // result = iterator.next() | |
1222 VisitForEffect(stmt->next_result()); | |
1223 | |
1224 // if (result.done) break; | |
1225 Label result_not_done; | |
1226 VisitForControl(stmt->result_done(), | |
1227 loop_statement.break_label(), | |
1228 &result_not_done, | |
1229 &result_not_done); | |
1230 __ bind(&result_not_done); | |
1231 | |
1232 // each = result.value | |
1233 VisitForEffect(stmt->assign_each()); | |
1234 | |
1235 // Generate code for the body of the loop. | |
1236 Visit(stmt->body()); | |
1237 | |
1238 // Check stack before looping. | |
1239 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); | |
1240 EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); | |
1241 __ jmp(loop_statement.continue_label()); | |
1242 | |
1243 // Exit and decrement the loop depth. | |
1244 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | |
1245 __ bind(loop_statement.break_label()); | |
1246 decrement_loop_depth(); | |
1247 } | |
1248 | |
1249 | |
1250 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1211 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1251 bool pretenure) { | 1212 bool pretenure) { |
1252 // Use the fast case closure allocation code that allocates in new | 1213 // Use the fast case closure allocation code that allocates in new |
1253 // space for nested functions that don't need literals cloning. If | 1214 // space for nested functions that don't need literals cloning. If |
1254 // we're running with the --always-opt or the --prepare-always-opt | 1215 // we're running with the --always-opt or the --prepare-always-opt |
1255 // flag, we need to use the runtime function so that the new function | 1216 // flag, we need to use the runtime function so that the new function |
1256 // we are creating here gets a chance to have its code optimized and | 1217 // we are creating here gets a chance to have its code optimized and |
1257 // doesn't just get a copy of the existing unoptimized code. | 1218 // doesn't just get a copy of the existing unoptimized code. |
1258 if (!FLAG_always_opt && | 1219 if (!FLAG_always_opt && |
1259 !FLAG_prepare_always_opt && | 1220 !FLAG_prepare_always_opt && |
(...skipping 3958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5218 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5179 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5219 Assembler::target_address_at(call_target_address, | 5180 Assembler::target_address_at(call_target_address, |
5220 unoptimized_code)); | 5181 unoptimized_code)); |
5221 return OSR_AFTER_STACK_CHECK; | 5182 return OSR_AFTER_STACK_CHECK; |
5222 } | 5183 } |
5223 | 5184 |
5224 | 5185 |
5225 } } // namespace v8::internal | 5186 } } // namespace v8::internal |
5226 | 5187 |
5227 #endif // V8_TARGET_ARCH_IA32 | 5188 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |