| 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // Possibly allocate a local context. | 159 // Possibly allocate a local context. |
| 160 if (info->scope()->num_heap_slots() > 0) { | 160 if (info->scope()->num_heap_slots() > 0) { |
| 161 Comment cmnt(masm_, "[ Allocate context"); | 161 Comment cmnt(masm_, "[ Allocate context"); |
| 162 bool need_write_barrier = true; | 162 bool need_write_barrier = true; |
| 163 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 163 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 164 // Argument to NewContext is the function, which is still in rdi. | 164 // Argument to NewContext is the function, which is still in rdi. |
| 165 if (info->scope()->is_script_scope()) { | 165 if (info->scope()->is_script_scope()) { |
| 166 __ Push(rdi); | 166 __ Push(rdi); |
| 167 __ Push(info->scope()->GetScopeInfo(info->isolate())); | 167 __ Push(info->scope()->GetScopeInfo(info->isolate())); |
| 168 __ CallRuntime(Runtime::kNewScriptContext); | 168 __ CallRuntime(Runtime::kNewScriptContext); |
| 169 PrepareForBailoutForId(BailoutId::ScriptContext(), TOS_REG); | 169 PrepareForBailoutForId(BailoutId::ScriptContext(), |
| 170 Deoptimizer::BailoutState::TOS_REGISTER); |
| 170 // The new target value is not used, clobbering is safe. | 171 // The new target value is not used, clobbering is safe. |
| 171 DCHECK_NULL(info->scope()->new_target_var()); | 172 DCHECK_NULL(info->scope()->new_target_var()); |
| 172 } else { | 173 } else { |
| 173 if (info->scope()->new_target_var() != nullptr) { | 174 if (info->scope()->new_target_var() != nullptr) { |
| 174 __ Push(rdx); // Preserve new target. | 175 __ Push(rdx); // Preserve new target. |
| 175 } | 176 } |
| 176 if (slots <= FastNewContextStub::kMaximumSlots) { | 177 if (slots <= FastNewContextStub::kMaximumSlots) { |
| 177 FastNewContextStub stub(isolate(), slots); | 178 FastNewContextStub stub(isolate(), slots); |
| 178 __ CallStub(&stub); | 179 __ CallStub(&stub); |
| 179 // Result of FastNewContextStub is always in new space. | 180 // Result of FastNewContextStub is always in new space. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 __ Abort(kExpectedNewSpaceObject); | 216 __ Abort(kExpectedNewSpaceObject); |
| 216 __ bind(&done); | 217 __ bind(&done); |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 } | 220 } |
| 220 } | 221 } |
| 221 | 222 |
| 222 // Register holding this function and new target are both trashed in case we | 223 // Register holding this function and new target are both trashed in case we |
| 223 // bailout here. But since that can happen only when new target is not used | 224 // bailout here. But since that can happen only when new target is not used |
| 224 // and we allocate a context, the value of |function_in_register| is correct. | 225 // and we allocate a context, the value of |function_in_register| is correct. |
| 225 PrepareForBailoutForId(BailoutId::FunctionContext(), NO_REGISTERS); | 226 PrepareForBailoutForId(BailoutId::FunctionContext(), |
| 227 Deoptimizer::BailoutState::NO_REGISTERS); |
| 226 | 228 |
| 227 // Possibly set up a local binding to the this function which is used in | 229 // Possibly set up a local binding to the this function which is used in |
| 228 // derived constructors with super calls. | 230 // derived constructors with super calls. |
| 229 Variable* this_function_var = scope()->this_function_var(); | 231 Variable* this_function_var = scope()->this_function_var(); |
| 230 if (this_function_var != nullptr) { | 232 if (this_function_var != nullptr) { |
| 231 Comment cmnt(masm_, "[ This function"); | 233 Comment cmnt(masm_, "[ This function"); |
| 232 if (!function_in_register) { | 234 if (!function_in_register) { |
| 233 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 235 __ movp(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 234 // The write barrier clobbers register again, keep it marked as such. | 236 // The write barrier clobbers register again, keep it marked as such. |
| 235 } | 237 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 281 |
| 280 SetVar(arguments, rax, rbx, rdx); | 282 SetVar(arguments, rax, rbx, rdx); |
| 281 } | 283 } |
| 282 | 284 |
| 283 if (FLAG_trace) { | 285 if (FLAG_trace) { |
| 284 __ CallRuntime(Runtime::kTraceEnter); | 286 __ CallRuntime(Runtime::kTraceEnter); |
| 285 } | 287 } |
| 286 | 288 |
| 287 // Visit the declarations and body unless there is an illegal | 289 // Visit the declarations and body unless there is an illegal |
| 288 // redeclaration. | 290 // redeclaration. |
| 289 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); | 291 PrepareForBailoutForId(BailoutId::FunctionEntry(), |
| 292 Deoptimizer::BailoutState::NO_REGISTERS); |
| 290 { | 293 { |
| 291 Comment cmnt(masm_, "[ Declarations"); | 294 Comment cmnt(masm_, "[ Declarations"); |
| 292 VisitDeclarations(scope()->declarations()); | 295 VisitDeclarations(scope()->declarations()); |
| 293 } | 296 } |
| 294 | 297 |
| 295 // Assert that the declarations do not use ICs. Otherwise the debugger | 298 // Assert that the declarations do not use ICs. Otherwise the debugger |
| 296 // 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 |
| 297 // recompiled code. | 300 // recompiled code. |
| 298 DCHECK_EQ(0, ic_total_count_); | 301 DCHECK_EQ(0, ic_total_count_); |
| 299 | 302 |
| 300 { | 303 { |
| 301 Comment cmnt(masm_, "[ Stack check"); | 304 Comment cmnt(masm_, "[ Stack check"); |
| 302 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); | 305 PrepareForBailoutForId(BailoutId::Declarations(), |
| 306 Deoptimizer::BailoutState::NO_REGISTERS); |
| 303 Label ok; | 307 Label ok; |
| 304 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | 308 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
| 305 __ j(above_equal, &ok, Label::kNear); | 309 __ j(above_equal, &ok, Label::kNear); |
| 306 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); | 310 __ call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); |
| 307 __ bind(&ok); | 311 __ bind(&ok); |
| 308 } | 312 } |
| 309 | 313 |
| 310 { | 314 { |
| 311 Comment cmnt(masm_, "[ Body"); | 315 Comment cmnt(masm_, "[ Body"); |
| 312 DCHECK(loop_depth() == 0); | 316 DCHECK(loop_depth() == 0); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 369 |
| 366 // Record a mapping of this PC offset to the OSR id. This is used to find | 370 // Record a mapping of this PC offset to the OSR id. This is used to find |
| 367 // the AST id from the unoptimized code in order to use it as a key into | 371 // the AST id from the unoptimized code in order to use it as a key into |
| 368 // the deoptimization input data found in the optimized code. | 372 // the deoptimization input data found in the optimized code. |
| 369 RecordBackEdge(stmt->OsrEntryId()); | 373 RecordBackEdge(stmt->OsrEntryId()); |
| 370 | 374 |
| 371 EmitProfilingCounterReset(); | 375 EmitProfilingCounterReset(); |
| 372 } | 376 } |
| 373 __ bind(&ok); | 377 __ bind(&ok); |
| 374 | 378 |
| 375 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 379 PrepareForBailoutForId(stmt->EntryId(), |
| 380 Deoptimizer::BailoutState::NO_REGISTERS); |
| 376 // Record a mapping of the OSR id to this PC. This is used if the OSR | 381 // Record a mapping of the OSR id to this PC. This is used if the OSR |
| 377 // entry becomes the target of a bailout. We don't expect it to be, but | 382 // entry becomes the target of a bailout. We don't expect it to be, but |
| 378 // we want it to work if it is. | 383 // we want it to work if it is. |
| 379 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); | 384 PrepareForBailoutForId(stmt->OsrEntryId(), |
| 385 Deoptimizer::BailoutState::NO_REGISTERS); |
| 380 } | 386 } |
| 381 | 387 |
| 382 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( | 388 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( |
| 383 bool is_tail_call) { | 389 bool is_tail_call) { |
| 384 // Pretend that the exit is a backwards jump to the entry. | 390 // Pretend that the exit is a backwards jump to the entry. |
| 385 int weight = 1; | 391 int weight = 1; |
| 386 if (info_->ShouldSelfOptimize()) { | 392 if (info_->ShouldSelfOptimize()) { |
| 387 weight = FLAG_interrupt_budget / FLAG_self_opt_count; | 393 weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
| 388 } else { | 394 } else { |
| 389 int distance = masm_->pc_offset(); | 395 int distance = masm_->pc_offset(); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 bool should_normalize, | 691 bool should_normalize, |
| 686 Label* if_true, | 692 Label* if_true, |
| 687 Label* if_false) { | 693 Label* if_false) { |
| 688 // Only prepare for bailouts before splits if we're in a test | 694 // Only prepare for bailouts before splits if we're in a test |
| 689 // context. Otherwise, we let the Visit function deal with the | 695 // context. Otherwise, we let the Visit function deal with the |
| 690 // preparation to avoid preparing with the same AST id twice. | 696 // preparation to avoid preparing with the same AST id twice. |
| 691 if (!context()->IsTest()) return; | 697 if (!context()->IsTest()) return; |
| 692 | 698 |
| 693 Label skip; | 699 Label skip; |
| 694 if (should_normalize) __ jmp(&skip, Label::kNear); | 700 if (should_normalize) __ jmp(&skip, Label::kNear); |
| 695 PrepareForBailout(expr, TOS_REG); | 701 PrepareForBailout(expr, Deoptimizer::BailoutState::TOS_REGISTER); |
| 696 if (should_normalize) { | 702 if (should_normalize) { |
| 697 __ CompareRoot(rax, Heap::kTrueValueRootIndex); | 703 __ CompareRoot(rax, Heap::kTrueValueRootIndex); |
| 698 Split(equal, if_true, if_false, NULL); | 704 Split(equal, if_true, if_false, NULL); |
| 699 __ bind(&skip); | 705 __ bind(&skip); |
| 700 } | 706 } |
| 701 } | 707 } |
| 702 | 708 |
| 703 | 709 |
| 704 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { | 710 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
| 705 // The variable in the declaration always resides in the current context. | 711 // The variable in the declaration always resides in the current context. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } | 747 } |
| 742 break; | 748 break; |
| 743 | 749 |
| 744 case VariableLocation::CONTEXT: | 750 case VariableLocation::CONTEXT: |
| 745 if (hole_init) { | 751 if (hole_init) { |
| 746 Comment cmnt(masm_, "[ VariableDeclaration"); | 752 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 747 EmitDebugCheckDeclarationContext(variable); | 753 EmitDebugCheckDeclarationContext(variable); |
| 748 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); | 754 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); |
| 749 __ movp(ContextOperand(rsi, variable->index()), kScratchRegister); | 755 __ movp(ContextOperand(rsi, variable->index()), kScratchRegister); |
| 750 // No write barrier since the hole value is in old space. | 756 // No write barrier since the hole value is in old space. |
| 751 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 757 PrepareForBailoutForId(proxy->id(), |
| 758 Deoptimizer::BailoutState::NO_REGISTERS); |
| 752 } | 759 } |
| 753 break; | 760 break; |
| 754 | 761 |
| 755 case VariableLocation::LOOKUP: { | 762 case VariableLocation::LOOKUP: { |
| 756 Comment cmnt(masm_, "[ VariableDeclaration"); | 763 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 757 __ Push(variable->name()); | 764 __ Push(variable->name()); |
| 758 // Declaration nodes are always introduced in one of four modes. | 765 // Declaration nodes are always introduced in one of four modes. |
| 759 DCHECK(IsDeclaredVariableMode(mode)); | 766 DCHECK(IsDeclaredVariableMode(mode)); |
| 760 // Push initial value, if any. | 767 // Push initial value, if any. |
| 761 // Note: For variables we must not push an initial value (such as | 768 // Note: For variables we must not push an initial value (such as |
| 762 // 'undefined') because we may have a (legal) redeclaration and we | 769 // 'undefined') because we may have a (legal) redeclaration and we |
| 763 // must not destroy the current value. | 770 // must not destroy the current value. |
| 764 if (hole_init) { | 771 if (hole_init) { |
| 765 __ PushRoot(Heap::kTheHoleValueRootIndex); | 772 __ PushRoot(Heap::kTheHoleValueRootIndex); |
| 766 } else { | 773 } else { |
| 767 __ Push(Smi::FromInt(0)); // Indicates no initial value. | 774 __ Push(Smi::FromInt(0)); // Indicates no initial value. |
| 768 } | 775 } |
| 769 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes())); | 776 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes())); |
| 770 __ CallRuntime(Runtime::kDeclareLookupSlot); | 777 __ CallRuntime(Runtime::kDeclareLookupSlot); |
| 771 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 778 PrepareForBailoutForId(proxy->id(), |
| 779 Deoptimizer::BailoutState::NO_REGISTERS); |
| 772 break; | 780 break; |
| 773 } | 781 } |
| 774 } | 782 } |
| 775 } | 783 } |
| 776 | 784 |
| 777 | 785 |
| 778 void FullCodeGenerator::VisitFunctionDeclaration( | 786 void FullCodeGenerator::VisitFunctionDeclaration( |
| 779 FunctionDeclaration* declaration) { | 787 FunctionDeclaration* declaration) { |
| 780 VariableProxy* proxy = declaration->proxy(); | 788 VariableProxy* proxy = declaration->proxy(); |
| 781 Variable* variable = proxy->var(); | 789 Variable* variable = proxy->var(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 806 __ movp(ContextOperand(rsi, variable->index()), result_register()); | 814 __ movp(ContextOperand(rsi, variable->index()), result_register()); |
| 807 int offset = Context::SlotOffset(variable->index()); | 815 int offset = Context::SlotOffset(variable->index()); |
| 808 // We know that we have written a function, which is not a smi. | 816 // We know that we have written a function, which is not a smi. |
| 809 __ RecordWriteContextSlot(rsi, | 817 __ RecordWriteContextSlot(rsi, |
| 810 offset, | 818 offset, |
| 811 result_register(), | 819 result_register(), |
| 812 rcx, | 820 rcx, |
| 813 kDontSaveFPRegs, | 821 kDontSaveFPRegs, |
| 814 EMIT_REMEMBERED_SET, | 822 EMIT_REMEMBERED_SET, |
| 815 OMIT_SMI_CHECK); | 823 OMIT_SMI_CHECK); |
| 816 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 824 PrepareForBailoutForId(proxy->id(), |
| 825 Deoptimizer::BailoutState::NO_REGISTERS); |
| 817 break; | 826 break; |
| 818 } | 827 } |
| 819 | 828 |
| 820 case VariableLocation::LOOKUP: { | 829 case VariableLocation::LOOKUP: { |
| 821 Comment cmnt(masm_, "[ FunctionDeclaration"); | 830 Comment cmnt(masm_, "[ FunctionDeclaration"); |
| 822 PushOperand(variable->name()); | 831 PushOperand(variable->name()); |
| 823 VisitForStackValue(declaration->fun()); | 832 VisitForStackValue(declaration->fun()); |
| 824 PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes())); | 833 PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes())); |
| 825 CallRuntimeWithOperands(Runtime::kDeclareLookupSlot); | 834 CallRuntimeWithOperands(Runtime::kDeclareLookupSlot); |
| 826 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 835 PrepareForBailoutForId(proxy->id(), |
| 836 Deoptimizer::BailoutState::NO_REGISTERS); |
| 827 break; | 837 break; |
| 828 } | 838 } |
| 829 } | 839 } |
| 830 } | 840 } |
| 831 | 841 |
| 832 | 842 |
| 833 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 843 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
| 834 // Call the runtime to declare the globals. | 844 // Call the runtime to declare the globals. |
| 835 __ Push(pairs); | 845 __ Push(pairs); |
| 836 __ Push(Smi::FromInt(DeclareGlobalsFlags())); | 846 __ Push(Smi::FromInt(DeclareGlobalsFlags())); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 847 } | 857 } |
| 848 | 858 |
| 849 | 859 |
| 850 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { | 860 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
| 851 Comment cmnt(masm_, "[ SwitchStatement"); | 861 Comment cmnt(masm_, "[ SwitchStatement"); |
| 852 Breakable nested_statement(this, stmt); | 862 Breakable nested_statement(this, stmt); |
| 853 SetStatementPosition(stmt); | 863 SetStatementPosition(stmt); |
| 854 | 864 |
| 855 // Keep the switch value on the stack until a case matches. | 865 // Keep the switch value on the stack until a case matches. |
| 856 VisitForStackValue(stmt->tag()); | 866 VisitForStackValue(stmt->tag()); |
| 857 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 867 PrepareForBailoutForId(stmt->EntryId(), |
| 868 Deoptimizer::BailoutState::NO_REGISTERS); |
| 858 | 869 |
| 859 ZoneList<CaseClause*>* clauses = stmt->cases(); | 870 ZoneList<CaseClause*>* clauses = stmt->cases(); |
| 860 CaseClause* default_clause = NULL; // Can occur anywhere in the list. | 871 CaseClause* default_clause = NULL; // Can occur anywhere in the list. |
| 861 | 872 |
| 862 Label next_test; // Recycled for each test. | 873 Label next_test; // Recycled for each test. |
| 863 // Compile all the tests with branches to their bodies. | 874 // Compile all the tests with branches to their bodies. |
| 864 for (int i = 0; i < clauses->length(); i++) { | 875 for (int i = 0; i < clauses->length(); i++) { |
| 865 CaseClause* clause = clauses->at(i); | 876 CaseClause* clause = clauses->at(i); |
| 866 clause->body_target()->Unuse(); | 877 clause->body_target()->Unuse(); |
| 867 | 878 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 897 | 908 |
| 898 // Record position before stub call for type feedback. | 909 // Record position before stub call for type feedback. |
| 899 SetExpressionPosition(clause); | 910 SetExpressionPosition(clause); |
| 900 Handle<Code> ic = | 911 Handle<Code> ic = |
| 901 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); | 912 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); |
| 902 CallIC(ic, clause->CompareId()); | 913 CallIC(ic, clause->CompareId()); |
| 903 patch_site.EmitPatchInfo(); | 914 patch_site.EmitPatchInfo(); |
| 904 | 915 |
| 905 Label skip; | 916 Label skip; |
| 906 __ jmp(&skip, Label::kNear); | 917 __ jmp(&skip, Label::kNear); |
| 907 PrepareForBailout(clause, TOS_REG); | 918 PrepareForBailout(clause, Deoptimizer::BailoutState::TOS_REGISTER); |
| 908 __ CompareRoot(rax, Heap::kTrueValueRootIndex); | 919 __ CompareRoot(rax, Heap::kTrueValueRootIndex); |
| 909 __ j(not_equal, &next_test); | 920 __ j(not_equal, &next_test); |
| 910 __ Drop(1); | 921 __ Drop(1); |
| 911 __ jmp(clause->body_target()); | 922 __ jmp(clause->body_target()); |
| 912 __ bind(&skip); | 923 __ bind(&skip); |
| 913 | 924 |
| 914 __ testp(rax, rax); | 925 __ testp(rax, rax); |
| 915 __ j(not_equal, &next_test); | 926 __ j(not_equal, &next_test); |
| 916 __ Drop(1); // Switch value is no longer needed. | 927 __ Drop(1); // Switch value is no longer needed. |
| 917 __ jmp(clause->body_target()); | 928 __ jmp(clause->body_target()); |
| 918 } | 929 } |
| 919 | 930 |
| 920 // Discard the test value and jump to the default if present, otherwise to | 931 // Discard the test value and jump to the default if present, otherwise to |
| 921 // the end of the statement. | 932 // the end of the statement. |
| 922 __ bind(&next_test); | 933 __ bind(&next_test); |
| 923 DropOperands(1); // Switch value is no longer needed. | 934 DropOperands(1); // Switch value is no longer needed. |
| 924 if (default_clause == NULL) { | 935 if (default_clause == NULL) { |
| 925 __ jmp(nested_statement.break_label()); | 936 __ jmp(nested_statement.break_label()); |
| 926 } else { | 937 } else { |
| 927 __ jmp(default_clause->body_target()); | 938 __ jmp(default_clause->body_target()); |
| 928 } | 939 } |
| 929 | 940 |
| 930 // Compile all the case bodies. | 941 // Compile all the case bodies. |
| 931 for (int i = 0; i < clauses->length(); i++) { | 942 for (int i = 0; i < clauses->length(); i++) { |
| 932 Comment cmnt(masm_, "[ Case body"); | 943 Comment cmnt(masm_, "[ Case body"); |
| 933 CaseClause* clause = clauses->at(i); | 944 CaseClause* clause = clauses->at(i); |
| 934 __ bind(clause->body_target()); | 945 __ bind(clause->body_target()); |
| 935 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); | 946 PrepareForBailoutForId(clause->EntryId(), |
| 947 Deoptimizer::BailoutState::NO_REGISTERS); |
| 936 VisitStatements(clause->statements()); | 948 VisitStatements(clause->statements()); |
| 937 } | 949 } |
| 938 | 950 |
| 939 __ bind(nested_statement.break_label()); | 951 __ bind(nested_statement.break_label()); |
| 940 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 952 PrepareForBailoutForId(stmt->ExitId(), |
| 953 Deoptimizer::BailoutState::NO_REGISTERS); |
| 941 } | 954 } |
| 942 | 955 |
| 943 | 956 |
| 944 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 957 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
| 945 Comment cmnt(masm_, "[ ForInStatement"); | 958 Comment cmnt(masm_, "[ ForInStatement"); |
| 946 SetStatementPosition(stmt, SKIP_BREAK); | 959 SetStatementPosition(stmt, SKIP_BREAK); |
| 947 | 960 |
| 948 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 961 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
| 949 | 962 |
| 950 // Get the object to enumerate over. | 963 // Get the object to enumerate over. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 963 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rcx); | 976 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rcx); |
| 964 __ j(above_equal, &done_convert, Label::kNear); | 977 __ j(above_equal, &done_convert, Label::kNear); |
| 965 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 978 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
| 966 __ j(equal, &exit); | 979 __ j(equal, &exit); |
| 967 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 980 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
| 968 __ j(equal, &exit); | 981 __ j(equal, &exit); |
| 969 __ bind(&convert); | 982 __ bind(&convert); |
| 970 ToObjectStub stub(isolate()); | 983 ToObjectStub stub(isolate()); |
| 971 __ CallStub(&stub); | 984 __ CallStub(&stub); |
| 972 __ bind(&done_convert); | 985 __ bind(&done_convert); |
| 973 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); | 986 PrepareForBailoutForId(stmt->ToObjectId(), |
| 987 Deoptimizer::BailoutState::TOS_REGISTER); |
| 974 __ Push(rax); | 988 __ Push(rax); |
| 975 | 989 |
| 976 // Check cache validity in generated code. If we cannot guarantee cache | 990 // Check cache validity in generated code. If we cannot guarantee cache |
| 977 // validity, call the runtime system to check cache validity or get the | 991 // validity, call the runtime system to check cache validity or get the |
| 978 // property names in a fixed array. Note: Proxies never have an enum cache, | 992 // property names in a fixed array. Note: Proxies never have an enum cache, |
| 979 // so will always take the slow path. | 993 // so will always take the slow path. |
| 980 Label call_runtime; | 994 Label call_runtime; |
| 981 __ CheckEnumCache(&call_runtime); | 995 __ CheckEnumCache(&call_runtime); |
| 982 | 996 |
| 983 // The enum cache is valid. Load the map of the object being | 997 // The enum cache is valid. Load the map of the object being |
| 984 // iterated over and use the cache for the iteration. | 998 // iterated over and use the cache for the iteration. |
| 985 Label use_cache; | 999 Label use_cache; |
| 986 __ movp(rax, FieldOperand(rax, HeapObject::kMapOffset)); | 1000 __ movp(rax, FieldOperand(rax, HeapObject::kMapOffset)); |
| 987 __ jmp(&use_cache, Label::kNear); | 1001 __ jmp(&use_cache, Label::kNear); |
| 988 | 1002 |
| 989 // Get the set of properties to enumerate. | 1003 // Get the set of properties to enumerate. |
| 990 __ bind(&call_runtime); | 1004 __ bind(&call_runtime); |
| 991 __ Push(rax); // Duplicate the enumerable object on the stack. | 1005 __ Push(rax); // Duplicate the enumerable object on the stack. |
| 992 __ CallRuntime(Runtime::kForInEnumerate); | 1006 __ CallRuntime(Runtime::kForInEnumerate); |
| 993 PrepareForBailoutForId(stmt->EnumId(), TOS_REG); | 1007 PrepareForBailoutForId(stmt->EnumId(), |
| 1008 Deoptimizer::BailoutState::TOS_REGISTER); |
| 994 | 1009 |
| 995 // If we got a map from the runtime call, we can do a fast | 1010 // If we got a map from the runtime call, we can do a fast |
| 996 // modification check. Otherwise, we got a fixed array, and we have | 1011 // modification check. Otherwise, we got a fixed array, and we have |
| 997 // to do a slow check. | 1012 // to do a slow check. |
| 998 Label fixed_array; | 1013 Label fixed_array; |
| 999 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), | 1014 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), |
| 1000 Heap::kMetaMapRootIndex); | 1015 Heap::kMetaMapRootIndex); |
| 1001 __ j(not_equal, &fixed_array); | 1016 __ j(not_equal, &fixed_array); |
| 1002 | 1017 |
| 1003 // We got a map in register rax. Get the enumeration cache from it. | 1018 // We got a map in register rax. Get the enumeration cache from it. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1025 __ jmp(&exit); | 1040 __ jmp(&exit); |
| 1026 | 1041 |
| 1027 // We got a fixed array in register rax. Iterate through that. | 1042 // We got a fixed array in register rax. Iterate through that. |
| 1028 __ bind(&fixed_array); | 1043 __ bind(&fixed_array); |
| 1029 | 1044 |
| 1030 __ movp(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object | 1045 __ movp(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object |
| 1031 __ Push(Smi::FromInt(1)); // Smi(1) indicates slow check | 1046 __ Push(Smi::FromInt(1)); // Smi(1) indicates slow check |
| 1032 __ Push(rax); // Array | 1047 __ Push(rax); // Array |
| 1033 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset)); | 1048 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset)); |
| 1034 __ Push(rax); // Fixed array length (as smi). | 1049 __ Push(rax); // Fixed array length (as smi). |
| 1035 PrepareForBailoutForId(stmt->PrepareId(), NO_REGISTERS); | 1050 PrepareForBailoutForId(stmt->PrepareId(), |
| 1051 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1036 __ Push(Smi::FromInt(0)); // Initial index. | 1052 __ Push(Smi::FromInt(0)); // Initial index. |
| 1037 | 1053 |
| 1038 // Generate code for doing the condition check. | 1054 // Generate code for doing the condition check. |
| 1039 __ bind(&loop); | 1055 __ bind(&loop); |
| 1040 SetExpressionAsStatementPosition(stmt->each()); | 1056 SetExpressionAsStatementPosition(stmt->each()); |
| 1041 | 1057 |
| 1042 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index. | 1058 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index. |
| 1043 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length. | 1059 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length. |
| 1044 __ j(above_equal, loop_statement.break_label()); | 1060 __ j(above_equal, loop_statement.break_label()); |
| 1045 | 1061 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1067 __ EmitLoadTypeFeedbackVector(rdx); | 1083 __ EmitLoadTypeFeedbackVector(rdx); |
| 1068 __ Move(FieldOperand(rdx, FixedArray::OffsetOfElementAt(vector_index)), | 1084 __ Move(FieldOperand(rdx, FixedArray::OffsetOfElementAt(vector_index)), |
| 1069 TypeFeedbackVector::MegamorphicSentinel(isolate())); | 1085 TypeFeedbackVector::MegamorphicSentinel(isolate())); |
| 1070 | 1086 |
| 1071 // Convert the entry to a string or null if it isn't a property | 1087 // Convert the entry to a string or null if it isn't a property |
| 1072 // anymore. If the property has been removed while iterating, we | 1088 // anymore. If the property has been removed while iterating, we |
| 1073 // just skip it. | 1089 // just skip it. |
| 1074 __ Push(rcx); // Enumerable. | 1090 __ Push(rcx); // Enumerable. |
| 1075 __ Push(rbx); // Current entry. | 1091 __ Push(rbx); // Current entry. |
| 1076 __ CallRuntime(Runtime::kForInFilter); | 1092 __ CallRuntime(Runtime::kForInFilter); |
| 1077 PrepareForBailoutForId(stmt->FilterId(), TOS_REG); | 1093 PrepareForBailoutForId(stmt->FilterId(), |
| 1094 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1078 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 1095 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
| 1079 __ j(equal, loop_statement.continue_label()); | 1096 __ j(equal, loop_statement.continue_label()); |
| 1080 __ movp(rbx, rax); | 1097 __ movp(rbx, rax); |
| 1081 | 1098 |
| 1082 // Update the 'each' property or variable from the possibly filtered | 1099 // Update the 'each' property or variable from the possibly filtered |
| 1083 // entry in register rbx. | 1100 // entry in register rbx. |
| 1084 __ bind(&update_each); | 1101 __ bind(&update_each); |
| 1085 __ movp(result_register(), rbx); | 1102 __ movp(result_register(), rbx); |
| 1086 // Perform the assignment as if via '='. | 1103 // Perform the assignment as if via '='. |
| 1087 { EffectContext context(this); | 1104 { EffectContext context(this); |
| 1088 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1105 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
| 1089 PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS); | 1106 PrepareForBailoutForId(stmt->AssignmentId(), |
| 1107 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1090 } | 1108 } |
| 1091 | 1109 |
| 1092 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). | 1110 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). |
| 1093 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1111 PrepareForBailoutForId(stmt->BodyId(), |
| 1112 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1094 // Generate code for the body of the loop. | 1113 // Generate code for the body of the loop. |
| 1095 Visit(stmt->body()); | 1114 Visit(stmt->body()); |
| 1096 | 1115 |
| 1097 // Generate code for going to the next element by incrementing the | 1116 // Generate code for going to the next element by incrementing the |
| 1098 // index (smi) stored on top of the stack. | 1117 // index (smi) stored on top of the stack. |
| 1099 __ bind(loop_statement.continue_label()); | 1118 __ bind(loop_statement.continue_label()); |
| 1100 __ SmiAddConstant(Operand(rsp, 0 * kPointerSize), Smi::FromInt(1)); | 1119 __ SmiAddConstant(Operand(rsp, 0 * kPointerSize), Smi::FromInt(1)); |
| 1101 | 1120 |
| 1102 EmitBackEdgeBookkeeping(stmt, &loop); | 1121 EmitBackEdgeBookkeeping(stmt, &loop); |
| 1103 __ jmp(&loop); | 1122 __ jmp(&loop); |
| 1104 | 1123 |
| 1105 // Remove the pointers stored on the stack. | 1124 // Remove the pointers stored on the stack. |
| 1106 __ bind(loop_statement.break_label()); | 1125 __ bind(loop_statement.break_label()); |
| 1107 DropOperands(5); | 1126 DropOperands(5); |
| 1108 | 1127 |
| 1109 // Exit and decrement the loop depth. | 1128 // Exit and decrement the loop depth. |
| 1110 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1129 PrepareForBailoutForId(stmt->ExitId(), |
| 1130 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1111 __ bind(&exit); | 1131 __ bind(&exit); |
| 1112 decrement_loop_depth(); | 1132 decrement_loop_depth(); |
| 1113 } | 1133 } |
| 1114 | 1134 |
| 1115 | 1135 |
| 1116 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, | 1136 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, |
| 1117 FeedbackVectorSlot slot) { | 1137 FeedbackVectorSlot slot) { |
| 1118 DCHECK(NeedsHomeObject(initializer)); | 1138 DCHECK(NeedsHomeObject(initializer)); |
| 1119 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 1139 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
| 1120 __ Move(StoreDescriptor::NameRegister(), | 1140 __ Move(StoreDescriptor::NameRegister(), |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 __ Move(LoadDescriptor::SlotRegister(), | 1279 __ Move(LoadDescriptor::SlotRegister(), |
| 1260 SmiFromSlot(proxy->VariableFeedbackSlot())); | 1280 SmiFromSlot(proxy->VariableFeedbackSlot())); |
| 1261 CallLoadIC(typeof_mode); | 1281 CallLoadIC(typeof_mode); |
| 1262 } | 1282 } |
| 1263 | 1283 |
| 1264 | 1284 |
| 1265 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1285 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
| 1266 TypeofMode typeof_mode) { | 1286 TypeofMode typeof_mode) { |
| 1267 // Record position before possible IC call. | 1287 // Record position before possible IC call. |
| 1268 SetExpressionPosition(proxy); | 1288 SetExpressionPosition(proxy); |
| 1269 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1289 PrepareForBailoutForId(proxy->BeforeId(), |
| 1290 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1270 Variable* var = proxy->var(); | 1291 Variable* var = proxy->var(); |
| 1271 | 1292 |
| 1272 // Three cases: global variables, lookup variables, and all other types of | 1293 // Three cases: global variables, lookup variables, and all other types of |
| 1273 // variables. | 1294 // variables. |
| 1274 switch (var->location()) { | 1295 switch (var->location()) { |
| 1275 case VariableLocation::GLOBAL: | 1296 case VariableLocation::GLOBAL: |
| 1276 case VariableLocation::UNALLOCATED: { | 1297 case VariableLocation::UNALLOCATED: { |
| 1277 Comment cmnt(masm_, "[ Global variable"); | 1298 Comment cmnt(masm_, "[ Global variable"); |
| 1278 EmitGlobalVariableLoad(proxy, typeof_mode); | 1299 EmitGlobalVariableLoad(proxy, typeof_mode); |
| 1279 context()->Plug(rax); | 1300 context()->Plug(rax); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 __ CallRuntime(Runtime::kCreateObjectLiteral); | 1390 __ CallRuntime(Runtime::kCreateObjectLiteral); |
| 1370 } else { | 1391 } else { |
| 1371 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1392 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1372 __ Move(rbx, Smi::FromInt(expr->literal_index())); | 1393 __ Move(rbx, Smi::FromInt(expr->literal_index())); |
| 1373 __ Move(rcx, constant_properties); | 1394 __ Move(rcx, constant_properties); |
| 1374 __ Move(rdx, Smi::FromInt(flags)); | 1395 __ Move(rdx, Smi::FromInt(flags)); |
| 1375 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); | 1396 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
| 1376 __ CallStub(&stub); | 1397 __ CallStub(&stub); |
| 1377 RestoreContext(); | 1398 RestoreContext(); |
| 1378 } | 1399 } |
| 1379 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1400 PrepareForBailoutForId(expr->CreateLiteralId(), |
| 1401 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1380 | 1402 |
| 1381 // If result_saved is true the result is on top of the stack. If | 1403 // If result_saved is true the result is on top of the stack. If |
| 1382 // result_saved is false the result is in rax. | 1404 // result_saved is false the result is in rax. |
| 1383 bool result_saved = false; | 1405 bool result_saved = false; |
| 1384 | 1406 |
| 1385 AccessorTable accessor_table(zone()); | 1407 AccessorTable accessor_table(zone()); |
| 1386 int property_index = 0; | 1408 int property_index = 0; |
| 1387 for (; property_index < expr->properties()->length(); property_index++) { | 1409 for (; property_index < expr->properties()->length(); property_index++) { |
| 1388 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1410 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
| 1389 if (property->is_computed_name()) break; | 1411 if (property->is_computed_name()) break; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1405 // It is safe to use [[Put]] here because the boilerplate already | 1427 // It is safe to use [[Put]] here because the boilerplate already |
| 1406 // contains computed properties with an uninitialized value. | 1428 // contains computed properties with an uninitialized value. |
| 1407 if (key->value()->IsInternalizedString()) { | 1429 if (key->value()->IsInternalizedString()) { |
| 1408 if (property->emit_store()) { | 1430 if (property->emit_store()) { |
| 1409 VisitForAccumulatorValue(value); | 1431 VisitForAccumulatorValue(value); |
| 1410 DCHECK(StoreDescriptor::ValueRegister().is(rax)); | 1432 DCHECK(StoreDescriptor::ValueRegister().is(rax)); |
| 1411 __ Move(StoreDescriptor::NameRegister(), key->value()); | 1433 __ Move(StoreDescriptor::NameRegister(), key->value()); |
| 1412 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 1434 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
| 1413 EmitLoadStoreICSlot(property->GetSlot(0)); | 1435 EmitLoadStoreICSlot(property->GetSlot(0)); |
| 1414 CallStoreIC(); | 1436 CallStoreIC(); |
| 1415 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1437 PrepareForBailoutForId(key->id(), |
| 1438 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1416 | 1439 |
| 1417 if (NeedsHomeObject(value)) { | 1440 if (NeedsHomeObject(value)) { |
| 1418 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); | 1441 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); |
| 1419 } | 1442 } |
| 1420 } else { | 1443 } else { |
| 1421 VisitForEffect(value); | 1444 VisitForEffect(value); |
| 1422 } | 1445 } |
| 1423 break; | 1446 break; |
| 1424 } | 1447 } |
| 1425 PushOperand(Operand(rsp, 0)); // Duplicate receiver. | 1448 PushOperand(Operand(rsp, 0)); // Duplicate receiver. |
| 1426 VisitForStackValue(key); | 1449 VisitForStackValue(key); |
| 1427 VisitForStackValue(value); | 1450 VisitForStackValue(value); |
| 1428 if (property->emit_store()) { | 1451 if (property->emit_store()) { |
| 1429 if (NeedsHomeObject(value)) { | 1452 if (NeedsHomeObject(value)) { |
| 1430 EmitSetHomeObject(value, 2, property->GetSlot()); | 1453 EmitSetHomeObject(value, 2, property->GetSlot()); |
| 1431 } | 1454 } |
| 1432 PushOperand(Smi::FromInt(SLOPPY)); // Language mode | 1455 PushOperand(Smi::FromInt(SLOPPY)); // Language mode |
| 1433 CallRuntimeWithOperands(Runtime::kSetProperty); | 1456 CallRuntimeWithOperands(Runtime::kSetProperty); |
| 1434 } else { | 1457 } else { |
| 1435 DropOperands(3); | 1458 DropOperands(3); |
| 1436 } | 1459 } |
| 1437 break; | 1460 break; |
| 1438 case ObjectLiteral::Property::PROTOTYPE: | 1461 case ObjectLiteral::Property::PROTOTYPE: |
| 1439 PushOperand(Operand(rsp, 0)); // Duplicate receiver. | 1462 PushOperand(Operand(rsp, 0)); // Duplicate receiver. |
| 1440 VisitForStackValue(value); | 1463 VisitForStackValue(value); |
| 1441 DCHECK(property->emit_store()); | 1464 DCHECK(property->emit_store()); |
| 1442 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1465 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
| 1443 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1466 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
| 1444 NO_REGISTERS); | 1467 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1445 break; | 1468 break; |
| 1446 case ObjectLiteral::Property::GETTER: | 1469 case ObjectLiteral::Property::GETTER: |
| 1447 if (property->emit_store()) { | 1470 if (property->emit_store()) { |
| 1448 accessor_table.lookup(key)->second->getter = property; | 1471 accessor_table.lookup(key)->second->getter = property; |
| 1449 } | 1472 } |
| 1450 break; | 1473 break; |
| 1451 case ObjectLiteral::Property::SETTER: | 1474 case ObjectLiteral::Property::SETTER: |
| 1452 if (property->emit_store()) { | 1475 if (property->emit_store()) { |
| 1453 accessor_table.lookup(key)->second->setter = property; | 1476 accessor_table.lookup(key)->second->setter = property; |
| 1454 } | 1477 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 } | 1511 } |
| 1489 | 1512 |
| 1490 PushOperand(Operand(rsp, 0)); // Duplicate receiver. | 1513 PushOperand(Operand(rsp, 0)); // Duplicate receiver. |
| 1491 | 1514 |
| 1492 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { | 1515 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { |
| 1493 DCHECK(!property->is_computed_name()); | 1516 DCHECK(!property->is_computed_name()); |
| 1494 VisitForStackValue(value); | 1517 VisitForStackValue(value); |
| 1495 DCHECK(property->emit_store()); | 1518 DCHECK(property->emit_store()); |
| 1496 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1519 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
| 1497 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1520 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
| 1498 NO_REGISTERS); | 1521 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1499 } else { | 1522 } else { |
| 1500 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); | 1523 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); |
| 1501 VisitForStackValue(value); | 1524 VisitForStackValue(value); |
| 1502 if (NeedsHomeObject(value)) { | 1525 if (NeedsHomeObject(value)) { |
| 1503 EmitSetHomeObject(value, 2, property->GetSlot()); | 1526 EmitSetHomeObject(value, 2, property->GetSlot()); |
| 1504 } | 1527 } |
| 1505 | 1528 |
| 1506 switch (property->kind()) { | 1529 switch (property->kind()) { |
| 1507 case ObjectLiteral::Property::CONSTANT: | 1530 case ObjectLiteral::Property::CONSTANT: |
| 1508 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1531 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 __ Push(constant_elements); | 1584 __ Push(constant_elements); |
| 1562 __ Push(Smi::FromInt(expr->ComputeFlags())); | 1585 __ Push(Smi::FromInt(expr->ComputeFlags())); |
| 1563 __ CallRuntime(Runtime::kCreateArrayLiteral); | 1586 __ CallRuntime(Runtime::kCreateArrayLiteral); |
| 1564 } else { | 1587 } else { |
| 1565 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1588 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1566 __ Move(rbx, Smi::FromInt(expr->literal_index())); | 1589 __ Move(rbx, Smi::FromInt(expr->literal_index())); |
| 1567 __ Move(rcx, constant_elements); | 1590 __ Move(rcx, constant_elements); |
| 1568 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1591 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
| 1569 __ CallStub(&stub); | 1592 __ CallStub(&stub); |
| 1570 } | 1593 } |
| 1571 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1594 PrepareForBailoutForId(expr->CreateLiteralId(), |
| 1595 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1572 | 1596 |
| 1573 bool result_saved = false; // Is the result saved to the stack? | 1597 bool result_saved = false; // Is the result saved to the stack? |
| 1574 ZoneList<Expression*>* subexprs = expr->values(); | 1598 ZoneList<Expression*>* subexprs = expr->values(); |
| 1575 int length = subexprs->length(); | 1599 int length = subexprs->length(); |
| 1576 | 1600 |
| 1577 // Emit code to evaluate all the non-constant subexpressions and to store | 1601 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1578 // them into the newly cloned array. | 1602 // them into the newly cloned array. |
| 1579 int array_index = 0; | 1603 int array_index = 0; |
| 1580 for (; array_index < length; array_index++) { | 1604 for (; array_index < length; array_index++) { |
| 1581 Expression* subexpr = subexprs->at(array_index); | 1605 Expression* subexpr = subexprs->at(array_index); |
| 1582 DCHECK(!subexpr->IsSpread()); | 1606 DCHECK(!subexpr->IsSpread()); |
| 1583 | 1607 |
| 1584 // If the subexpression is a literal or a simple materialized literal it | 1608 // If the subexpression is a literal or a simple materialized literal it |
| 1585 // is already set in the cloned array. | 1609 // is already set in the cloned array. |
| 1586 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1610 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 1587 | 1611 |
| 1588 if (!result_saved) { | 1612 if (!result_saved) { |
| 1589 PushOperand(rax); // array literal | 1613 PushOperand(rax); // array literal |
| 1590 result_saved = true; | 1614 result_saved = true; |
| 1591 } | 1615 } |
| 1592 VisitForAccumulatorValue(subexpr); | 1616 VisitForAccumulatorValue(subexpr); |
| 1593 | 1617 |
| 1594 __ Move(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); | 1618 __ Move(StoreDescriptor::NameRegister(), Smi::FromInt(array_index)); |
| 1595 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 1619 __ movp(StoreDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
| 1596 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1620 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); |
| 1597 Handle<Code> ic = | 1621 Handle<Code> ic = |
| 1598 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 1622 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
| 1599 CallIC(ic); | 1623 CallIC(ic); |
| 1600 | 1624 |
| 1601 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1625 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1626 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1602 } | 1627 } |
| 1603 | 1628 |
| 1604 // In case the array literal contains spread expressions it has two parts. The | 1629 // In case the array literal contains spread expressions it has two parts. The |
| 1605 // first part is the "static" array which has a literal index is handled | 1630 // first part is the "static" array which has a literal index is handled |
| 1606 // above. The second part is the part after the first spread expression | 1631 // above. The second part is the part after the first spread expression |
| 1607 // (inclusive) and these elements gets appended to the array. Note that the | 1632 // (inclusive) and these elements gets appended to the array. Note that the |
| 1608 // number elements an iterable produces is unknown ahead of time. | 1633 // number elements an iterable produces is unknown ahead of time. |
| 1609 if (array_index < length && result_saved) { | 1634 if (array_index < length && result_saved) { |
| 1610 PopOperand(rax); | 1635 PopOperand(rax); |
| 1611 result_saved = false; | 1636 result_saved = false; |
| 1612 } | 1637 } |
| 1613 for (; array_index < length; array_index++) { | 1638 for (; array_index < length; array_index++) { |
| 1614 Expression* subexpr = subexprs->at(array_index); | 1639 Expression* subexpr = subexprs->at(array_index); |
| 1615 | 1640 |
| 1616 PushOperand(rax); | 1641 PushOperand(rax); |
| 1617 DCHECK(!subexpr->IsSpread()); | 1642 DCHECK(!subexpr->IsSpread()); |
| 1618 VisitForStackValue(subexpr); | 1643 VisitForStackValue(subexpr); |
| 1619 CallRuntimeWithOperands(Runtime::kAppendElement); | 1644 CallRuntimeWithOperands(Runtime::kAppendElement); |
| 1620 | 1645 |
| 1621 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1646 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1647 Deoptimizer::BailoutState::NO_REGISTERS); |
| 1622 } | 1648 } |
| 1623 | 1649 |
| 1624 if (result_saved) { | 1650 if (result_saved) { |
| 1625 context()->PlugTOS(); | 1651 context()->PlugTOS(); |
| 1626 } else { | 1652 } else { |
| 1627 context()->Plug(rax); | 1653 context()->Plug(rax); |
| 1628 } | 1654 } |
| 1629 } | 1655 } |
| 1630 | 1656 |
| 1631 | 1657 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 } | 1715 } |
| 1690 } | 1716 } |
| 1691 | 1717 |
| 1692 // For compound assignments we need another deoptimization point after the | 1718 // For compound assignments we need another deoptimization point after the |
| 1693 // variable/property load. | 1719 // variable/property load. |
| 1694 if (expr->is_compound()) { | 1720 if (expr->is_compound()) { |
| 1695 { AccumulatorValueContext context(this); | 1721 { AccumulatorValueContext context(this); |
| 1696 switch (assign_type) { | 1722 switch (assign_type) { |
| 1697 case VARIABLE: | 1723 case VARIABLE: |
| 1698 EmitVariableLoad(expr->target()->AsVariableProxy()); | 1724 EmitVariableLoad(expr->target()->AsVariableProxy()); |
| 1699 PrepareForBailout(expr->target(), TOS_REG); | 1725 PrepareForBailout(expr->target(), |
| 1726 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1700 break; | 1727 break; |
| 1701 case NAMED_PROPERTY: | 1728 case NAMED_PROPERTY: |
| 1702 EmitNamedPropertyLoad(property); | 1729 EmitNamedPropertyLoad(property); |
| 1703 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1730 PrepareForBailoutForId(property->LoadId(), |
| 1731 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1704 break; | 1732 break; |
| 1705 case NAMED_SUPER_PROPERTY: | 1733 case NAMED_SUPER_PROPERTY: |
| 1706 EmitNamedSuperPropertyLoad(property); | 1734 EmitNamedSuperPropertyLoad(property); |
| 1707 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1735 PrepareForBailoutForId(property->LoadId(), |
| 1736 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1708 break; | 1737 break; |
| 1709 case KEYED_SUPER_PROPERTY: | 1738 case KEYED_SUPER_PROPERTY: |
| 1710 EmitKeyedSuperPropertyLoad(property); | 1739 EmitKeyedSuperPropertyLoad(property); |
| 1711 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1740 PrepareForBailoutForId(property->LoadId(), |
| 1741 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1712 break; | 1742 break; |
| 1713 case KEYED_PROPERTY: | 1743 case KEYED_PROPERTY: |
| 1714 EmitKeyedPropertyLoad(property); | 1744 EmitKeyedPropertyLoad(property); |
| 1715 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1745 PrepareForBailoutForId(property->LoadId(), |
| 1746 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1716 break; | 1747 break; |
| 1717 } | 1748 } |
| 1718 } | 1749 } |
| 1719 | 1750 |
| 1720 Token::Value op = expr->binary_op(); | 1751 Token::Value op = expr->binary_op(); |
| 1721 PushOperand(rax); // Left operand goes on the stack. | 1752 PushOperand(rax); // Left operand goes on the stack. |
| 1722 VisitForAccumulatorValue(expr->value()); | 1753 VisitForAccumulatorValue(expr->value()); |
| 1723 | 1754 |
| 1724 AccumulatorValueContext context(this); | 1755 AccumulatorValueContext context(this); |
| 1725 if (ShouldInlineSmiCase(op)) { | 1756 if (ShouldInlineSmiCase(op)) { |
| 1726 EmitInlineSmiBinaryOp(expr->binary_operation(), | 1757 EmitInlineSmiBinaryOp(expr->binary_operation(), |
| 1727 op, | 1758 op, |
| 1728 expr->target(), | 1759 expr->target(), |
| 1729 expr->value()); | 1760 expr->value()); |
| 1730 } else { | 1761 } else { |
| 1731 EmitBinaryOp(expr->binary_operation(), op); | 1762 EmitBinaryOp(expr->binary_operation(), op); |
| 1732 } | 1763 } |
| 1733 // Deoptimization point in case the binary operation may have side effects. | 1764 // Deoptimization point in case the binary operation may have side effects. |
| 1734 PrepareForBailout(expr->binary_operation(), TOS_REG); | 1765 PrepareForBailout(expr->binary_operation(), |
| 1766 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1735 } else { | 1767 } else { |
| 1736 VisitForAccumulatorValue(expr->value()); | 1768 VisitForAccumulatorValue(expr->value()); |
| 1737 } | 1769 } |
| 1738 | 1770 |
| 1739 SetExpressionPosition(expr); | 1771 SetExpressionPosition(expr); |
| 1740 | 1772 |
| 1741 // Store the value. | 1773 // Store the value. |
| 1742 switch (assign_type) { | 1774 switch (assign_type) { |
| 1743 case VARIABLE: | 1775 case VARIABLE: |
| 1744 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 1776 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
| 1745 expr->op(), expr->AssignmentSlot()); | 1777 expr->op(), expr->AssignmentSlot()); |
| 1746 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 1778 PrepareForBailoutForId(expr->AssignmentId(), |
| 1779 Deoptimizer::BailoutState::TOS_REGISTER); |
| 1747 context()->Plug(rax); | 1780 context()->Plug(rax); |
| 1748 break; | 1781 break; |
| 1749 case NAMED_PROPERTY: | 1782 case NAMED_PROPERTY: |
| 1750 EmitNamedPropertyAssignment(expr); | 1783 EmitNamedPropertyAssignment(expr); |
| 1751 break; | 1784 break; |
| 1752 case NAMED_SUPER_PROPERTY: | 1785 case NAMED_SUPER_PROPERTY: |
| 1753 EmitNamedSuperPropertyStore(property); | 1786 EmitNamedSuperPropertyStore(property); |
| 1754 context()->Plug(rax); | 1787 context()->Plug(rax); |
| 1755 break; | 1788 break; |
| 1756 case KEYED_SUPER_PROPERTY: | 1789 case KEYED_SUPER_PROPERTY: |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 // Assignment to a property, using a named store IC. | 2192 // Assignment to a property, using a named store IC. |
| 2160 Property* prop = expr->target()->AsProperty(); | 2193 Property* prop = expr->target()->AsProperty(); |
| 2161 DCHECK(prop != NULL); | 2194 DCHECK(prop != NULL); |
| 2162 DCHECK(prop->key()->IsLiteral()); | 2195 DCHECK(prop->key()->IsLiteral()); |
| 2163 | 2196 |
| 2164 __ Move(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); | 2197 __ Move(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); |
| 2165 PopOperand(StoreDescriptor::ReceiverRegister()); | 2198 PopOperand(StoreDescriptor::ReceiverRegister()); |
| 2166 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2199 EmitLoadStoreICSlot(expr->AssignmentSlot()); |
| 2167 CallStoreIC(); | 2200 CallStoreIC(); |
| 2168 | 2201 |
| 2169 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2202 PrepareForBailoutForId(expr->AssignmentId(), |
| 2203 Deoptimizer::BailoutState::TOS_REGISTER); |
| 2170 context()->Plug(rax); | 2204 context()->Plug(rax); |
| 2171 } | 2205 } |
| 2172 | 2206 |
| 2173 | 2207 |
| 2174 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { | 2208 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { |
| 2175 // Assignment to named property of super. | 2209 // Assignment to named property of super. |
| 2176 // rax : value | 2210 // rax : value |
| 2177 // stack : receiver ('this'), home_object | 2211 // stack : receiver ('this'), home_object |
| 2178 DCHECK(prop != NULL); | 2212 DCHECK(prop != NULL); |
| 2179 Literal* key = prop->key()->AsLiteral(); | 2213 Literal* key = prop->key()->AsLiteral(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2203 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2237 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
| 2204 // Assignment to a property, using a keyed store IC. | 2238 // Assignment to a property, using a keyed store IC. |
| 2205 PopOperand(StoreDescriptor::NameRegister()); // Key. | 2239 PopOperand(StoreDescriptor::NameRegister()); // Key. |
| 2206 PopOperand(StoreDescriptor::ReceiverRegister()); | 2240 PopOperand(StoreDescriptor::ReceiverRegister()); |
| 2207 DCHECK(StoreDescriptor::ValueRegister().is(rax)); | 2241 DCHECK(StoreDescriptor::ValueRegister().is(rax)); |
| 2208 Handle<Code> ic = | 2242 Handle<Code> ic = |
| 2209 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 2243 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
| 2210 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2244 EmitLoadStoreICSlot(expr->AssignmentSlot()); |
| 2211 CallIC(ic); | 2245 CallIC(ic); |
| 2212 | 2246 |
| 2213 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2247 PrepareForBailoutForId(expr->AssignmentId(), |
| 2248 Deoptimizer::BailoutState::TOS_REGISTER); |
| 2214 context()->Plug(rax); | 2249 context()->Plug(rax); |
| 2215 } | 2250 } |
| 2216 | 2251 |
| 2217 | 2252 |
| 2218 void FullCodeGenerator::CallIC(Handle<Code> code, | 2253 void FullCodeGenerator::CallIC(Handle<Code> code, |
| 2219 TypeFeedbackId ast_id) { | 2254 TypeFeedbackId ast_id) { |
| 2220 ic_total_count_++; | 2255 ic_total_count_++; |
| 2221 __ call(code, RelocInfo::CODE_TARGET, ast_id); | 2256 __ call(code, RelocInfo::CODE_TARGET, ast_id); |
| 2222 } | 2257 } |
| 2223 | 2258 |
| 2224 | 2259 |
| 2225 // Code common for calls using the IC. | 2260 // Code common for calls using the IC. |
| 2226 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { | 2261 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
| 2227 Expression* callee = expr->expression(); | 2262 Expression* callee = expr->expression(); |
| 2228 | 2263 |
| 2229 // Get the target function. | 2264 // Get the target function. |
| 2230 ConvertReceiverMode convert_mode; | 2265 ConvertReceiverMode convert_mode; |
| 2231 if (callee->IsVariableProxy()) { | 2266 if (callee->IsVariableProxy()) { |
| 2232 { StackValueContext context(this); | 2267 { StackValueContext context(this); |
| 2233 EmitVariableLoad(callee->AsVariableProxy()); | 2268 EmitVariableLoad(callee->AsVariableProxy()); |
| 2234 PrepareForBailout(callee, NO_REGISTERS); | 2269 PrepareForBailout(callee, Deoptimizer::BailoutState::NO_REGISTERS); |
| 2235 } | 2270 } |
| 2236 // Push undefined as receiver. This is patched in the Call builtin if it | 2271 // Push undefined as receiver. This is patched in the Call builtin if it |
| 2237 // is a sloppy mode method. | 2272 // is a sloppy mode method. |
| 2238 PushOperand(isolate()->factory()->undefined_value()); | 2273 PushOperand(isolate()->factory()->undefined_value()); |
| 2239 convert_mode = ConvertReceiverMode::kNullOrUndefined; | 2274 convert_mode = ConvertReceiverMode::kNullOrUndefined; |
| 2240 } else { | 2275 } else { |
| 2241 // Load the function from the receiver. | 2276 // Load the function from the receiver. |
| 2242 DCHECK(callee->IsProperty()); | 2277 DCHECK(callee->IsProperty()); |
| 2243 DCHECK(!callee->AsProperty()->IsSuperAccess()); | 2278 DCHECK(!callee->AsProperty()->IsSuperAccess()); |
| 2244 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 2279 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
| 2245 EmitNamedPropertyLoad(callee->AsProperty()); | 2280 EmitNamedPropertyLoad(callee->AsProperty()); |
| 2246 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2281 PrepareForBailoutForId(callee->AsProperty()->LoadId(), |
| 2282 Deoptimizer::BailoutState::TOS_REGISTER); |
| 2247 // Push the target function under the receiver. | 2283 // Push the target function under the receiver. |
| 2248 PushOperand(Operand(rsp, 0)); | 2284 PushOperand(Operand(rsp, 0)); |
| 2249 __ movp(Operand(rsp, kPointerSize), rax); | 2285 __ movp(Operand(rsp, kPointerSize), rax); |
| 2250 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; | 2286 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; |
| 2251 } | 2287 } |
| 2252 | 2288 |
| 2253 EmitCall(expr, convert_mode); | 2289 EmitCall(expr, convert_mode); |
| 2254 } | 2290 } |
| 2255 | 2291 |
| 2256 | 2292 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2272 PushOperand(Operand(rsp, kPointerSize * 2)); | 2308 PushOperand(Operand(rsp, kPointerSize * 2)); |
| 2273 PushOperand(key->value()); | 2309 PushOperand(key->value()); |
| 2274 | 2310 |
| 2275 // Stack here: | 2311 // Stack here: |
| 2276 // - home_object | 2312 // - home_object |
| 2277 // - this (receiver) | 2313 // - this (receiver) |
| 2278 // - this (receiver) <-- LoadFromSuper will pop here and below. | 2314 // - this (receiver) <-- LoadFromSuper will pop here and below. |
| 2279 // - home_object | 2315 // - home_object |
| 2280 // - key | 2316 // - key |
| 2281 CallRuntimeWithOperands(Runtime::kLoadFromSuper); | 2317 CallRuntimeWithOperands(Runtime::kLoadFromSuper); |
| 2282 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 2318 PrepareForBailoutForId(prop->LoadId(), |
| 2319 Deoptimizer::BailoutState::TOS_REGISTER); |
| 2283 | 2320 |
| 2284 // Replace home_object with target function. | 2321 // Replace home_object with target function. |
| 2285 __ movp(Operand(rsp, kPointerSize), rax); | 2322 __ movp(Operand(rsp, kPointerSize), rax); |
| 2286 | 2323 |
| 2287 // Stack here: | 2324 // Stack here: |
| 2288 // - target function | 2325 // - target function |
| 2289 // - this (receiver) | 2326 // - this (receiver) |
| 2290 EmitCall(expr); | 2327 EmitCall(expr); |
| 2291 } | 2328 } |
| 2292 | 2329 |
| 2293 | 2330 |
| 2294 // Common code for calls using the IC. | 2331 // Common code for calls using the IC. |
| 2295 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, | 2332 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
| 2296 Expression* key) { | 2333 Expression* key) { |
| 2297 // Load the key. | 2334 // Load the key. |
| 2298 VisitForAccumulatorValue(key); | 2335 VisitForAccumulatorValue(key); |
| 2299 | 2336 |
| 2300 Expression* callee = expr->expression(); | 2337 Expression* callee = expr->expression(); |
| 2301 | 2338 |
| 2302 // Load the function from the receiver. | 2339 // Load the function from the receiver. |
| 2303 DCHECK(callee->IsProperty()); | 2340 DCHECK(callee->IsProperty()); |
| 2304 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 2341 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
| 2305 __ Move(LoadDescriptor::NameRegister(), rax); | 2342 __ Move(LoadDescriptor::NameRegister(), rax); |
| 2306 EmitKeyedPropertyLoad(callee->AsProperty()); | 2343 EmitKeyedPropertyLoad(callee->AsProperty()); |
| 2307 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2344 PrepareForBailoutForId(callee->AsProperty()->LoadId(), |
| 2345 Deoptimizer::BailoutState::TOS_REGISTER); |
| 2308 | 2346 |
| 2309 // Push the target function under the receiver. | 2347 // Push the target function under the receiver. |
| 2310 PushOperand(Operand(rsp, 0)); | 2348 PushOperand(Operand(rsp, 0)); |
| 2311 __ movp(Operand(rsp, kPointerSize), rax); | 2349 __ movp(Operand(rsp, kPointerSize), rax); |
| 2312 | 2350 |
| 2313 EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); | 2351 EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); |
| 2314 } | 2352 } |
| 2315 | 2353 |
| 2316 | 2354 |
| 2317 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 2355 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2330 PushOperand(Operand(rsp, kPointerSize * 2)); | 2368 PushOperand(Operand(rsp, kPointerSize * 2)); |
| 2331 VisitForStackValue(prop->key()); | 2369 VisitForStackValue(prop->key()); |
| 2332 | 2370 |
| 2333 // Stack here: | 2371 // Stack here: |
| 2334 // - home_object | 2372 // - home_object |
| 2335 // - this (receiver) | 2373 // - this (receiver) |
| 2336 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. | 2374 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
| 2337 // - home_object | 2375 // - home_object |
| 2338 // - key | 2376 // - key |
| 2339 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); | 2377 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); |
| 2340 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 2378 PrepareForBailoutForId(prop->LoadId(), |
| 2379 Deoptimizer::BailoutState::TOS_REGISTER); |
| 2341 | 2380 |
| 2342 // Replace home_object with target function. | 2381 // Replace home_object with target function. |
| 2343 __ movp(Operand(rsp, kPointerSize), rax); | 2382 __ movp(Operand(rsp, kPointerSize), rax); |
| 2344 | 2383 |
| 2345 // Stack here: | 2384 // Stack here: |
| 2346 // - target function | 2385 // - target function |
| 2347 // - this (receiver) | 2386 // - this (receiver) |
| 2348 EmitCall(expr); | 2387 EmitCall(expr); |
| 2349 } | 2388 } |
| 2350 | 2389 |
| 2351 | 2390 |
| 2352 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { | 2391 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
| 2353 // Load the arguments. | 2392 // Load the arguments. |
| 2354 ZoneList<Expression*>* args = expr->arguments(); | 2393 ZoneList<Expression*>* args = expr->arguments(); |
| 2355 int arg_count = args->length(); | 2394 int arg_count = args->length(); |
| 2356 for (int i = 0; i < arg_count; i++) { | 2395 for (int i = 0; i < arg_count; i++) { |
| 2357 VisitForStackValue(args->at(i)); | 2396 VisitForStackValue(args->at(i)); |
| 2358 } | 2397 } |
| 2359 | 2398 |
| 2360 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2399 PrepareForBailoutForId(expr->CallId(), |
| 2400 Deoptimizer::BailoutState::NO_REGISTERS); |
| 2361 SetCallPosition(expr, expr->tail_call_mode()); | 2401 SetCallPosition(expr, expr->tail_call_mode()); |
| 2362 if (expr->tail_call_mode() == TailCallMode::kAllow) { | 2402 if (expr->tail_call_mode() == TailCallMode::kAllow) { |
| 2363 if (FLAG_trace) { | 2403 if (FLAG_trace) { |
| 2364 __ CallRuntime(Runtime::kTraceTailCall); | 2404 __ CallRuntime(Runtime::kTraceTailCall); |
| 2365 } | 2405 } |
| 2366 // Update profiling counters before the tail call since we will | 2406 // Update profiling counters before the tail call since we will |
| 2367 // not return to this function. | 2407 // not return to this function. |
| 2368 EmitProfilingCounterHandlingForReturnSequence(true); | 2408 EmitProfilingCounterHandlingForReturnSequence(true); |
| 2369 } | 2409 } |
| 2370 Handle<Code> ic = | 2410 Handle<Code> ic = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 // Generate code for loading from variables potentially shadowed by | 2458 // Generate code for loading from variables potentially shadowed by |
| 2419 // eval-introduced variables. | 2459 // eval-introduced variables. |
| 2420 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); | 2460 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); |
| 2421 __ bind(&slow); | 2461 __ bind(&slow); |
| 2422 // Call the runtime to find the function to call (returned in rax) and | 2462 // Call the runtime to find the function to call (returned in rax) and |
| 2423 // the object holding it (returned in rdx). | 2463 // the object holding it (returned in rdx). |
| 2424 __ Push(callee->name()); | 2464 __ Push(callee->name()); |
| 2425 __ CallRuntime(Runtime::kLoadLookupSlotForCall); | 2465 __ CallRuntime(Runtime::kLoadLookupSlotForCall); |
| 2426 PushOperand(rax); // Function. | 2466 PushOperand(rax); // Function. |
| 2427 PushOperand(rdx); // Receiver. | 2467 PushOperand(rdx); // Receiver. |
| 2428 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); | 2468 PrepareForBailoutForId(expr->LookupId(), |
| 2469 Deoptimizer::BailoutState::NO_REGISTERS); |
| 2429 | 2470 |
| 2430 // If fast case code has been generated, emit code to push the function | 2471 // If fast case code has been generated, emit code to push the function |
| 2431 // and receiver and have the slow path jump around this code. | 2472 // and receiver and have the slow path jump around this code. |
| 2432 if (done.is_linked()) { | 2473 if (done.is_linked()) { |
| 2433 Label call; | 2474 Label call; |
| 2434 __ jmp(&call, Label::kNear); | 2475 __ jmp(&call, Label::kNear); |
| 2435 __ bind(&done); | 2476 __ bind(&done); |
| 2436 // Push function. | 2477 // Push function. |
| 2437 __ Push(rax); | 2478 __ Push(rax); |
| 2438 // Pass undefined as the receiver, which is the WithBaseObject of a | 2479 // Pass undefined as the receiver, which is the WithBaseObject of a |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2464 } | 2505 } |
| 2465 | 2506 |
| 2466 // Push a copy of the function (found below the arguments) and resolve | 2507 // Push a copy of the function (found below the arguments) and resolve |
| 2467 // eval. | 2508 // eval. |
| 2468 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); | 2509 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2469 EmitResolvePossiblyDirectEval(expr); | 2510 EmitResolvePossiblyDirectEval(expr); |
| 2470 | 2511 |
| 2471 // Touch up the callee. | 2512 // Touch up the callee. |
| 2472 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); | 2513 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); |
| 2473 | 2514 |
| 2474 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2515 PrepareForBailoutForId(expr->EvalId(), |
| 2516 Deoptimizer::BailoutState::NO_REGISTERS); |
| 2475 | 2517 |
| 2476 SetCallPosition(expr); | 2518 SetCallPosition(expr); |
| 2477 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2519 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2478 __ Set(rax, arg_count); | 2520 __ Set(rax, arg_count); |
| 2479 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2521 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
| 2480 expr->tail_call_mode()), | 2522 expr->tail_call_mode()), |
| 2481 RelocInfo::CODE_TARGET); | 2523 RelocInfo::CODE_TARGET); |
| 2482 OperandStackDepthDecrement(arg_count + 1); | 2524 OperandStackDepthDecrement(arg_count + 1); |
| 2483 RecordJSReturnSite(expr); | 2525 RecordJSReturnSite(expr); |
| 2484 RestoreContext(); | 2526 RestoreContext(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2513 __ Set(rax, arg_count); | 2555 __ Set(rax, arg_count); |
| 2514 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 2556 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 2515 | 2557 |
| 2516 // Record call targets in unoptimized code, but not in the snapshot. | 2558 // Record call targets in unoptimized code, but not in the snapshot. |
| 2517 __ EmitLoadTypeFeedbackVector(rbx); | 2559 __ EmitLoadTypeFeedbackVector(rbx); |
| 2518 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); | 2560 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); |
| 2519 | 2561 |
| 2520 CallConstructStub stub(isolate()); | 2562 CallConstructStub stub(isolate()); |
| 2521 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); | 2563 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 2522 OperandStackDepthDecrement(arg_count + 1); | 2564 OperandStackDepthDecrement(arg_count + 1); |
| 2523 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2565 PrepareForBailoutForId(expr->ReturnId(), |
| 2566 Deoptimizer::BailoutState::TOS_REGISTER); |
| 2524 RestoreContext(); | 2567 RestoreContext(); |
| 2525 context()->Plug(rax); | 2568 context()->Plug(rax); |
| 2526 } | 2569 } |
| 2527 | 2570 |
| 2528 | 2571 |
| 2529 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 2572 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 2530 SuperCallReference* super_call_ref = | 2573 SuperCallReference* super_call_ref = |
| 2531 expr->expression()->AsSuperCallReference(); | 2574 expr->expression()->AsSuperCallReference(); |
| 2532 DCHECK_NOT_NULL(super_call_ref); | 2575 DCHECK_NOT_NULL(super_call_ref); |
| 2533 | 2576 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2946 } | 2989 } |
| 2947 | 2990 |
| 2948 | 2991 |
| 2949 void FullCodeGenerator::EmitCall(CallRuntime* expr) { | 2992 void FullCodeGenerator::EmitCall(CallRuntime* expr) { |
| 2950 ZoneList<Expression*>* args = expr->arguments(); | 2993 ZoneList<Expression*>* args = expr->arguments(); |
| 2951 DCHECK_LE(2, args->length()); | 2994 DCHECK_LE(2, args->length()); |
| 2952 // Push target, receiver and arguments onto the stack. | 2995 // Push target, receiver and arguments onto the stack. |
| 2953 for (Expression* const arg : *args) { | 2996 for (Expression* const arg : *args) { |
| 2954 VisitForStackValue(arg); | 2997 VisitForStackValue(arg); |
| 2955 } | 2998 } |
| 2956 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2999 PrepareForBailoutForId(expr->CallId(), |
| 3000 Deoptimizer::BailoutState::NO_REGISTERS); |
| 2957 // Move target to rdi. | 3001 // Move target to rdi. |
| 2958 int const argc = args->length() - 2; | 3002 int const argc = args->length() - 2; |
| 2959 __ movp(rdi, Operand(rsp, (argc + 1) * kPointerSize)); | 3003 __ movp(rdi, Operand(rsp, (argc + 1) * kPointerSize)); |
| 2960 // Call the target. | 3004 // Call the target. |
| 2961 __ Set(rax, argc); | 3005 __ Set(rax, argc); |
| 2962 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 3006 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 2963 OperandStackDepthDecrement(argc + 1); | 3007 OperandStackDepthDecrement(argc + 1); |
| 2964 RestoreContext(); | 3008 RestoreContext(); |
| 2965 // Discard the function left on TOS. | 3009 // Discard the function left on TOS. |
| 2966 context()->DropAndPlug(1, rax); | 3010 context()->DropAndPlug(1, rax); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3159 // because we need to prepare a pair of extra administrative AST ids | 3203 // because we need to prepare a pair of extra administrative AST ids |
| 3160 // for the optimizing compiler. | 3204 // for the optimizing compiler. |
| 3161 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); | 3205 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); |
| 3162 Label materialize_true, materialize_false, done; | 3206 Label materialize_true, materialize_false, done; |
| 3163 VisitForControl(expr->expression(), | 3207 VisitForControl(expr->expression(), |
| 3164 &materialize_false, | 3208 &materialize_false, |
| 3165 &materialize_true, | 3209 &materialize_true, |
| 3166 &materialize_true); | 3210 &materialize_true); |
| 3167 if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1); | 3211 if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1); |
| 3168 __ bind(&materialize_true); | 3212 __ bind(&materialize_true); |
| 3169 PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS); | 3213 PrepareForBailoutForId(expr->MaterializeTrueId(), |
| 3214 Deoptimizer::BailoutState::NO_REGISTERS); |
| 3170 if (context()->IsAccumulatorValue()) { | 3215 if (context()->IsAccumulatorValue()) { |
| 3171 __ LoadRoot(rax, Heap::kTrueValueRootIndex); | 3216 __ LoadRoot(rax, Heap::kTrueValueRootIndex); |
| 3172 } else { | 3217 } else { |
| 3173 __ PushRoot(Heap::kTrueValueRootIndex); | 3218 __ PushRoot(Heap::kTrueValueRootIndex); |
| 3174 } | 3219 } |
| 3175 __ jmp(&done, Label::kNear); | 3220 __ jmp(&done, Label::kNear); |
| 3176 __ bind(&materialize_false); | 3221 __ bind(&materialize_false); |
| 3177 PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS); | 3222 PrepareForBailoutForId(expr->MaterializeFalseId(), |
| 3223 Deoptimizer::BailoutState::NO_REGISTERS); |
| 3178 if (context()->IsAccumulatorValue()) { | 3224 if (context()->IsAccumulatorValue()) { |
| 3179 __ LoadRoot(rax, Heap::kFalseValueRootIndex); | 3225 __ LoadRoot(rax, Heap::kFalseValueRootIndex); |
| 3180 } else { | 3226 } else { |
| 3181 __ PushRoot(Heap::kFalseValueRootIndex); | 3227 __ PushRoot(Heap::kFalseValueRootIndex); |
| 3182 } | 3228 } |
| 3183 __ bind(&done); | 3229 __ bind(&done); |
| 3184 } | 3230 } |
| 3185 break; | 3231 break; |
| 3186 } | 3232 } |
| 3187 | 3233 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3266 } | 3312 } |
| 3267 | 3313 |
| 3268 case VARIABLE: | 3314 case VARIABLE: |
| 3269 UNREACHABLE(); | 3315 UNREACHABLE(); |
| 3270 } | 3316 } |
| 3271 } | 3317 } |
| 3272 | 3318 |
| 3273 // We need a second deoptimization point after loading the value | 3319 // We need a second deoptimization point after loading the value |
| 3274 // in case evaluating the property load my have a side effect. | 3320 // in case evaluating the property load my have a side effect. |
| 3275 if (assign_type == VARIABLE) { | 3321 if (assign_type == VARIABLE) { |
| 3276 PrepareForBailout(expr->expression(), TOS_REG); | 3322 PrepareForBailout(expr->expression(), |
| 3323 Deoptimizer::BailoutState::TOS_REGISTER); |
| 3277 } else { | 3324 } else { |
| 3278 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 3325 PrepareForBailoutForId(prop->LoadId(), |
| 3326 Deoptimizer::BailoutState::TOS_REGISTER); |
| 3279 } | 3327 } |
| 3280 | 3328 |
| 3281 // Inline smi case if we are in a loop. | 3329 // Inline smi case if we are in a loop. |
| 3282 Label done, stub_call; | 3330 Label done, stub_call; |
| 3283 JumpPatchSite patch_site(masm_); | 3331 JumpPatchSite patch_site(masm_); |
| 3284 if (ShouldInlineSmiCase(expr->op())) { | 3332 if (ShouldInlineSmiCase(expr->op())) { |
| 3285 Label slow; | 3333 Label slow; |
| 3286 patch_site.EmitJumpIfNotSmi(rax, &slow, Label::kNear); | 3334 patch_site.EmitJumpIfNotSmi(rax, &slow, Label::kNear); |
| 3287 | 3335 |
| 3288 // Save result for postfix expressions. | 3336 // Save result for postfix expressions. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3321 __ SmiSubConstant(rax, rax, Smi::FromInt(1), constraints, &done, | 3369 __ SmiSubConstant(rax, rax, Smi::FromInt(1), constraints, &done, |
| 3322 Label::kNear); | 3370 Label::kNear); |
| 3323 } | 3371 } |
| 3324 __ jmp(&stub_call, Label::kNear); | 3372 __ jmp(&stub_call, Label::kNear); |
| 3325 __ bind(&slow); | 3373 __ bind(&slow); |
| 3326 } | 3374 } |
| 3327 | 3375 |
| 3328 // Convert old value into a number. | 3376 // Convert old value into a number. |
| 3329 ToNumberStub convert_stub(isolate()); | 3377 ToNumberStub convert_stub(isolate()); |
| 3330 __ CallStub(&convert_stub); | 3378 __ CallStub(&convert_stub); |
| 3331 PrepareForBailoutForId(expr->ToNumberId(), TOS_REG); | 3379 PrepareForBailoutForId(expr->ToNumberId(), |
| 3380 Deoptimizer::BailoutState::TOS_REGISTER); |
| 3332 | 3381 |
| 3333 // Save result for postfix expressions. | 3382 // Save result for postfix expressions. |
| 3334 if (expr->is_postfix()) { | 3383 if (expr->is_postfix()) { |
| 3335 if (!context()->IsEffect()) { | 3384 if (!context()->IsEffect()) { |
| 3336 // Save the result on the stack. If we have a named or keyed property | 3385 // Save the result on the stack. If we have a named or keyed property |
| 3337 // we store the result under the receiver that is currently on top | 3386 // we store the result under the receiver that is currently on top |
| 3338 // of the stack. | 3387 // of the stack. |
| 3339 switch (assign_type) { | 3388 switch (assign_type) { |
| 3340 case VARIABLE: | 3389 case VARIABLE: |
| 3341 PushOperand(rax); | 3390 PushOperand(rax); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3369 __ bind(&done); | 3418 __ bind(&done); |
| 3370 | 3419 |
| 3371 // Store the value returned in rax. | 3420 // Store the value returned in rax. |
| 3372 switch (assign_type) { | 3421 switch (assign_type) { |
| 3373 case VARIABLE: | 3422 case VARIABLE: |
| 3374 if (expr->is_postfix()) { | 3423 if (expr->is_postfix()) { |
| 3375 // Perform the assignment as if via '='. | 3424 // Perform the assignment as if via '='. |
| 3376 { EffectContext context(this); | 3425 { EffectContext context(this); |
| 3377 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3426 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
| 3378 Token::ASSIGN, expr->CountSlot()); | 3427 Token::ASSIGN, expr->CountSlot()); |
| 3379 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3428 PrepareForBailoutForId(expr->AssignmentId(), |
| 3429 Deoptimizer::BailoutState::TOS_REGISTER); |
| 3380 context.Plug(rax); | 3430 context.Plug(rax); |
| 3381 } | 3431 } |
| 3382 // For all contexts except kEffect: We have the result on | 3432 // For all contexts except kEffect: We have the result on |
| 3383 // top of the stack. | 3433 // top of the stack. |
| 3384 if (!context()->IsEffect()) { | 3434 if (!context()->IsEffect()) { |
| 3385 context()->PlugTOS(); | 3435 context()->PlugTOS(); |
| 3386 } | 3436 } |
| 3387 } else { | 3437 } else { |
| 3388 // Perform the assignment as if via '='. | 3438 // Perform the assignment as if via '='. |
| 3389 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3439 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
| 3390 Token::ASSIGN, expr->CountSlot()); | 3440 Token::ASSIGN, expr->CountSlot()); |
| 3391 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3441 PrepareForBailoutForId(expr->AssignmentId(), |
| 3442 Deoptimizer::BailoutState::TOS_REGISTER); |
| 3392 context()->Plug(rax); | 3443 context()->Plug(rax); |
| 3393 } | 3444 } |
| 3394 break; | 3445 break; |
| 3395 case NAMED_PROPERTY: { | 3446 case NAMED_PROPERTY: { |
| 3396 __ Move(StoreDescriptor::NameRegister(), | 3447 __ Move(StoreDescriptor::NameRegister(), |
| 3397 prop->key()->AsLiteral()->value()); | 3448 prop->key()->AsLiteral()->value()); |
| 3398 PopOperand(StoreDescriptor::ReceiverRegister()); | 3449 PopOperand(StoreDescriptor::ReceiverRegister()); |
| 3399 EmitLoadStoreICSlot(expr->CountSlot()); | 3450 EmitLoadStoreICSlot(expr->CountSlot()); |
| 3400 CallStoreIC(); | 3451 CallStoreIC(); |
| 3401 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3452 PrepareForBailoutForId(expr->AssignmentId(), |
| 3453 Deoptimizer::BailoutState::TOS_REGISTER); |
| 3402 if (expr->is_postfix()) { | 3454 if (expr->is_postfix()) { |
| 3403 if (!context()->IsEffect()) { | 3455 if (!context()->IsEffect()) { |
| 3404 context()->PlugTOS(); | 3456 context()->PlugTOS(); |
| 3405 } | 3457 } |
| 3406 } else { | 3458 } else { |
| 3407 context()->Plug(rax); | 3459 context()->Plug(rax); |
| 3408 } | 3460 } |
| 3409 break; | 3461 break; |
| 3410 } | 3462 } |
| 3411 case NAMED_SUPER_PROPERTY: { | 3463 case NAMED_SUPER_PROPERTY: { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3430 } | 3482 } |
| 3431 break; | 3483 break; |
| 3432 } | 3484 } |
| 3433 case KEYED_PROPERTY: { | 3485 case KEYED_PROPERTY: { |
| 3434 PopOperand(StoreDescriptor::NameRegister()); | 3486 PopOperand(StoreDescriptor::NameRegister()); |
| 3435 PopOperand(StoreDescriptor::ReceiverRegister()); | 3487 PopOperand(StoreDescriptor::ReceiverRegister()); |
| 3436 Handle<Code> ic = | 3488 Handle<Code> ic = |
| 3437 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 3489 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
| 3438 EmitLoadStoreICSlot(expr->CountSlot()); | 3490 EmitLoadStoreICSlot(expr->CountSlot()); |
| 3439 CallIC(ic); | 3491 CallIC(ic); |
| 3440 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3492 PrepareForBailoutForId(expr->AssignmentId(), |
| 3493 Deoptimizer::BailoutState::TOS_REGISTER); |
| 3441 if (expr->is_postfix()) { | 3494 if (expr->is_postfix()) { |
| 3442 if (!context()->IsEffect()) { | 3495 if (!context()->IsEffect()) { |
| 3443 context()->PlugTOS(); | 3496 context()->PlugTOS(); |
| 3444 } | 3497 } |
| 3445 } else { | 3498 } else { |
| 3446 context()->Plug(rax); | 3499 context()->Plug(rax); |
| 3447 } | 3500 } |
| 3448 break; | 3501 break; |
| 3449 } | 3502 } |
| 3450 } | 3503 } |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3811 DCHECK_EQ( | 3864 DCHECK_EQ( |
| 3812 isolate->builtins()->OnStackReplacement()->entry(), | 3865 isolate->builtins()->OnStackReplacement()->entry(), |
| 3813 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3866 Assembler::target_address_at(call_target_address, unoptimized_code)); |
| 3814 return ON_STACK_REPLACEMENT; | 3867 return ON_STACK_REPLACEMENT; |
| 3815 } | 3868 } |
| 3816 | 3869 |
| 3817 } // namespace internal | 3870 } // namespace internal |
| 3818 } // namespace v8 | 3871 } // namespace v8 |
| 3819 | 3872 |
| 3820 #endif // V8_TARGET_ARCH_X64 | 3873 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |