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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Possibly allocate a local context. | 161 // Possibly allocate a local context. |
162 if (info->scope()->num_heap_slots() > 0) { | 162 if (info->scope()->num_heap_slots() > 0) { |
163 Comment cmnt(masm_, "[ Allocate context"); | 163 Comment cmnt(masm_, "[ Allocate context"); |
164 bool need_write_barrier = true; | 164 bool need_write_barrier = true; |
165 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 165 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
166 // Argument to NewContext is the function, which is still in edi. | 166 // Argument to NewContext is the function, which is still in edi. |
167 if (info->scope()->is_script_scope()) { | 167 if (info->scope()->is_script_scope()) { |
168 __ push(edi); | 168 __ push(edi); |
169 __ Push(info->scope()->GetScopeInfo(info->isolate())); | 169 __ Push(info->scope()->GetScopeInfo(info->isolate())); |
170 __ CallRuntime(Runtime::kNewScriptContext); | 170 __ CallRuntime(Runtime::kNewScriptContext); |
171 PrepareForBailoutForId(BailoutId::ScriptContext(), TOS_REG); | 171 PrepareForBailoutForId(BailoutId::ScriptContext(), |
| 172 BailoutState::TOS_REGISTER); |
172 // The new target value is not used, clobbering is safe. | 173 // The new target value is not used, clobbering is safe. |
173 DCHECK_NULL(info->scope()->new_target_var()); | 174 DCHECK_NULL(info->scope()->new_target_var()); |
174 } else { | 175 } else { |
175 if (info->scope()->new_target_var() != nullptr) { | 176 if (info->scope()->new_target_var() != nullptr) { |
176 __ push(edx); // Preserve new target. | 177 __ push(edx); // Preserve new target. |
177 } | 178 } |
178 if (slots <= FastNewContextStub::kMaximumSlots) { | 179 if (slots <= FastNewContextStub::kMaximumSlots) { |
179 FastNewContextStub stub(isolate(), slots); | 180 FastNewContextStub stub(isolate(), slots); |
180 __ CallStub(&stub); | 181 __ CallStub(&stub); |
181 // Result of FastNewContextStub is always in new space. | 182 // Result of FastNewContextStub is always in new space. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 __ Abort(kExpectedNewSpaceObject); | 221 __ Abort(kExpectedNewSpaceObject); |
221 __ bind(&done); | 222 __ bind(&done); |
222 } | 223 } |
223 } | 224 } |
224 } | 225 } |
225 } | 226 } |
226 | 227 |
227 // Register holding this function and new target are both trashed in case we | 228 // Register holding this function and new target are both trashed in case we |
228 // bailout here. But since that can happen only when new target is not used | 229 // bailout here. But since that can happen only when new target is not used |
229 // and we allocate a context, the value of |function_in_register| is correct. | 230 // and we allocate a context, the value of |function_in_register| is correct. |
230 PrepareForBailoutForId(BailoutId::FunctionContext(), NO_REGISTERS); | 231 PrepareForBailoutForId(BailoutId::FunctionContext(), |
| 232 BailoutState::NO_REGISTERS); |
231 | 233 |
232 // Possibly set up a local binding to the this function which is used in | 234 // Possibly set up a local binding to the this function which is used in |
233 // derived constructors with super calls. | 235 // derived constructors with super calls. |
234 Variable* this_function_var = scope()->this_function_var(); | 236 Variable* this_function_var = scope()->this_function_var(); |
235 if (this_function_var != nullptr) { | 237 if (this_function_var != nullptr) { |
236 Comment cmnt(masm_, "[ This function"); | 238 Comment cmnt(masm_, "[ This function"); |
237 if (!function_in_register) { | 239 if (!function_in_register) { |
238 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 240 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
239 // The write barrier clobbers register again, keep it marked as such. | 241 // The write barrier clobbers register again, keep it marked as such. |
240 } | 242 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 284 } |
283 | 285 |
284 SetVar(arguments, eax, ebx, edx); | 286 SetVar(arguments, eax, ebx, edx); |
285 } | 287 } |
286 | 288 |
287 if (FLAG_trace) { | 289 if (FLAG_trace) { |
288 __ CallRuntime(Runtime::kTraceEnter); | 290 __ CallRuntime(Runtime::kTraceEnter); |
289 } | 291 } |
290 | 292 |
291 // Visit the declarations and body. | 293 // Visit the declarations and body. |
292 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); | 294 PrepareForBailoutForId(BailoutId::FunctionEntry(), |
| 295 BailoutState::NO_REGISTERS); |
293 { | 296 { |
294 Comment cmnt(masm_, "[ Declarations"); | 297 Comment cmnt(masm_, "[ Declarations"); |
295 VisitDeclarations(scope()->declarations()); | 298 VisitDeclarations(scope()->declarations()); |
296 } | 299 } |
297 | 300 |
298 // Assert that the declarations do not use ICs. Otherwise the debugger | 301 // Assert that the declarations do not use ICs. Otherwise the debugger |
299 // won't be able to redirect a PC at an IC to the correct IC in newly | 302 // won't be able to redirect a PC at an IC to the correct IC in newly |
300 // recompiled code. | 303 // recompiled code. |
301 DCHECK_EQ(0, ic_total_count_); | 304 DCHECK_EQ(0, ic_total_count_); |
302 | 305 |
303 { | 306 { |
304 Comment cmnt(masm_, "[ Stack check"); | 307 Comment cmnt(masm_, "[ Stack check"); |
305 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); | 308 PrepareForBailoutForId(BailoutId::Declarations(), |
| 309 BailoutState::NO_REGISTERS); |
306 Label ok; | 310 Label ok; |
307 ExternalReference stack_limit = | 311 ExternalReference stack_limit = |
308 ExternalReference::address_of_stack_limit(isolate()); | 312 ExternalReference::address_of_stack_limit(isolate()); |
309 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 313 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
310 __ j(above_equal, &ok, Label::kNear); | 314 __ j(above_equal, &ok, Label::kNear); |
311 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); | 315 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); |
312 __ bind(&ok); | 316 __ bind(&ok); |
313 } | 317 } |
314 | 318 |
315 { | 319 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 __ call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); | 366 __ call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
363 | 367 |
364 // Record a mapping of this PC offset to the OSR id. This is used to find | 368 // Record a mapping of this PC offset to the OSR id. This is used to find |
365 // the AST id from the unoptimized code in order to use it as a key into | 369 // the AST id from the unoptimized code in order to use it as a key into |
366 // the deoptimization input data found in the optimized code. | 370 // the deoptimization input data found in the optimized code. |
367 RecordBackEdge(stmt->OsrEntryId()); | 371 RecordBackEdge(stmt->OsrEntryId()); |
368 | 372 |
369 EmitProfilingCounterReset(); | 373 EmitProfilingCounterReset(); |
370 | 374 |
371 __ bind(&ok); | 375 __ bind(&ok); |
372 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 376 PrepareForBailoutForId(stmt->EntryId(), BailoutState::NO_REGISTERS); |
373 // Record a mapping of the OSR id to this PC. This is used if the OSR | 377 // Record a mapping of the OSR id to this PC. This is used if the OSR |
374 // entry becomes the target of a bailout. We don't expect it to be, but | 378 // entry becomes the target of a bailout. We don't expect it to be, but |
375 // we want it to work if it is. | 379 // we want it to work if it is. |
376 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); | 380 PrepareForBailoutForId(stmt->OsrEntryId(), BailoutState::NO_REGISTERS); |
377 } | 381 } |
378 | 382 |
379 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( | 383 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( |
380 bool is_tail_call) { | 384 bool is_tail_call) { |
381 // Pretend that the exit is a backwards jump to the entry. | 385 // Pretend that the exit is a backwards jump to the entry. |
382 int weight = 1; | 386 int weight = 1; |
383 if (info_->ShouldSelfOptimize()) { | 387 if (info_->ShouldSelfOptimize()) { |
384 weight = FLAG_interrupt_budget / FLAG_self_opt_count; | 388 weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
385 } else { | 389 } else { |
386 int distance = masm_->pc_offset(); | 390 int distance = masm_->pc_offset(); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 bool should_normalize, | 677 bool should_normalize, |
674 Label* if_true, | 678 Label* if_true, |
675 Label* if_false) { | 679 Label* if_false) { |
676 // Only prepare for bailouts before splits if we're in a test | 680 // Only prepare for bailouts before splits if we're in a test |
677 // context. Otherwise, we let the Visit function deal with the | 681 // context. Otherwise, we let the Visit function deal with the |
678 // preparation to avoid preparing with the same AST id twice. | 682 // preparation to avoid preparing with the same AST id twice. |
679 if (!context()->IsTest()) return; | 683 if (!context()->IsTest()) return; |
680 | 684 |
681 Label skip; | 685 Label skip; |
682 if (should_normalize) __ jmp(&skip, Label::kNear); | 686 if (should_normalize) __ jmp(&skip, Label::kNear); |
683 PrepareForBailout(expr, TOS_REG); | 687 PrepareForBailout(expr, BailoutState::TOS_REGISTER); |
684 if (should_normalize) { | 688 if (should_normalize) { |
685 __ cmp(eax, isolate()->factory()->true_value()); | 689 __ cmp(eax, isolate()->factory()->true_value()); |
686 Split(equal, if_true, if_false, NULL); | 690 Split(equal, if_true, if_false, NULL); |
687 __ bind(&skip); | 691 __ bind(&skip); |
688 } | 692 } |
689 } | 693 } |
690 | 694 |
691 | 695 |
692 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { | 696 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
693 // The variable in the declaration always resides in the current context. | 697 // The variable in the declaration always resides in the current context. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 } | 733 } |
730 break; | 734 break; |
731 | 735 |
732 case VariableLocation::CONTEXT: | 736 case VariableLocation::CONTEXT: |
733 if (hole_init) { | 737 if (hole_init) { |
734 Comment cmnt(masm_, "[ VariableDeclaration"); | 738 Comment cmnt(masm_, "[ VariableDeclaration"); |
735 EmitDebugCheckDeclarationContext(variable); | 739 EmitDebugCheckDeclarationContext(variable); |
736 __ mov(ContextOperand(esi, variable->index()), | 740 __ mov(ContextOperand(esi, variable->index()), |
737 Immediate(isolate()->factory()->the_hole_value())); | 741 Immediate(isolate()->factory()->the_hole_value())); |
738 // No write barrier since the hole value is in old space. | 742 // No write barrier since the hole value is in old space. |
739 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 743 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
740 } | 744 } |
741 break; | 745 break; |
742 | 746 |
743 case VariableLocation::LOOKUP: { | 747 case VariableLocation::LOOKUP: { |
744 Comment cmnt(masm_, "[ VariableDeclaration"); | 748 Comment cmnt(masm_, "[ VariableDeclaration"); |
745 __ push(Immediate(variable->name())); | 749 __ push(Immediate(variable->name())); |
746 // VariableDeclaration nodes are always introduced in one of four modes. | 750 // VariableDeclaration nodes are always introduced in one of four modes. |
747 DCHECK(IsDeclaredVariableMode(mode)); | 751 DCHECK(IsDeclaredVariableMode(mode)); |
748 // Push initial value, if any. | 752 // Push initial value, if any. |
749 // Note: For variables we must not push an initial value (such as | 753 // Note: For variables we must not push an initial value (such as |
750 // 'undefined') because we may have a (legal) redeclaration and we | 754 // 'undefined') because we may have a (legal) redeclaration and we |
751 // must not destroy the current value. | 755 // must not destroy the current value. |
752 if (hole_init) { | 756 if (hole_init) { |
753 __ push(Immediate(isolate()->factory()->the_hole_value())); | 757 __ push(Immediate(isolate()->factory()->the_hole_value())); |
754 } else { | 758 } else { |
755 __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value. | 759 __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value. |
756 } | 760 } |
757 __ push( | 761 __ push( |
758 Immediate(Smi::FromInt(variable->DeclarationPropertyAttributes()))); | 762 Immediate(Smi::FromInt(variable->DeclarationPropertyAttributes()))); |
759 __ CallRuntime(Runtime::kDeclareLookupSlot); | 763 __ CallRuntime(Runtime::kDeclareLookupSlot); |
760 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 764 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
761 break; | 765 break; |
762 } | 766 } |
763 } | 767 } |
764 } | 768 } |
765 | 769 |
766 | 770 |
767 void FullCodeGenerator::VisitFunctionDeclaration( | 771 void FullCodeGenerator::VisitFunctionDeclaration( |
768 FunctionDeclaration* declaration) { | 772 FunctionDeclaration* declaration) { |
769 VariableProxy* proxy = declaration->proxy(); | 773 VariableProxy* proxy = declaration->proxy(); |
770 Variable* variable = proxy->var(); | 774 Variable* variable = proxy->var(); |
(...skipping 23 matching lines...) Expand all Loading... |
794 VisitForAccumulatorValue(declaration->fun()); | 798 VisitForAccumulatorValue(declaration->fun()); |
795 __ mov(ContextOperand(esi, variable->index()), result_register()); | 799 __ mov(ContextOperand(esi, variable->index()), result_register()); |
796 // We know that we have written a function, which is not a smi. | 800 // We know that we have written a function, which is not a smi. |
797 __ RecordWriteContextSlot(esi, | 801 __ RecordWriteContextSlot(esi, |
798 Context::SlotOffset(variable->index()), | 802 Context::SlotOffset(variable->index()), |
799 result_register(), | 803 result_register(), |
800 ecx, | 804 ecx, |
801 kDontSaveFPRegs, | 805 kDontSaveFPRegs, |
802 EMIT_REMEMBERED_SET, | 806 EMIT_REMEMBERED_SET, |
803 OMIT_SMI_CHECK); | 807 OMIT_SMI_CHECK); |
804 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 808 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
805 break; | 809 break; |
806 } | 810 } |
807 | 811 |
808 case VariableLocation::LOOKUP: { | 812 case VariableLocation::LOOKUP: { |
809 Comment cmnt(masm_, "[ FunctionDeclaration"); | 813 Comment cmnt(masm_, "[ FunctionDeclaration"); |
810 PushOperand(variable->name()); | 814 PushOperand(variable->name()); |
811 VisitForStackValue(declaration->fun()); | 815 VisitForStackValue(declaration->fun()); |
812 PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes())); | 816 PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes())); |
813 CallRuntimeWithOperands(Runtime::kDeclareLookupSlot); | 817 CallRuntimeWithOperands(Runtime::kDeclareLookupSlot); |
814 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 818 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
815 break; | 819 break; |
816 } | 820 } |
817 } | 821 } |
818 } | 822 } |
819 | 823 |
820 | 824 |
821 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 825 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
822 // Call the runtime to declare the globals. | 826 // Call the runtime to declare the globals. |
823 __ Push(pairs); | 827 __ Push(pairs); |
824 __ Push(Smi::FromInt(DeclareGlobalsFlags())); | 828 __ Push(Smi::FromInt(DeclareGlobalsFlags())); |
(...skipping 10 matching lines...) Expand all Loading... |
835 } | 839 } |
836 | 840 |
837 | 841 |
838 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { | 842 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
839 Comment cmnt(masm_, "[ SwitchStatement"); | 843 Comment cmnt(masm_, "[ SwitchStatement"); |
840 Breakable nested_statement(this, stmt); | 844 Breakable nested_statement(this, stmt); |
841 SetStatementPosition(stmt); | 845 SetStatementPosition(stmt); |
842 | 846 |
843 // Keep the switch value on the stack until a case matches. | 847 // Keep the switch value on the stack until a case matches. |
844 VisitForStackValue(stmt->tag()); | 848 VisitForStackValue(stmt->tag()); |
845 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 849 PrepareForBailoutForId(stmt->EntryId(), BailoutState::NO_REGISTERS); |
846 | 850 |
847 ZoneList<CaseClause*>* clauses = stmt->cases(); | 851 ZoneList<CaseClause*>* clauses = stmt->cases(); |
848 CaseClause* default_clause = NULL; // Can occur anywhere in the list. | 852 CaseClause* default_clause = NULL; // Can occur anywhere in the list. |
849 | 853 |
850 Label next_test; // Recycled for each test. | 854 Label next_test; // Recycled for each test. |
851 // Compile all the tests with branches to their bodies. | 855 // Compile all the tests with branches to their bodies. |
852 for (int i = 0; i < clauses->length(); i++) { | 856 for (int i = 0; i < clauses->length(); i++) { |
853 CaseClause* clause = clauses->at(i); | 857 CaseClause* clause = clauses->at(i); |
854 clause->body_target()->Unuse(); | 858 clause->body_target()->Unuse(); |
855 | 859 |
(...skipping 28 matching lines...) Expand all Loading... |
884 } | 888 } |
885 | 889 |
886 SetExpressionPosition(clause); | 890 SetExpressionPosition(clause); |
887 Handle<Code> ic = | 891 Handle<Code> ic = |
888 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); | 892 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); |
889 CallIC(ic, clause->CompareId()); | 893 CallIC(ic, clause->CompareId()); |
890 patch_site.EmitPatchInfo(); | 894 patch_site.EmitPatchInfo(); |
891 | 895 |
892 Label skip; | 896 Label skip; |
893 __ jmp(&skip, Label::kNear); | 897 __ jmp(&skip, Label::kNear); |
894 PrepareForBailout(clause, TOS_REG); | 898 PrepareForBailout(clause, BailoutState::TOS_REGISTER); |
895 __ cmp(eax, isolate()->factory()->true_value()); | 899 __ cmp(eax, isolate()->factory()->true_value()); |
896 __ j(not_equal, &next_test); | 900 __ j(not_equal, &next_test); |
897 __ Drop(1); | 901 __ Drop(1); |
898 __ jmp(clause->body_target()); | 902 __ jmp(clause->body_target()); |
899 __ bind(&skip); | 903 __ bind(&skip); |
900 | 904 |
901 __ test(eax, eax); | 905 __ test(eax, eax); |
902 __ j(not_equal, &next_test); | 906 __ j(not_equal, &next_test); |
903 __ Drop(1); // Switch value is no longer needed. | 907 __ Drop(1); // Switch value is no longer needed. |
904 __ jmp(clause->body_target()); | 908 __ jmp(clause->body_target()); |
905 } | 909 } |
906 | 910 |
907 // Discard the test value and jump to the default if present, otherwise to | 911 // Discard the test value and jump to the default if present, otherwise to |
908 // the end of the statement. | 912 // the end of the statement. |
909 __ bind(&next_test); | 913 __ bind(&next_test); |
910 DropOperands(1); // Switch value is no longer needed. | 914 DropOperands(1); // Switch value is no longer needed. |
911 if (default_clause == NULL) { | 915 if (default_clause == NULL) { |
912 __ jmp(nested_statement.break_label()); | 916 __ jmp(nested_statement.break_label()); |
913 } else { | 917 } else { |
914 __ jmp(default_clause->body_target()); | 918 __ jmp(default_clause->body_target()); |
915 } | 919 } |
916 | 920 |
917 // Compile all the case bodies. | 921 // Compile all the case bodies. |
918 for (int i = 0; i < clauses->length(); i++) { | 922 for (int i = 0; i < clauses->length(); i++) { |
919 Comment cmnt(masm_, "[ Case body"); | 923 Comment cmnt(masm_, "[ Case body"); |
920 CaseClause* clause = clauses->at(i); | 924 CaseClause* clause = clauses->at(i); |
921 __ bind(clause->body_target()); | 925 __ bind(clause->body_target()); |
922 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); | 926 PrepareForBailoutForId(clause->EntryId(), BailoutState::NO_REGISTERS); |
923 VisitStatements(clause->statements()); | 927 VisitStatements(clause->statements()); |
924 } | 928 } |
925 | 929 |
926 __ bind(nested_statement.break_label()); | 930 __ bind(nested_statement.break_label()); |
927 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 931 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); |
928 } | 932 } |
929 | 933 |
930 | 934 |
931 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 935 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
932 Comment cmnt(masm_, "[ ForInStatement"); | 936 Comment cmnt(masm_, "[ ForInStatement"); |
933 SetStatementPosition(stmt, SKIP_BREAK); | 937 SetStatementPosition(stmt, SKIP_BREAK); |
934 | 938 |
935 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 939 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
936 | 940 |
937 // Get the object to enumerate over. | 941 // Get the object to enumerate over. |
(...skipping 12 matching lines...) Expand all Loading... |
950 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); | 954 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); |
951 __ j(above_equal, &done_convert, Label::kNear); | 955 __ j(above_equal, &done_convert, Label::kNear); |
952 __ cmp(eax, isolate()->factory()->undefined_value()); | 956 __ cmp(eax, isolate()->factory()->undefined_value()); |
953 __ j(equal, &exit); | 957 __ j(equal, &exit); |
954 __ cmp(eax, isolate()->factory()->null_value()); | 958 __ cmp(eax, isolate()->factory()->null_value()); |
955 __ j(equal, &exit); | 959 __ j(equal, &exit); |
956 __ bind(&convert); | 960 __ bind(&convert); |
957 ToObjectStub stub(isolate()); | 961 ToObjectStub stub(isolate()); |
958 __ CallStub(&stub); | 962 __ CallStub(&stub); |
959 __ bind(&done_convert); | 963 __ bind(&done_convert); |
960 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); | 964 PrepareForBailoutForId(stmt->ToObjectId(), BailoutState::TOS_REGISTER); |
961 __ push(eax); | 965 __ push(eax); |
962 | 966 |
963 // Check cache validity in generated code. If we cannot guarantee cache | 967 // Check cache validity in generated code. If we cannot guarantee cache |
964 // validity, call the runtime system to check cache validity or get the | 968 // validity, call the runtime system to check cache validity or get the |
965 // property names in a fixed array. Note: Proxies never have an enum cache, | 969 // property names in a fixed array. Note: Proxies never have an enum cache, |
966 // so will always take the slow path. | 970 // so will always take the slow path. |
967 Label call_runtime, use_cache, fixed_array; | 971 Label call_runtime, use_cache, fixed_array; |
968 __ CheckEnumCache(&call_runtime); | 972 __ CheckEnumCache(&call_runtime); |
969 | 973 |
970 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); | 974 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); |
971 __ jmp(&use_cache, Label::kNear); | 975 __ jmp(&use_cache, Label::kNear); |
972 | 976 |
973 // Get the set of properties to enumerate. | 977 // Get the set of properties to enumerate. |
974 __ bind(&call_runtime); | 978 __ bind(&call_runtime); |
975 __ push(eax); | 979 __ push(eax); |
976 __ CallRuntime(Runtime::kForInEnumerate); | 980 __ CallRuntime(Runtime::kForInEnumerate); |
977 PrepareForBailoutForId(stmt->EnumId(), TOS_REG); | 981 PrepareForBailoutForId(stmt->EnumId(), BailoutState::TOS_REGISTER); |
978 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), | 982 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), |
979 isolate()->factory()->meta_map()); | 983 isolate()->factory()->meta_map()); |
980 __ j(not_equal, &fixed_array); | 984 __ j(not_equal, &fixed_array); |
981 | 985 |
982 | 986 |
983 // We got a map in register eax. Get the enumeration cache from it. | 987 // We got a map in register eax. Get the enumeration cache from it. |
984 Label no_descriptors; | 988 Label no_descriptors; |
985 __ bind(&use_cache); | 989 __ bind(&use_cache); |
986 | 990 |
987 __ EnumLength(edx, eax); | 991 __ EnumLength(edx, eax); |
(...skipping 15 matching lines...) Expand all Loading... |
1003 __ add(esp, Immediate(kPointerSize)); | 1007 __ add(esp, Immediate(kPointerSize)); |
1004 __ jmp(&exit); | 1008 __ jmp(&exit); |
1005 | 1009 |
1006 // We got a fixed array in register eax. Iterate through that. | 1010 // We got a fixed array in register eax. Iterate through that. |
1007 __ bind(&fixed_array); | 1011 __ bind(&fixed_array); |
1008 | 1012 |
1009 __ push(Immediate(Smi::FromInt(1))); // Smi(1) indicates slow check | 1013 __ push(Immediate(Smi::FromInt(1))); // Smi(1) indicates slow check |
1010 __ push(eax); // Array | 1014 __ push(eax); // Array |
1011 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); | 1015 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); |
1012 __ push(eax); // Fixed array length (as smi). | 1016 __ push(eax); // Fixed array length (as smi). |
1013 PrepareForBailoutForId(stmt->PrepareId(), NO_REGISTERS); | 1017 PrepareForBailoutForId(stmt->PrepareId(), BailoutState::NO_REGISTERS); |
1014 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1018 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
1015 | 1019 |
1016 // Generate code for doing the condition check. | 1020 // Generate code for doing the condition check. |
1017 __ bind(&loop); | 1021 __ bind(&loop); |
1018 SetExpressionAsStatementPosition(stmt->each()); | 1022 SetExpressionAsStatementPosition(stmt->each()); |
1019 | 1023 |
1020 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. | 1024 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. |
1021 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. | 1025 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. |
1022 __ j(above_equal, loop_statement.break_label()); | 1026 __ j(above_equal, loop_statement.break_label()); |
1023 | 1027 |
(...skipping 17 matching lines...) Expand all Loading... |
1041 __ EmitLoadTypeFeedbackVector(edx); | 1045 __ EmitLoadTypeFeedbackVector(edx); |
1042 __ mov(FieldOperand(edx, FixedArray::OffsetOfElementAt(vector_index)), | 1046 __ mov(FieldOperand(edx, FixedArray::OffsetOfElementAt(vector_index)), |
1043 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate()))); | 1047 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate()))); |
1044 | 1048 |
1045 // Convert the entry to a string or null if it isn't a property | 1049 // Convert the entry to a string or null if it isn't a property |
1046 // anymore. If the property has been removed while iterating, we | 1050 // anymore. If the property has been removed while iterating, we |
1047 // just skip it. | 1051 // just skip it. |
1048 __ push(ecx); // Enumerable. | 1052 __ push(ecx); // Enumerable. |
1049 __ push(ebx); // Current entry. | 1053 __ push(ebx); // Current entry. |
1050 __ CallRuntime(Runtime::kForInFilter); | 1054 __ CallRuntime(Runtime::kForInFilter); |
1051 PrepareForBailoutForId(stmt->FilterId(), TOS_REG); | 1055 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); |
1052 __ cmp(eax, isolate()->factory()->undefined_value()); | 1056 __ cmp(eax, isolate()->factory()->undefined_value()); |
1053 __ j(equal, loop_statement.continue_label()); | 1057 __ j(equal, loop_statement.continue_label()); |
1054 __ mov(ebx, eax); | 1058 __ mov(ebx, eax); |
1055 | 1059 |
1056 // Update the 'each' property or variable from the possibly filtered | 1060 // Update the 'each' property or variable from the possibly filtered |
1057 // entry in register ebx. | 1061 // entry in register ebx. |
1058 __ bind(&update_each); | 1062 __ bind(&update_each); |
1059 __ mov(result_register(), ebx); | 1063 __ mov(result_register(), ebx); |
1060 // Perform the assignment as if via '='. | 1064 // Perform the assignment as if via '='. |
1061 { EffectContext context(this); | 1065 { EffectContext context(this); |
1062 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1066 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
1063 PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS); | 1067 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); |
1064 } | 1068 } |
1065 | 1069 |
1066 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). | 1070 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). |
1067 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1071 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); |
1068 // Generate code for the body of the loop. | 1072 // Generate code for the body of the loop. |
1069 Visit(stmt->body()); | 1073 Visit(stmt->body()); |
1070 | 1074 |
1071 // Generate code for going to the next element by incrementing the | 1075 // Generate code for going to the next element by incrementing the |
1072 // index (smi) stored on top of the stack. | 1076 // index (smi) stored on top of the stack. |
1073 __ bind(loop_statement.continue_label()); | 1077 __ bind(loop_statement.continue_label()); |
1074 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); | 1078 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); |
1075 | 1079 |
1076 EmitBackEdgeBookkeeping(stmt, &loop); | 1080 EmitBackEdgeBookkeeping(stmt, &loop); |
1077 __ jmp(&loop); | 1081 __ jmp(&loop); |
1078 | 1082 |
1079 // Remove the pointers stored on the stack. | 1083 // Remove the pointers stored on the stack. |
1080 __ bind(loop_statement.break_label()); | 1084 __ bind(loop_statement.break_label()); |
1081 DropOperands(5); | 1085 DropOperands(5); |
1082 | 1086 |
1083 // Exit and decrement the loop depth. | 1087 // Exit and decrement the loop depth. |
1084 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1088 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); |
1085 __ bind(&exit); | 1089 __ bind(&exit); |
1086 decrement_loop_depth(); | 1090 decrement_loop_depth(); |
1087 } | 1091 } |
1088 | 1092 |
1089 | 1093 |
1090 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, | 1094 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, |
1091 FeedbackVectorSlot slot) { | 1095 FeedbackVectorSlot slot) { |
1092 DCHECK(NeedsHomeObject(initializer)); | 1096 DCHECK(NeedsHomeObject(initializer)); |
1093 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); | 1097 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); |
1094 __ mov(StoreDescriptor::NameRegister(), | 1098 __ mov(StoreDescriptor::NameRegister(), |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1236 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1233 __ mov(LoadDescriptor::SlotRegister(), | 1237 __ mov(LoadDescriptor::SlotRegister(), |
1234 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1238 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1235 CallLoadIC(typeof_mode); | 1239 CallLoadIC(typeof_mode); |
1236 } | 1240 } |
1237 | 1241 |
1238 | 1242 |
1239 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1243 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
1240 TypeofMode typeof_mode) { | 1244 TypeofMode typeof_mode) { |
1241 SetExpressionPosition(proxy); | 1245 SetExpressionPosition(proxy); |
1242 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1246 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); |
1243 Variable* var = proxy->var(); | 1247 Variable* var = proxy->var(); |
1244 | 1248 |
1245 // Three cases: global variables, lookup variables, and all other types of | 1249 // Three cases: global variables, lookup variables, and all other types of |
1246 // variables. | 1250 // variables. |
1247 switch (var->location()) { | 1251 switch (var->location()) { |
1248 case VariableLocation::GLOBAL: | 1252 case VariableLocation::GLOBAL: |
1249 case VariableLocation::UNALLOCATED: { | 1253 case VariableLocation::UNALLOCATED: { |
1250 Comment cmnt(masm_, "[ Global variable"); | 1254 Comment cmnt(masm_, "[ Global variable"); |
1251 EmitGlobalVariableLoad(proxy, typeof_mode); | 1255 EmitGlobalVariableLoad(proxy, typeof_mode); |
1252 context()->Plug(eax); | 1256 context()->Plug(eax); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 __ CallRuntime(Runtime::kCreateObjectLiteral); | 1348 __ CallRuntime(Runtime::kCreateObjectLiteral); |
1345 } else { | 1349 } else { |
1346 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1350 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1347 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); | 1351 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); |
1348 __ mov(ecx, Immediate(constant_properties)); | 1352 __ mov(ecx, Immediate(constant_properties)); |
1349 __ mov(edx, Immediate(Smi::FromInt(flags))); | 1353 __ mov(edx, Immediate(Smi::FromInt(flags))); |
1350 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); | 1354 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
1351 __ CallStub(&stub); | 1355 __ CallStub(&stub); |
1352 RestoreContext(); | 1356 RestoreContext(); |
1353 } | 1357 } |
1354 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1358 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
1355 | 1359 |
1356 // If result_saved is true the result is on top of the stack. If | 1360 // If result_saved is true the result is on top of the stack. If |
1357 // result_saved is false the result is in eax. | 1361 // result_saved is false the result is in eax. |
1358 bool result_saved = false; | 1362 bool result_saved = false; |
1359 | 1363 |
1360 AccessorTable accessor_table(zone()); | 1364 AccessorTable accessor_table(zone()); |
1361 int property_index = 0; | 1365 int property_index = 0; |
1362 for (; property_index < expr->properties()->length(); property_index++) { | 1366 for (; property_index < expr->properties()->length(); property_index++) { |
1363 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1367 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
1364 if (property->is_computed_name()) break; | 1368 if (property->is_computed_name()) break; |
(...skipping 15 matching lines...) Expand all Loading... |
1380 // It is safe to use [[Put]] here because the boilerplate already | 1384 // It is safe to use [[Put]] here because the boilerplate already |
1381 // contains computed properties with an uninitialized value. | 1385 // contains computed properties with an uninitialized value. |
1382 if (key->value()->IsInternalizedString()) { | 1386 if (key->value()->IsInternalizedString()) { |
1383 if (property->emit_store()) { | 1387 if (property->emit_store()) { |
1384 VisitForAccumulatorValue(value); | 1388 VisitForAccumulatorValue(value); |
1385 DCHECK(StoreDescriptor::ValueRegister().is(eax)); | 1389 DCHECK(StoreDescriptor::ValueRegister().is(eax)); |
1386 __ mov(StoreDescriptor::NameRegister(), Immediate(key->value())); | 1390 __ mov(StoreDescriptor::NameRegister(), Immediate(key->value())); |
1387 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); | 1391 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); |
1388 EmitLoadStoreICSlot(property->GetSlot(0)); | 1392 EmitLoadStoreICSlot(property->GetSlot(0)); |
1389 CallStoreIC(); | 1393 CallStoreIC(); |
1390 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1394 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); |
1391 if (NeedsHomeObject(value)) { | 1395 if (NeedsHomeObject(value)) { |
1392 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); | 1396 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); |
1393 } | 1397 } |
1394 } else { | 1398 } else { |
1395 VisitForEffect(value); | 1399 VisitForEffect(value); |
1396 } | 1400 } |
1397 break; | 1401 break; |
1398 } | 1402 } |
1399 PushOperand(Operand(esp, 0)); // Duplicate receiver. | 1403 PushOperand(Operand(esp, 0)); // Duplicate receiver. |
1400 VisitForStackValue(key); | 1404 VisitForStackValue(key); |
1401 VisitForStackValue(value); | 1405 VisitForStackValue(value); |
1402 if (property->emit_store()) { | 1406 if (property->emit_store()) { |
1403 if (NeedsHomeObject(value)) { | 1407 if (NeedsHomeObject(value)) { |
1404 EmitSetHomeObject(value, 2, property->GetSlot()); | 1408 EmitSetHomeObject(value, 2, property->GetSlot()); |
1405 } | 1409 } |
1406 PushOperand(Smi::FromInt(SLOPPY)); // Language mode | 1410 PushOperand(Smi::FromInt(SLOPPY)); // Language mode |
1407 CallRuntimeWithOperands(Runtime::kSetProperty); | 1411 CallRuntimeWithOperands(Runtime::kSetProperty); |
1408 } else { | 1412 } else { |
1409 DropOperands(3); | 1413 DropOperands(3); |
1410 } | 1414 } |
1411 break; | 1415 break; |
1412 case ObjectLiteral::Property::PROTOTYPE: | 1416 case ObjectLiteral::Property::PROTOTYPE: |
1413 PushOperand(Operand(esp, 0)); // Duplicate receiver. | 1417 PushOperand(Operand(esp, 0)); // Duplicate receiver. |
1414 VisitForStackValue(value); | 1418 VisitForStackValue(value); |
1415 DCHECK(property->emit_store()); | 1419 DCHECK(property->emit_store()); |
1416 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1420 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
1417 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1421 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
1418 NO_REGISTERS); | 1422 BailoutState::NO_REGISTERS); |
1419 break; | 1423 break; |
1420 case ObjectLiteral::Property::GETTER: | 1424 case ObjectLiteral::Property::GETTER: |
1421 if (property->emit_store()) { | 1425 if (property->emit_store()) { |
1422 accessor_table.lookup(key)->second->getter = property; | 1426 accessor_table.lookup(key)->second->getter = property; |
1423 } | 1427 } |
1424 break; | 1428 break; |
1425 case ObjectLiteral::Property::SETTER: | 1429 case ObjectLiteral::Property::SETTER: |
1426 if (property->emit_store()) { | 1430 if (property->emit_store()) { |
1427 accessor_table.lookup(key)->second->setter = property; | 1431 accessor_table.lookup(key)->second->setter = property; |
1428 } | 1432 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 } | 1468 } |
1465 | 1469 |
1466 PushOperand(Operand(esp, 0)); // Duplicate receiver. | 1470 PushOperand(Operand(esp, 0)); // Duplicate receiver. |
1467 | 1471 |
1468 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { | 1472 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { |
1469 DCHECK(!property->is_computed_name()); | 1473 DCHECK(!property->is_computed_name()); |
1470 VisitForStackValue(value); | 1474 VisitForStackValue(value); |
1471 DCHECK(property->emit_store()); | 1475 DCHECK(property->emit_store()); |
1472 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1476 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
1473 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1477 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
1474 NO_REGISTERS); | 1478 BailoutState::NO_REGISTERS); |
1475 } else { | 1479 } else { |
1476 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); | 1480 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); |
1477 VisitForStackValue(value); | 1481 VisitForStackValue(value); |
1478 if (NeedsHomeObject(value)) { | 1482 if (NeedsHomeObject(value)) { |
1479 EmitSetHomeObject(value, 2, property->GetSlot()); | 1483 EmitSetHomeObject(value, 2, property->GetSlot()); |
1480 } | 1484 } |
1481 | 1485 |
1482 switch (property->kind()) { | 1486 switch (property->kind()) { |
1483 case ObjectLiteral::Property::CONSTANT: | 1487 case ObjectLiteral::Property::CONSTANT: |
1484 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1488 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 __ push(Immediate(constant_elements)); | 1541 __ push(Immediate(constant_elements)); |
1538 __ push(Immediate(Smi::FromInt(expr->ComputeFlags()))); | 1542 __ push(Immediate(Smi::FromInt(expr->ComputeFlags()))); |
1539 __ CallRuntime(Runtime::kCreateArrayLiteral); | 1543 __ CallRuntime(Runtime::kCreateArrayLiteral); |
1540 } else { | 1544 } else { |
1541 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1545 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1542 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); | 1546 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); |
1543 __ mov(ecx, Immediate(constant_elements)); | 1547 __ mov(ecx, Immediate(constant_elements)); |
1544 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1548 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
1545 __ CallStub(&stub); | 1549 __ CallStub(&stub); |
1546 } | 1550 } |
1547 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1551 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
1548 | 1552 |
1549 bool result_saved = false; // Is the result saved to the stack? | 1553 bool result_saved = false; // Is the result saved to the stack? |
1550 ZoneList<Expression*>* subexprs = expr->values(); | 1554 ZoneList<Expression*>* subexprs = expr->values(); |
1551 int length = subexprs->length(); | 1555 int length = subexprs->length(); |
1552 | 1556 |
1553 // Emit code to evaluate all the non-constant subexpressions and to store | 1557 // Emit code to evaluate all the non-constant subexpressions and to store |
1554 // them into the newly cloned array. | 1558 // them into the newly cloned array. |
1555 int array_index = 0; | 1559 int array_index = 0; |
1556 for (; array_index < length; array_index++) { | 1560 for (; array_index < length; array_index++) { |
1557 Expression* subexpr = subexprs->at(array_index); | 1561 Expression* subexpr = subexprs->at(array_index); |
1558 DCHECK(!subexpr->IsSpread()); | 1562 DCHECK(!subexpr->IsSpread()); |
1559 | 1563 |
1560 // If the subexpression is a literal or a simple materialized literal it | 1564 // If the subexpression is a literal or a simple materialized literal it |
1561 // is already set in the cloned array. | 1565 // is already set in the cloned array. |
1562 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1566 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1563 | 1567 |
1564 if (!result_saved) { | 1568 if (!result_saved) { |
1565 PushOperand(eax); // array literal. | 1569 PushOperand(eax); // array literal. |
1566 result_saved = true; | 1570 result_saved = true; |
1567 } | 1571 } |
1568 VisitForAccumulatorValue(subexpr); | 1572 VisitForAccumulatorValue(subexpr); |
1569 | 1573 |
1570 __ mov(StoreDescriptor::NameRegister(), | 1574 __ mov(StoreDescriptor::NameRegister(), |
1571 Immediate(Smi::FromInt(array_index))); | 1575 Immediate(Smi::FromInt(array_index))); |
1572 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); | 1576 __ mov(StoreDescriptor::ReceiverRegister(), Operand(esp, 0)); |
1573 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1577 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); |
1574 Handle<Code> ic = | 1578 Handle<Code> ic = |
1575 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 1579 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
1576 CallIC(ic); | 1580 CallIC(ic); |
1577 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1581 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1582 BailoutState::NO_REGISTERS); |
1578 } | 1583 } |
1579 | 1584 |
1580 // In case the array literal contains spread expressions it has two parts. The | 1585 // In case the array literal contains spread expressions it has two parts. The |
1581 // first part is the "static" array which has a literal index is handled | 1586 // first part is the "static" array which has a literal index is handled |
1582 // above. The second part is the part after the first spread expression | 1587 // above. The second part is the part after the first spread expression |
1583 // (inclusive) and these elements gets appended to the array. Note that the | 1588 // (inclusive) and these elements gets appended to the array. Note that the |
1584 // number elements an iterable produces is unknown ahead of time. | 1589 // number elements an iterable produces is unknown ahead of time. |
1585 if (array_index < length && result_saved) { | 1590 if (array_index < length && result_saved) { |
1586 PopOperand(eax); | 1591 PopOperand(eax); |
1587 result_saved = false; | 1592 result_saved = false; |
1588 } | 1593 } |
1589 for (; array_index < length; array_index++) { | 1594 for (; array_index < length; array_index++) { |
1590 Expression* subexpr = subexprs->at(array_index); | 1595 Expression* subexpr = subexprs->at(array_index); |
1591 | 1596 |
1592 PushOperand(eax); | 1597 PushOperand(eax); |
1593 DCHECK(!subexpr->IsSpread()); | 1598 DCHECK(!subexpr->IsSpread()); |
1594 VisitForStackValue(subexpr); | 1599 VisitForStackValue(subexpr); |
1595 CallRuntimeWithOperands(Runtime::kAppendElement); | 1600 CallRuntimeWithOperands(Runtime::kAppendElement); |
1596 | 1601 |
1597 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1602 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1603 BailoutState::NO_REGISTERS); |
1598 } | 1604 } |
1599 | 1605 |
1600 if (result_saved) { | 1606 if (result_saved) { |
1601 context()->PlugTOS(); | 1607 context()->PlugTOS(); |
1602 } else { | 1608 } else { |
1603 context()->Plug(eax); | 1609 context()->Plug(eax); |
1604 } | 1610 } |
1605 } | 1611 } |
1606 | 1612 |
1607 | 1613 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 } | 1672 } |
1667 | 1673 |
1668 // For compound assignments we need another deoptimization point after the | 1674 // For compound assignments we need another deoptimization point after the |
1669 // variable/property load. | 1675 // variable/property load. |
1670 if (expr->is_compound()) { | 1676 if (expr->is_compound()) { |
1671 AccumulatorValueContext result_context(this); | 1677 AccumulatorValueContext result_context(this); |
1672 { AccumulatorValueContext left_operand_context(this); | 1678 { AccumulatorValueContext left_operand_context(this); |
1673 switch (assign_type) { | 1679 switch (assign_type) { |
1674 case VARIABLE: | 1680 case VARIABLE: |
1675 EmitVariableLoad(expr->target()->AsVariableProxy()); | 1681 EmitVariableLoad(expr->target()->AsVariableProxy()); |
1676 PrepareForBailout(expr->target(), TOS_REG); | 1682 PrepareForBailout(expr->target(), BailoutState::TOS_REGISTER); |
1677 break; | 1683 break; |
1678 case NAMED_SUPER_PROPERTY: | 1684 case NAMED_SUPER_PROPERTY: |
1679 EmitNamedSuperPropertyLoad(property); | 1685 EmitNamedSuperPropertyLoad(property); |
1680 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1686 PrepareForBailoutForId(property->LoadId(), |
| 1687 BailoutState::TOS_REGISTER); |
1681 break; | 1688 break; |
1682 case NAMED_PROPERTY: | 1689 case NAMED_PROPERTY: |
1683 EmitNamedPropertyLoad(property); | 1690 EmitNamedPropertyLoad(property); |
1684 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1691 PrepareForBailoutForId(property->LoadId(), |
| 1692 BailoutState::TOS_REGISTER); |
1685 break; | 1693 break; |
1686 case KEYED_SUPER_PROPERTY: | 1694 case KEYED_SUPER_PROPERTY: |
1687 EmitKeyedSuperPropertyLoad(property); | 1695 EmitKeyedSuperPropertyLoad(property); |
1688 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1696 PrepareForBailoutForId(property->LoadId(), |
| 1697 BailoutState::TOS_REGISTER); |
1689 break; | 1698 break; |
1690 case KEYED_PROPERTY: | 1699 case KEYED_PROPERTY: |
1691 EmitKeyedPropertyLoad(property); | 1700 EmitKeyedPropertyLoad(property); |
1692 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1701 PrepareForBailoutForId(property->LoadId(), |
| 1702 BailoutState::TOS_REGISTER); |
1693 break; | 1703 break; |
1694 } | 1704 } |
1695 } | 1705 } |
1696 | 1706 |
1697 Token::Value op = expr->binary_op(); | 1707 Token::Value op = expr->binary_op(); |
1698 PushOperand(eax); // Left operand goes on the stack. | 1708 PushOperand(eax); // Left operand goes on the stack. |
1699 VisitForAccumulatorValue(expr->value()); | 1709 VisitForAccumulatorValue(expr->value()); |
1700 | 1710 |
1701 if (ShouldInlineSmiCase(op)) { | 1711 if (ShouldInlineSmiCase(op)) { |
1702 EmitInlineSmiBinaryOp(expr->binary_operation(), | 1712 EmitInlineSmiBinaryOp(expr->binary_operation(), |
1703 op, | 1713 op, |
1704 expr->target(), | 1714 expr->target(), |
1705 expr->value()); | 1715 expr->value()); |
1706 } else { | 1716 } else { |
1707 EmitBinaryOp(expr->binary_operation(), op); | 1717 EmitBinaryOp(expr->binary_operation(), op); |
1708 } | 1718 } |
1709 | 1719 |
1710 // Deoptimization point in case the binary operation may have side effects. | 1720 // Deoptimization point in case the binary operation may have side effects. |
1711 PrepareForBailout(expr->binary_operation(), TOS_REG); | 1721 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); |
1712 } else { | 1722 } else { |
1713 VisitForAccumulatorValue(expr->value()); | 1723 VisitForAccumulatorValue(expr->value()); |
1714 } | 1724 } |
1715 | 1725 |
1716 SetExpressionPosition(expr); | 1726 SetExpressionPosition(expr); |
1717 | 1727 |
1718 // Store the value. | 1728 // Store the value. |
1719 switch (assign_type) { | 1729 switch (assign_type) { |
1720 case VARIABLE: | 1730 case VARIABLE: |
1721 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 1731 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
1722 expr->op(), expr->AssignmentSlot()); | 1732 expr->op(), expr->AssignmentSlot()); |
1723 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 1733 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
1724 context()->Plug(eax); | 1734 context()->Plug(eax); |
1725 break; | 1735 break; |
1726 case NAMED_PROPERTY: | 1736 case NAMED_PROPERTY: |
1727 EmitNamedPropertyAssignment(expr); | 1737 EmitNamedPropertyAssignment(expr); |
1728 break; | 1738 break; |
1729 case NAMED_SUPER_PROPERTY: | 1739 case NAMED_SUPER_PROPERTY: |
1730 EmitNamedSuperPropertyStore(property); | 1740 EmitNamedSuperPropertyStore(property); |
1731 context()->Plug(result_register()); | 1741 context()->Plug(result_register()); |
1732 break; | 1742 break; |
1733 case KEYED_SUPER_PROPERTY: | 1743 case KEYED_SUPER_PROPERTY: |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 // eax : value | 2182 // eax : value |
2173 // esp[0] : receiver | 2183 // esp[0] : receiver |
2174 Property* prop = expr->target()->AsProperty(); | 2184 Property* prop = expr->target()->AsProperty(); |
2175 DCHECK(prop != NULL); | 2185 DCHECK(prop != NULL); |
2176 DCHECK(prop->key()->IsLiteral()); | 2186 DCHECK(prop->key()->IsLiteral()); |
2177 | 2187 |
2178 __ mov(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); | 2188 __ mov(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); |
2179 PopOperand(StoreDescriptor::ReceiverRegister()); | 2189 PopOperand(StoreDescriptor::ReceiverRegister()); |
2180 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2190 EmitLoadStoreICSlot(expr->AssignmentSlot()); |
2181 CallStoreIC(); | 2191 CallStoreIC(); |
2182 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2192 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
2183 context()->Plug(eax); | 2193 context()->Plug(eax); |
2184 } | 2194 } |
2185 | 2195 |
2186 | 2196 |
2187 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { | 2197 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { |
2188 // Assignment to named property of super. | 2198 // Assignment to named property of super. |
2189 // eax : value | 2199 // eax : value |
2190 // stack : receiver ('this'), home_object | 2200 // stack : receiver ('this'), home_object |
2191 DCHECK(prop != NULL); | 2201 DCHECK(prop != NULL); |
2192 Literal* key = prop->key()->AsLiteral(); | 2202 Literal* key = prop->key()->AsLiteral(); |
(...skipping 25 matching lines...) Expand all Loading... |
2218 // esp[0] : key | 2228 // esp[0] : key |
2219 // esp[kPointerSize] : receiver | 2229 // esp[kPointerSize] : receiver |
2220 | 2230 |
2221 PopOperand(StoreDescriptor::NameRegister()); // Key. | 2231 PopOperand(StoreDescriptor::NameRegister()); // Key. |
2222 PopOperand(StoreDescriptor::ReceiverRegister()); | 2232 PopOperand(StoreDescriptor::ReceiverRegister()); |
2223 DCHECK(StoreDescriptor::ValueRegister().is(eax)); | 2233 DCHECK(StoreDescriptor::ValueRegister().is(eax)); |
2224 Handle<Code> ic = | 2234 Handle<Code> ic = |
2225 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 2235 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
2226 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2236 EmitLoadStoreICSlot(expr->AssignmentSlot()); |
2227 CallIC(ic); | 2237 CallIC(ic); |
2228 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2238 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
2229 context()->Plug(eax); | 2239 context()->Plug(eax); |
2230 } | 2240 } |
2231 | 2241 |
2232 | 2242 |
2233 void FullCodeGenerator::CallIC(Handle<Code> code, | 2243 void FullCodeGenerator::CallIC(Handle<Code> code, |
2234 TypeFeedbackId ast_id) { | 2244 TypeFeedbackId ast_id) { |
2235 ic_total_count_++; | 2245 ic_total_count_++; |
2236 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2246 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
2237 } | 2247 } |
2238 | 2248 |
2239 | 2249 |
2240 // Code common for calls using the IC. | 2250 // Code common for calls using the IC. |
2241 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { | 2251 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
2242 Expression* callee = expr->expression(); | 2252 Expression* callee = expr->expression(); |
2243 | 2253 |
2244 // Get the target function. | 2254 // Get the target function. |
2245 ConvertReceiverMode convert_mode; | 2255 ConvertReceiverMode convert_mode; |
2246 if (callee->IsVariableProxy()) { | 2256 if (callee->IsVariableProxy()) { |
2247 { StackValueContext context(this); | 2257 { StackValueContext context(this); |
2248 EmitVariableLoad(callee->AsVariableProxy()); | 2258 EmitVariableLoad(callee->AsVariableProxy()); |
2249 PrepareForBailout(callee, NO_REGISTERS); | 2259 PrepareForBailout(callee, BailoutState::NO_REGISTERS); |
2250 } | 2260 } |
2251 // Push undefined as receiver. This is patched in the method prologue if it | 2261 // Push undefined as receiver. This is patched in the method prologue if it |
2252 // is a sloppy mode method. | 2262 // is a sloppy mode method. |
2253 PushOperand(isolate()->factory()->undefined_value()); | 2263 PushOperand(isolate()->factory()->undefined_value()); |
2254 convert_mode = ConvertReceiverMode::kNullOrUndefined; | 2264 convert_mode = ConvertReceiverMode::kNullOrUndefined; |
2255 } else { | 2265 } else { |
2256 // Load the function from the receiver. | 2266 // Load the function from the receiver. |
2257 DCHECK(callee->IsProperty()); | 2267 DCHECK(callee->IsProperty()); |
2258 DCHECK(!callee->AsProperty()->IsSuperAccess()); | 2268 DCHECK(!callee->AsProperty()->IsSuperAccess()); |
2259 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 2269 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
2260 EmitNamedPropertyLoad(callee->AsProperty()); | 2270 EmitNamedPropertyLoad(callee->AsProperty()); |
2261 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2271 PrepareForBailoutForId(callee->AsProperty()->LoadId(), |
| 2272 BailoutState::TOS_REGISTER); |
2262 // Push the target function under the receiver. | 2273 // Push the target function under the receiver. |
2263 PushOperand(Operand(esp, 0)); | 2274 PushOperand(Operand(esp, 0)); |
2264 __ mov(Operand(esp, kPointerSize), eax); | 2275 __ mov(Operand(esp, kPointerSize), eax); |
2265 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; | 2276 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; |
2266 } | 2277 } |
2267 | 2278 |
2268 EmitCall(expr, convert_mode); | 2279 EmitCall(expr, convert_mode); |
2269 } | 2280 } |
2270 | 2281 |
2271 | 2282 |
(...skipping 14 matching lines...) Expand all Loading... |
2286 PushOperand(eax); | 2297 PushOperand(eax); |
2287 PushOperand(Operand(esp, kPointerSize * 2)); | 2298 PushOperand(Operand(esp, kPointerSize * 2)); |
2288 PushOperand(key->value()); | 2299 PushOperand(key->value()); |
2289 // Stack here: | 2300 // Stack here: |
2290 // - home_object | 2301 // - home_object |
2291 // - this (receiver) | 2302 // - this (receiver) |
2292 // - this (receiver) <-- LoadFromSuper will pop here and below. | 2303 // - this (receiver) <-- LoadFromSuper will pop here and below. |
2293 // - home_object | 2304 // - home_object |
2294 // - key | 2305 // - key |
2295 CallRuntimeWithOperands(Runtime::kLoadFromSuper); | 2306 CallRuntimeWithOperands(Runtime::kLoadFromSuper); |
2296 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 2307 PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER); |
2297 | 2308 |
2298 // Replace home_object with target function. | 2309 // Replace home_object with target function. |
2299 __ mov(Operand(esp, kPointerSize), eax); | 2310 __ mov(Operand(esp, kPointerSize), eax); |
2300 | 2311 |
2301 // Stack here: | 2312 // Stack here: |
2302 // - target function | 2313 // - target function |
2303 // - this (receiver) | 2314 // - this (receiver) |
2304 EmitCall(expr); | 2315 EmitCall(expr); |
2305 } | 2316 } |
2306 | 2317 |
2307 | 2318 |
2308 // Code common for calls using the IC. | 2319 // Code common for calls using the IC. |
2309 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, | 2320 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
2310 Expression* key) { | 2321 Expression* key) { |
2311 // Load the key. | 2322 // Load the key. |
2312 VisitForAccumulatorValue(key); | 2323 VisitForAccumulatorValue(key); |
2313 | 2324 |
2314 Expression* callee = expr->expression(); | 2325 Expression* callee = expr->expression(); |
2315 | 2326 |
2316 // Load the function from the receiver. | 2327 // Load the function from the receiver. |
2317 DCHECK(callee->IsProperty()); | 2328 DCHECK(callee->IsProperty()); |
2318 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 2329 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
2319 __ mov(LoadDescriptor::NameRegister(), eax); | 2330 __ mov(LoadDescriptor::NameRegister(), eax); |
2320 EmitKeyedPropertyLoad(callee->AsProperty()); | 2331 EmitKeyedPropertyLoad(callee->AsProperty()); |
2321 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2332 PrepareForBailoutForId(callee->AsProperty()->LoadId(), |
| 2333 BailoutState::TOS_REGISTER); |
2322 | 2334 |
2323 // Push the target function under the receiver. | 2335 // Push the target function under the receiver. |
2324 PushOperand(Operand(esp, 0)); | 2336 PushOperand(Operand(esp, 0)); |
2325 __ mov(Operand(esp, kPointerSize), eax); | 2337 __ mov(Operand(esp, kPointerSize), eax); |
2326 | 2338 |
2327 EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); | 2339 EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); |
2328 } | 2340 } |
2329 | 2341 |
2330 | 2342 |
2331 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 2343 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
(...skipping 11 matching lines...) Expand all Loading... |
2343 PushOperand(eax); | 2355 PushOperand(eax); |
2344 PushOperand(Operand(esp, kPointerSize * 2)); | 2356 PushOperand(Operand(esp, kPointerSize * 2)); |
2345 VisitForStackValue(prop->key()); | 2357 VisitForStackValue(prop->key()); |
2346 // Stack here: | 2358 // Stack here: |
2347 // - home_object | 2359 // - home_object |
2348 // - this (receiver) | 2360 // - this (receiver) |
2349 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. | 2361 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
2350 // - home_object | 2362 // - home_object |
2351 // - key | 2363 // - key |
2352 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); | 2364 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); |
2353 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 2365 PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER); |
2354 | 2366 |
2355 // Replace home_object with target function. | 2367 // Replace home_object with target function. |
2356 __ mov(Operand(esp, kPointerSize), eax); | 2368 __ mov(Operand(esp, kPointerSize), eax); |
2357 | 2369 |
2358 // Stack here: | 2370 // Stack here: |
2359 // - target function | 2371 // - target function |
2360 // - this (receiver) | 2372 // - this (receiver) |
2361 EmitCall(expr); | 2373 EmitCall(expr); |
2362 } | 2374 } |
2363 | 2375 |
2364 | 2376 |
2365 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { | 2377 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
2366 // Load the arguments. | 2378 // Load the arguments. |
2367 ZoneList<Expression*>* args = expr->arguments(); | 2379 ZoneList<Expression*>* args = expr->arguments(); |
2368 int arg_count = args->length(); | 2380 int arg_count = args->length(); |
2369 for (int i = 0; i < arg_count; i++) { | 2381 for (int i = 0; i < arg_count; i++) { |
2370 VisitForStackValue(args->at(i)); | 2382 VisitForStackValue(args->at(i)); |
2371 } | 2383 } |
2372 | 2384 |
2373 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2385 PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS); |
2374 SetCallPosition(expr, expr->tail_call_mode()); | 2386 SetCallPosition(expr, expr->tail_call_mode()); |
2375 if (expr->tail_call_mode() == TailCallMode::kAllow) { | 2387 if (expr->tail_call_mode() == TailCallMode::kAllow) { |
2376 if (FLAG_trace) { | 2388 if (FLAG_trace) { |
2377 __ CallRuntime(Runtime::kTraceTailCall); | 2389 __ CallRuntime(Runtime::kTraceTailCall); |
2378 } | 2390 } |
2379 // Update profiling counters before the tail call since we will | 2391 // Update profiling counters before the tail call since we will |
2380 // not return to this function. | 2392 // not return to this function. |
2381 EmitProfilingCounterHandlingForReturnSequence(true); | 2393 EmitProfilingCounterHandlingForReturnSequence(true); |
2382 } | 2394 } |
2383 Handle<Code> ic = | 2395 Handle<Code> ic = |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 // eval-introduced variables. | 2443 // eval-introduced variables. |
2432 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); | 2444 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); |
2433 | 2445 |
2434 __ bind(&slow); | 2446 __ bind(&slow); |
2435 // Call the runtime to find the function to call (returned in eax) and | 2447 // Call the runtime to find the function to call (returned in eax) and |
2436 // the object holding it (returned in edx). | 2448 // the object holding it (returned in edx). |
2437 __ Push(callee->name()); | 2449 __ Push(callee->name()); |
2438 __ CallRuntime(Runtime::kLoadLookupSlotForCall); | 2450 __ CallRuntime(Runtime::kLoadLookupSlotForCall); |
2439 PushOperand(eax); // Function. | 2451 PushOperand(eax); // Function. |
2440 PushOperand(edx); // Receiver. | 2452 PushOperand(edx); // Receiver. |
2441 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); | 2453 PrepareForBailoutForId(expr->LookupId(), BailoutState::NO_REGISTERS); |
2442 | 2454 |
2443 // If fast case code has been generated, emit code to push the function | 2455 // If fast case code has been generated, emit code to push the function |
2444 // and receiver and have the slow path jump around this code. | 2456 // and receiver and have the slow path jump around this code. |
2445 if (done.is_linked()) { | 2457 if (done.is_linked()) { |
2446 Label call; | 2458 Label call; |
2447 __ jmp(&call, Label::kNear); | 2459 __ jmp(&call, Label::kNear); |
2448 __ bind(&done); | 2460 __ bind(&done); |
2449 // Push function. | 2461 // Push function. |
2450 __ push(eax); | 2462 __ push(eax); |
2451 // The receiver is implicitly the global receiver. Indicate this by | 2463 // The receiver is implicitly the global receiver. Indicate this by |
(...skipping 24 matching lines...) Expand all Loading... |
2476 } | 2488 } |
2477 | 2489 |
2478 // Push a copy of the function (found below the arguments) and | 2490 // Push a copy of the function (found below the arguments) and |
2479 // resolve eval. | 2491 // resolve eval. |
2480 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); | 2492 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); |
2481 EmitResolvePossiblyDirectEval(expr); | 2493 EmitResolvePossiblyDirectEval(expr); |
2482 | 2494 |
2483 // Touch up the stack with the resolved function. | 2495 // Touch up the stack with the resolved function. |
2484 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 2496 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
2485 | 2497 |
2486 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2498 PrepareForBailoutForId(expr->EvalId(), BailoutState::NO_REGISTERS); |
2487 | 2499 |
2488 SetCallPosition(expr); | 2500 SetCallPosition(expr); |
2489 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2501 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2490 __ Set(eax, arg_count); | 2502 __ Set(eax, arg_count); |
2491 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2503 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
2492 expr->tail_call_mode()), | 2504 expr->tail_call_mode()), |
2493 RelocInfo::CODE_TARGET); | 2505 RelocInfo::CODE_TARGET); |
2494 OperandStackDepthDecrement(arg_count + 1); | 2506 OperandStackDepthDecrement(arg_count + 1); |
2495 RecordJSReturnSite(expr); | 2507 RecordJSReturnSite(expr); |
2496 RestoreContext(); | 2508 RestoreContext(); |
(...skipping 28 matching lines...) Expand all Loading... |
2525 __ Move(eax, Immediate(arg_count)); | 2537 __ Move(eax, Immediate(arg_count)); |
2526 __ mov(edi, Operand(esp, arg_count * kPointerSize)); | 2538 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
2527 | 2539 |
2528 // Record call targets in unoptimized code. | 2540 // Record call targets in unoptimized code. |
2529 __ EmitLoadTypeFeedbackVector(ebx); | 2541 __ EmitLoadTypeFeedbackVector(ebx); |
2530 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 2542 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
2531 | 2543 |
2532 CallConstructStub stub(isolate()); | 2544 CallConstructStub stub(isolate()); |
2533 __ call(stub.GetCode(), RelocInfo::CODE_TARGET); | 2545 __ call(stub.GetCode(), RelocInfo::CODE_TARGET); |
2534 OperandStackDepthDecrement(arg_count + 1); | 2546 OperandStackDepthDecrement(arg_count + 1); |
2535 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2547 PrepareForBailoutForId(expr->ReturnId(), BailoutState::TOS_REGISTER); |
2536 RestoreContext(); | 2548 RestoreContext(); |
2537 context()->Plug(eax); | 2549 context()->Plug(eax); |
2538 } | 2550 } |
2539 | 2551 |
2540 | 2552 |
2541 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 2553 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
2542 SuperCallReference* super_call_ref = | 2554 SuperCallReference* super_call_ref = |
2543 expr->expression()->AsSuperCallReference(); | 2555 expr->expression()->AsSuperCallReference(); |
2544 DCHECK_NOT_NULL(super_call_ref); | 2556 DCHECK_NOT_NULL(super_call_ref); |
2545 | 2557 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2960 } | 2972 } |
2961 | 2973 |
2962 | 2974 |
2963 void FullCodeGenerator::EmitCall(CallRuntime* expr) { | 2975 void FullCodeGenerator::EmitCall(CallRuntime* expr) { |
2964 ZoneList<Expression*>* args = expr->arguments(); | 2976 ZoneList<Expression*>* args = expr->arguments(); |
2965 DCHECK_LE(2, args->length()); | 2977 DCHECK_LE(2, args->length()); |
2966 // Push target, receiver and arguments onto the stack. | 2978 // Push target, receiver and arguments onto the stack. |
2967 for (Expression* const arg : *args) { | 2979 for (Expression* const arg : *args) { |
2968 VisitForStackValue(arg); | 2980 VisitForStackValue(arg); |
2969 } | 2981 } |
2970 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2982 PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS); |
2971 // Move target to edi. | 2983 // Move target to edi. |
2972 int const argc = args->length() - 2; | 2984 int const argc = args->length() - 2; |
2973 __ mov(edi, Operand(esp, (argc + 1) * kPointerSize)); | 2985 __ mov(edi, Operand(esp, (argc + 1) * kPointerSize)); |
2974 // Call the target. | 2986 // Call the target. |
2975 __ mov(eax, Immediate(argc)); | 2987 __ mov(eax, Immediate(argc)); |
2976 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 2988 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
2977 OperandStackDepthDecrement(argc + 1); | 2989 OperandStackDepthDecrement(argc + 1); |
2978 RestoreContext(); | 2990 RestoreContext(); |
2979 // Discard the function left on TOS. | 2991 // Discard the function left on TOS. |
2980 context()->DropAndPlug(1, eax); | 2992 context()->DropAndPlug(1, eax); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3174 // because we need to prepare a pair of extra administrative AST ids | 3186 // because we need to prepare a pair of extra administrative AST ids |
3175 // for the optimizing compiler. | 3187 // for the optimizing compiler. |
3176 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); | 3188 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); |
3177 Label materialize_true, materialize_false, done; | 3189 Label materialize_true, materialize_false, done; |
3178 VisitForControl(expr->expression(), | 3190 VisitForControl(expr->expression(), |
3179 &materialize_false, | 3191 &materialize_false, |
3180 &materialize_true, | 3192 &materialize_true, |
3181 &materialize_true); | 3193 &materialize_true); |
3182 if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1); | 3194 if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1); |
3183 __ bind(&materialize_true); | 3195 __ bind(&materialize_true); |
3184 PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS); | 3196 PrepareForBailoutForId(expr->MaterializeTrueId(), |
| 3197 BailoutState::NO_REGISTERS); |
3185 if (context()->IsAccumulatorValue()) { | 3198 if (context()->IsAccumulatorValue()) { |
3186 __ mov(eax, isolate()->factory()->true_value()); | 3199 __ mov(eax, isolate()->factory()->true_value()); |
3187 } else { | 3200 } else { |
3188 __ Push(isolate()->factory()->true_value()); | 3201 __ Push(isolate()->factory()->true_value()); |
3189 } | 3202 } |
3190 __ jmp(&done, Label::kNear); | 3203 __ jmp(&done, Label::kNear); |
3191 __ bind(&materialize_false); | 3204 __ bind(&materialize_false); |
3192 PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS); | 3205 PrepareForBailoutForId(expr->MaterializeFalseId(), |
| 3206 BailoutState::NO_REGISTERS); |
3193 if (context()->IsAccumulatorValue()) { | 3207 if (context()->IsAccumulatorValue()) { |
3194 __ mov(eax, isolate()->factory()->false_value()); | 3208 __ mov(eax, isolate()->factory()->false_value()); |
3195 } else { | 3209 } else { |
3196 __ Push(isolate()->factory()->false_value()); | 3210 __ Push(isolate()->factory()->false_value()); |
3197 } | 3211 } |
3198 __ bind(&done); | 3212 __ bind(&done); |
3199 } | 3213 } |
3200 break; | 3214 break; |
3201 } | 3215 } |
3202 | 3216 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3281 } | 3295 } |
3282 | 3296 |
3283 case VARIABLE: | 3297 case VARIABLE: |
3284 UNREACHABLE(); | 3298 UNREACHABLE(); |
3285 } | 3299 } |
3286 } | 3300 } |
3287 | 3301 |
3288 // We need a second deoptimization point after loading the value | 3302 // We need a second deoptimization point after loading the value |
3289 // in case evaluating the property load my have a side effect. | 3303 // in case evaluating the property load my have a side effect. |
3290 if (assign_type == VARIABLE) { | 3304 if (assign_type == VARIABLE) { |
3291 PrepareForBailout(expr->expression(), TOS_REG); | 3305 PrepareForBailout(expr->expression(), BailoutState::TOS_REGISTER); |
3292 } else { | 3306 } else { |
3293 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 3307 PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER); |
3294 } | 3308 } |
3295 | 3309 |
3296 // Inline smi case if we are in a loop. | 3310 // Inline smi case if we are in a loop. |
3297 Label done, stub_call; | 3311 Label done, stub_call; |
3298 JumpPatchSite patch_site(masm_); | 3312 JumpPatchSite patch_site(masm_); |
3299 if (ShouldInlineSmiCase(expr->op())) { | 3313 if (ShouldInlineSmiCase(expr->op())) { |
3300 Label slow; | 3314 Label slow; |
3301 patch_site.EmitJumpIfNotSmi(eax, &slow, Label::kNear); | 3315 patch_site.EmitJumpIfNotSmi(eax, &slow, Label::kNear); |
3302 | 3316 |
3303 // Save result for postfix expressions. | 3317 // Save result for postfix expressions. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 } else { | 3352 } else { |
3339 __ add(eax, Immediate(Smi::FromInt(1))); | 3353 __ add(eax, Immediate(Smi::FromInt(1))); |
3340 } | 3354 } |
3341 __ jmp(&stub_call, Label::kNear); | 3355 __ jmp(&stub_call, Label::kNear); |
3342 __ bind(&slow); | 3356 __ bind(&slow); |
3343 } | 3357 } |
3344 | 3358 |
3345 // Convert old value into a number. | 3359 // Convert old value into a number. |
3346 ToNumberStub convert_stub(isolate()); | 3360 ToNumberStub convert_stub(isolate()); |
3347 __ CallStub(&convert_stub); | 3361 __ CallStub(&convert_stub); |
3348 PrepareForBailoutForId(expr->ToNumberId(), TOS_REG); | 3362 PrepareForBailoutForId(expr->ToNumberId(), BailoutState::TOS_REGISTER); |
3349 | 3363 |
3350 // Save result for postfix expressions. | 3364 // Save result for postfix expressions. |
3351 if (expr->is_postfix()) { | 3365 if (expr->is_postfix()) { |
3352 if (!context()->IsEffect()) { | 3366 if (!context()->IsEffect()) { |
3353 // Save the result on the stack. If we have a named or keyed property | 3367 // Save the result on the stack. If we have a named or keyed property |
3354 // we store the result under the receiver that is currently on top | 3368 // we store the result under the receiver that is currently on top |
3355 // of the stack. | 3369 // of the stack. |
3356 switch (assign_type) { | 3370 switch (assign_type) { |
3357 case VARIABLE: | 3371 case VARIABLE: |
3358 PushOperand(eax); | 3372 PushOperand(eax); |
(...skipping 27 matching lines...) Expand all Loading... |
3386 __ bind(&done); | 3400 __ bind(&done); |
3387 | 3401 |
3388 // Store the value returned in eax. | 3402 // Store the value returned in eax. |
3389 switch (assign_type) { | 3403 switch (assign_type) { |
3390 case VARIABLE: | 3404 case VARIABLE: |
3391 if (expr->is_postfix()) { | 3405 if (expr->is_postfix()) { |
3392 // Perform the assignment as if via '='. | 3406 // Perform the assignment as if via '='. |
3393 { EffectContext context(this); | 3407 { EffectContext context(this); |
3394 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3408 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3395 Token::ASSIGN, expr->CountSlot()); | 3409 Token::ASSIGN, expr->CountSlot()); |
3396 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3410 PrepareForBailoutForId(expr->AssignmentId(), |
| 3411 BailoutState::TOS_REGISTER); |
3397 context.Plug(eax); | 3412 context.Plug(eax); |
3398 } | 3413 } |
3399 // For all contexts except EffectContext We have the result on | 3414 // For all contexts except EffectContext We have the result on |
3400 // top of the stack. | 3415 // top of the stack. |
3401 if (!context()->IsEffect()) { | 3416 if (!context()->IsEffect()) { |
3402 context()->PlugTOS(); | 3417 context()->PlugTOS(); |
3403 } | 3418 } |
3404 } else { | 3419 } else { |
3405 // Perform the assignment as if via '='. | 3420 // Perform the assignment as if via '='. |
3406 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3421 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3407 Token::ASSIGN, expr->CountSlot()); | 3422 Token::ASSIGN, expr->CountSlot()); |
3408 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3423 PrepareForBailoutForId(expr->AssignmentId(), |
| 3424 BailoutState::TOS_REGISTER); |
3409 context()->Plug(eax); | 3425 context()->Plug(eax); |
3410 } | 3426 } |
3411 break; | 3427 break; |
3412 case NAMED_PROPERTY: { | 3428 case NAMED_PROPERTY: { |
3413 __ mov(StoreDescriptor::NameRegister(), | 3429 __ mov(StoreDescriptor::NameRegister(), |
3414 prop->key()->AsLiteral()->value()); | 3430 prop->key()->AsLiteral()->value()); |
3415 PopOperand(StoreDescriptor::ReceiverRegister()); | 3431 PopOperand(StoreDescriptor::ReceiverRegister()); |
3416 EmitLoadStoreICSlot(expr->CountSlot()); | 3432 EmitLoadStoreICSlot(expr->CountSlot()); |
3417 CallStoreIC(); | 3433 CallStoreIC(); |
3418 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3434 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3419 if (expr->is_postfix()) { | 3435 if (expr->is_postfix()) { |
3420 if (!context()->IsEffect()) { | 3436 if (!context()->IsEffect()) { |
3421 context()->PlugTOS(); | 3437 context()->PlugTOS(); |
3422 } | 3438 } |
3423 } else { | 3439 } else { |
3424 context()->Plug(eax); | 3440 context()->Plug(eax); |
3425 } | 3441 } |
3426 break; | 3442 break; |
3427 } | 3443 } |
3428 case NAMED_SUPER_PROPERTY: { | 3444 case NAMED_SUPER_PROPERTY: { |
(...skipping 18 matching lines...) Expand all Loading... |
3447 } | 3463 } |
3448 break; | 3464 break; |
3449 } | 3465 } |
3450 case KEYED_PROPERTY: { | 3466 case KEYED_PROPERTY: { |
3451 PopOperand(StoreDescriptor::NameRegister()); | 3467 PopOperand(StoreDescriptor::NameRegister()); |
3452 PopOperand(StoreDescriptor::ReceiverRegister()); | 3468 PopOperand(StoreDescriptor::ReceiverRegister()); |
3453 Handle<Code> ic = | 3469 Handle<Code> ic = |
3454 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 3470 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
3455 EmitLoadStoreICSlot(expr->CountSlot()); | 3471 EmitLoadStoreICSlot(expr->CountSlot()); |
3456 CallIC(ic); | 3472 CallIC(ic); |
3457 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3473 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3458 if (expr->is_postfix()) { | 3474 if (expr->is_postfix()) { |
3459 // Result is on the stack | 3475 // Result is on the stack |
3460 if (!context()->IsEffect()) { | 3476 if (!context()->IsEffect()) { |
3461 context()->PlugTOS(); | 3477 context()->PlugTOS(); |
3462 } | 3478 } |
3463 } else { | 3479 } else { |
3464 context()->Plug(eax); | 3480 context()->Plug(eax); |
3465 } | 3481 } |
3466 break; | 3482 break; |
3467 } | 3483 } |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3829 isolate->builtins()->OnStackReplacement()->entry(), | 3845 isolate->builtins()->OnStackReplacement()->entry(), |
3830 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3846 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3831 return ON_STACK_REPLACEMENT; | 3847 return ON_STACK_REPLACEMENT; |
3832 } | 3848 } |
3833 | 3849 |
3834 | 3850 |
3835 } // namespace internal | 3851 } // namespace internal |
3836 } // namespace v8 | 3852 } // namespace v8 |
3837 | 3853 |
3838 #endif // V8_TARGET_ARCH_IA32 | 3854 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |