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