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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 __ test(eax, eax); | 1163 __ test(eax, eax); |
1163 __ j(equal, loop_statement.continue_label()); | 1164 __ j(equal, loop_statement.continue_label()); |
1164 __ mov(ebx, eax); | 1165 __ mov(ebx, eax); |
1165 | 1166 |
1166 // Update the 'each' property or variable from the possibly filtered | 1167 // Update the 'each' property or variable from the possibly filtered |
1167 // entry in register ebx. | 1168 // entry in register ebx. |
1168 __ bind(&update_each); | 1169 __ bind(&update_each); |
1169 __ mov(result_register(), ebx); | 1170 __ mov(result_register(), ebx); |
1170 // Perform the assignment as if via '='. | 1171 // Perform the assignment as if via '='. |
1171 { EffectContext context(this); | 1172 { EffectContext context(this); |
| 1173 SetExpressionPosition(stmt->each()); |
1172 EmitAssignment(stmt->each()); | 1174 EmitAssignment(stmt->each()); |
1173 } | 1175 } |
1174 | 1176 |
1175 // Generate code for the body of the loop. | 1177 // Generate code for the body of the loop. |
1176 Visit(stmt->body()); | 1178 Visit(stmt->body()); |
1177 | 1179 |
1178 // Generate code for going to the next element by incrementing the | 1180 // Generate code for going to the next element by incrementing the |
1179 // index (smi) stored on top of the stack. | 1181 // index (smi) stored on top of the stack. |
1180 __ bind(loop_statement.continue_label()); | 1182 __ bind(loop_statement.continue_label()); |
1181 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); | 1183 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); |
1182 | 1184 |
1183 EmitBackEdgeBookkeeping(stmt, &loop); | 1185 EmitBackEdgeBookkeeping(stmt, &loop); |
1184 __ jmp(&loop); | 1186 __ jmp(&loop); |
1185 | 1187 |
1186 // Remove the pointers stored on the stack. | 1188 // Remove the pointers stored on the stack. |
1187 __ bind(loop_statement.break_label()); | 1189 __ bind(loop_statement.break_label()); |
1188 __ add(esp, Immediate(5 * kPointerSize)); | 1190 __ add(esp, Immediate(5 * kPointerSize)); |
1189 | 1191 |
1190 // Exit and decrement the loop depth. | 1192 // Exit and decrement the loop depth. |
1191 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1193 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1192 __ bind(&exit); | 1194 __ bind(&exit); |
1193 decrement_loop_depth(); | 1195 decrement_loop_depth(); |
1194 } | 1196 } |
1195 | 1197 |
1196 | 1198 |
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, | 1199 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
1240 bool pretenure) { | 1200 bool pretenure) { |
1241 // Use the fast case closure allocation code that allocates in new | 1201 // Use the fast case closure allocation code that allocates in new |
1242 // space for nested functions that don't need literals cloning. If | 1202 // space for nested functions that don't need literals cloning. If |
1243 // we're running with the --always-opt or the --prepare-always-opt | 1203 // 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 | 1204 // 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 | 1205 // 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. | 1206 // doesn't just get a copy of the existing unoptimized code. |
1247 if (!FLAG_always_opt && | 1207 if (!FLAG_always_opt && |
1248 !FLAG_prepare_always_opt && | 1208 !FLAG_prepare_always_opt && |
(...skipping 3955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5204 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5164 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5205 Assembler::target_address_at(call_target_address, | 5165 Assembler::target_address_at(call_target_address, |
5206 unoptimized_code)); | 5166 unoptimized_code)); |
5207 return OSR_AFTER_STACK_CHECK; | 5167 return OSR_AFTER_STACK_CHECK; |
5208 } | 5168 } |
5209 | 5169 |
5210 | 5170 |
5211 } } // namespace v8::internal | 5171 } } // namespace v8::internal |
5212 | 5172 |
5213 #endif // V8_TARGET_ARCH_X87 | 5173 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |