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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
8 // | 8 // |
9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // Possibly allocate a local context. | 178 // Possibly allocate a local context. |
179 if (info->scope()->num_heap_slots() > 0) { | 179 if (info->scope()->num_heap_slots() > 0) { |
180 Comment cmnt(masm_, "[ Allocate context"); | 180 Comment cmnt(masm_, "[ Allocate context"); |
181 // Argument to NewContext is the function, which is still in a1. | 181 // Argument to NewContext is the function, which is still in a1. |
182 bool need_write_barrier = true; | 182 bool need_write_barrier = true; |
183 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 183 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
184 if (info->scope()->is_script_scope()) { | 184 if (info->scope()->is_script_scope()) { |
185 __ push(a1); | 185 __ push(a1); |
186 __ Push(info->scope()->GetScopeInfo(info->isolate())); | 186 __ Push(info->scope()->GetScopeInfo(info->isolate())); |
187 __ CallRuntime(Runtime::kNewScriptContext); | 187 __ CallRuntime(Runtime::kNewScriptContext); |
188 PrepareForBailoutForId(BailoutId::ScriptContext(), TOS_REG); | 188 PrepareForBailoutForId(BailoutId::ScriptContext(), |
| 189 BailoutState::TOS_REGISTER); |
189 // The new target value is not used, clobbering is safe. | 190 // The new target value is not used, clobbering is safe. |
190 DCHECK_NULL(info->scope()->new_target_var()); | 191 DCHECK_NULL(info->scope()->new_target_var()); |
191 } else { | 192 } else { |
192 if (info->scope()->new_target_var() != nullptr) { | 193 if (info->scope()->new_target_var() != nullptr) { |
193 __ push(a3); // Preserve new target. | 194 __ push(a3); // Preserve new target. |
194 } | 195 } |
195 if (slots <= FastNewContextStub::kMaximumSlots) { | 196 if (slots <= FastNewContextStub::kMaximumSlots) { |
196 FastNewContextStub stub(isolate(), slots); | 197 FastNewContextStub stub(isolate(), slots); |
197 __ CallStub(&stub); | 198 __ CallStub(&stub); |
198 // Result of FastNewContextStub is always in new space. | 199 // Result of FastNewContextStub is always in new space. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 __ Abort(kExpectedNewSpaceObject); | 235 __ Abort(kExpectedNewSpaceObject); |
235 __ bind(&done); | 236 __ bind(&done); |
236 } | 237 } |
237 } | 238 } |
238 } | 239 } |
239 } | 240 } |
240 | 241 |
241 // Register holding this function and new target are both trashed in case we | 242 // Register holding this function and new target are both trashed in case we |
242 // bailout here. But since that can happen only when new target is not used | 243 // bailout here. But since that can happen only when new target is not used |
243 // and we allocate a context, the value of |function_in_register| is correct. | 244 // and we allocate a context, the value of |function_in_register| is correct. |
244 PrepareForBailoutForId(BailoutId::FunctionContext(), NO_REGISTERS); | 245 PrepareForBailoutForId(BailoutId::FunctionContext(), |
| 246 BailoutState::NO_REGISTERS); |
245 | 247 |
246 // Possibly set up a local binding to the this function which is used in | 248 // Possibly set up a local binding to the this function which is used in |
247 // derived constructors with super calls. | 249 // derived constructors with super calls. |
248 Variable* this_function_var = scope()->this_function_var(); | 250 Variable* this_function_var = scope()->this_function_var(); |
249 if (this_function_var != nullptr) { | 251 if (this_function_var != nullptr) { |
250 Comment cmnt(masm_, "[ This function"); | 252 Comment cmnt(masm_, "[ This function"); |
251 if (!function_in_register_a1) { | 253 if (!function_in_register_a1) { |
252 __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 254 __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
253 // The write barrier clobbers register again, keep it marked as such. | 255 // The write barrier clobbers register again, keep it marked as such. |
254 } | 256 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 297 } |
296 | 298 |
297 SetVar(arguments, v0, a1, a2); | 299 SetVar(arguments, v0, a1, a2); |
298 } | 300 } |
299 | 301 |
300 if (FLAG_trace) { | 302 if (FLAG_trace) { |
301 __ CallRuntime(Runtime::kTraceEnter); | 303 __ CallRuntime(Runtime::kTraceEnter); |
302 } | 304 } |
303 | 305 |
304 // Visit the declarations and body. | 306 // Visit the declarations and body. |
305 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); | 307 PrepareForBailoutForId(BailoutId::FunctionEntry(), |
| 308 BailoutState::NO_REGISTERS); |
306 { | 309 { |
307 Comment cmnt(masm_, "[ Declarations"); | 310 Comment cmnt(masm_, "[ Declarations"); |
308 VisitDeclarations(scope()->declarations()); | 311 VisitDeclarations(scope()->declarations()); |
309 } | 312 } |
310 | 313 |
311 // Assert that the declarations do not use ICs. Otherwise the debugger | 314 // Assert that the declarations do not use ICs. Otherwise the debugger |
312 // won't be able to redirect a PC at an IC to the correct IC in newly | 315 // won't be able to redirect a PC at an IC to the correct IC in newly |
313 // recompiled code. | 316 // recompiled code. |
314 DCHECK_EQ(0, ic_total_count_); | 317 DCHECK_EQ(0, ic_total_count_); |
315 | 318 |
316 { | 319 { |
317 Comment cmnt(masm_, "[ Stack check"); | 320 Comment cmnt(masm_, "[ Stack check"); |
318 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); | 321 PrepareForBailoutForId(BailoutId::Declarations(), |
| 322 BailoutState::NO_REGISTERS); |
319 Label ok; | 323 Label ok; |
320 __ LoadRoot(at, Heap::kStackLimitRootIndex); | 324 __ LoadRoot(at, Heap::kStackLimitRootIndex); |
321 __ Branch(&ok, hs, sp, Operand(at)); | 325 __ Branch(&ok, hs, sp, Operand(at)); |
322 Handle<Code> stack_check = isolate()->builtins()->StackCheck(); | 326 Handle<Code> stack_check = isolate()->builtins()->StackCheck(); |
323 PredictableCodeSizeScope predictable( | 327 PredictableCodeSizeScope predictable( |
324 masm_, masm_->CallSize(stack_check, RelocInfo::CODE_TARGET)); | 328 masm_, masm_->CallSize(stack_check, RelocInfo::CODE_TARGET)); |
325 __ Call(stack_check, RelocInfo::CODE_TARGET); | 329 __ Call(stack_check, RelocInfo::CODE_TARGET); |
326 __ bind(&ok); | 330 __ bind(&ok); |
327 } | 331 } |
328 | 332 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 __ beq(at, zero_reg, &ok); | 393 __ beq(at, zero_reg, &ok); |
390 // Call will emit a li t9 first, so it is safe to use the delay slot. | 394 // Call will emit a li t9 first, so it is safe to use the delay slot. |
391 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); | 395 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
392 // Record a mapping of this PC offset to the OSR id. This is used to find | 396 // Record a mapping of this PC offset to the OSR id. This is used to find |
393 // the AST id from the unoptimized code in order to use it as a key into | 397 // the AST id from the unoptimized code in order to use it as a key into |
394 // the deoptimization input data found in the optimized code. | 398 // the deoptimization input data found in the optimized code. |
395 RecordBackEdge(stmt->OsrEntryId()); | 399 RecordBackEdge(stmt->OsrEntryId()); |
396 EmitProfilingCounterReset(); | 400 EmitProfilingCounterReset(); |
397 | 401 |
398 __ bind(&ok); | 402 __ bind(&ok); |
399 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 403 PrepareForBailoutForId(stmt->EntryId(), BailoutState::NO_REGISTERS); |
400 // Record a mapping of the OSR id to this PC. This is used if the OSR | 404 // Record a mapping of the OSR id to this PC. This is used if the OSR |
401 // entry becomes the target of a bailout. We don't expect it to be, but | 405 // entry becomes the target of a bailout. We don't expect it to be, but |
402 // we want it to work if it is. | 406 // we want it to work if it is. |
403 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); | 407 PrepareForBailoutForId(stmt->OsrEntryId(), BailoutState::NO_REGISTERS); |
404 } | 408 } |
405 | 409 |
406 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( | 410 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( |
407 bool is_tail_call) { | 411 bool is_tail_call) { |
408 // Pretend that the exit is a backwards jump to the entry. | 412 // Pretend that the exit is a backwards jump to the entry. |
409 int weight = 1; | 413 int weight = 1; |
410 if (info_->ShouldSelfOptimize()) { | 414 if (info_->ShouldSelfOptimize()) { |
411 weight = FLAG_interrupt_budget / FLAG_self_opt_count; | 415 weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
412 } else { | 416 } else { |
413 int distance = masm_->pc_offset(); | 417 int distance = masm_->pc_offset(); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 bool should_normalize, | 723 bool should_normalize, |
720 Label* if_true, | 724 Label* if_true, |
721 Label* if_false) { | 725 Label* if_false) { |
722 // Only prepare for bailouts before splits if we're in a test | 726 // Only prepare for bailouts before splits if we're in a test |
723 // context. Otherwise, we let the Visit function deal with the | 727 // context. Otherwise, we let the Visit function deal with the |
724 // preparation to avoid preparing with the same AST id twice. | 728 // preparation to avoid preparing with the same AST id twice. |
725 if (!context()->IsTest()) return; | 729 if (!context()->IsTest()) return; |
726 | 730 |
727 Label skip; | 731 Label skip; |
728 if (should_normalize) __ Branch(&skip); | 732 if (should_normalize) __ Branch(&skip); |
729 PrepareForBailout(expr, TOS_REG); | 733 PrepareForBailout(expr, BailoutState::TOS_REGISTER); |
730 if (should_normalize) { | 734 if (should_normalize) { |
731 __ LoadRoot(a4, Heap::kTrueValueRootIndex); | 735 __ LoadRoot(a4, Heap::kTrueValueRootIndex); |
732 Split(eq, a0, Operand(a4), if_true, if_false, NULL); | 736 Split(eq, a0, Operand(a4), if_true, if_false, NULL); |
733 __ bind(&skip); | 737 __ bind(&skip); |
734 } | 738 } |
735 } | 739 } |
736 | 740 |
737 | 741 |
738 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { | 742 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
739 // The variable in the declaration always resides in the current function | 743 // The variable in the declaration always resides in the current function |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 } | 782 } |
779 break; | 783 break; |
780 | 784 |
781 case VariableLocation::CONTEXT: | 785 case VariableLocation::CONTEXT: |
782 if (hole_init) { | 786 if (hole_init) { |
783 Comment cmnt(masm_, "[ VariableDeclaration"); | 787 Comment cmnt(masm_, "[ VariableDeclaration"); |
784 EmitDebugCheckDeclarationContext(variable); | 788 EmitDebugCheckDeclarationContext(variable); |
785 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 789 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
786 __ sd(at, ContextMemOperand(cp, variable->index())); | 790 __ sd(at, ContextMemOperand(cp, variable->index())); |
787 // No write barrier since the_hole_value is in old space. | 791 // No write barrier since the_hole_value is in old space. |
788 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 792 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
789 } | 793 } |
790 break; | 794 break; |
791 | 795 |
792 case VariableLocation::LOOKUP: { | 796 case VariableLocation::LOOKUP: { |
793 Comment cmnt(masm_, "[ VariableDeclaration"); | 797 Comment cmnt(masm_, "[ VariableDeclaration"); |
794 __ li(a2, Operand(variable->name())); | 798 __ li(a2, Operand(variable->name())); |
795 // Declaration nodes are always introduced in one of four modes. | 799 // Declaration nodes are always introduced in one of four modes. |
796 DCHECK(IsDeclaredVariableMode(mode)); | 800 DCHECK(IsDeclaredVariableMode(mode)); |
797 // Push initial value, if any. | 801 // Push initial value, if any. |
798 // Note: For variables we must not push an initial value (such as | 802 // Note: For variables we must not push an initial value (such as |
799 // 'undefined') because we may have a (legal) redeclaration and we | 803 // 'undefined') because we may have a (legal) redeclaration and we |
800 // must not destroy the current value. | 804 // must not destroy the current value. |
801 if (hole_init) { | 805 if (hole_init) { |
802 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex); | 806 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex); |
803 } else { | 807 } else { |
804 DCHECK(Smi::FromInt(0) == 0); | 808 DCHECK(Smi::FromInt(0) == 0); |
805 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value. | 809 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value. |
806 } | 810 } |
807 __ Push(a2, a0); | 811 __ Push(a2, a0); |
808 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes())); | 812 __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes())); |
809 __ CallRuntime(Runtime::kDeclareLookupSlot); | 813 __ CallRuntime(Runtime::kDeclareLookupSlot); |
810 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 814 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
811 break; | 815 break; |
812 } | 816 } |
813 } | 817 } |
814 } | 818 } |
815 | 819 |
816 | 820 |
817 void FullCodeGenerator::VisitFunctionDeclaration( | 821 void FullCodeGenerator::VisitFunctionDeclaration( |
818 FunctionDeclaration* declaration) { | 822 FunctionDeclaration* declaration) { |
819 VariableProxy* proxy = declaration->proxy(); | 823 VariableProxy* proxy = declaration->proxy(); |
820 Variable* variable = proxy->var(); | 824 Variable* variable = proxy->var(); |
(...skipping 25 matching lines...) Expand all Loading... |
846 int offset = Context::SlotOffset(variable->index()); | 850 int offset = Context::SlotOffset(variable->index()); |
847 // We know that we have written a function, which is not a smi. | 851 // We know that we have written a function, which is not a smi. |
848 __ RecordWriteContextSlot(cp, | 852 __ RecordWriteContextSlot(cp, |
849 offset, | 853 offset, |
850 result_register(), | 854 result_register(), |
851 a2, | 855 a2, |
852 kRAHasBeenSaved, | 856 kRAHasBeenSaved, |
853 kDontSaveFPRegs, | 857 kDontSaveFPRegs, |
854 EMIT_REMEMBERED_SET, | 858 EMIT_REMEMBERED_SET, |
855 OMIT_SMI_CHECK); | 859 OMIT_SMI_CHECK); |
856 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 860 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
857 break; | 861 break; |
858 } | 862 } |
859 | 863 |
860 case VariableLocation::LOOKUP: { | 864 case VariableLocation::LOOKUP: { |
861 Comment cmnt(masm_, "[ FunctionDeclaration"); | 865 Comment cmnt(masm_, "[ FunctionDeclaration"); |
862 __ li(a2, Operand(variable->name())); | 866 __ li(a2, Operand(variable->name())); |
863 PushOperand(a2); | 867 PushOperand(a2); |
864 // Push initial value for function declaration. | 868 // Push initial value for function declaration. |
865 VisitForStackValue(declaration->fun()); | 869 VisitForStackValue(declaration->fun()); |
866 PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes())); | 870 PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes())); |
867 CallRuntimeWithOperands(Runtime::kDeclareLookupSlot); | 871 CallRuntimeWithOperands(Runtime::kDeclareLookupSlot); |
868 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 872 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
869 break; | 873 break; |
870 } | 874 } |
871 } | 875 } |
872 } | 876 } |
873 | 877 |
874 | 878 |
875 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 879 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
876 // Call the runtime to declare the globals. | 880 // Call the runtime to declare the globals. |
877 __ li(a1, Operand(pairs)); | 881 __ li(a1, Operand(pairs)); |
878 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); | 882 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); |
(...skipping 11 matching lines...) Expand all Loading... |
890 } | 894 } |
891 | 895 |
892 | 896 |
893 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { | 897 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
894 Comment cmnt(masm_, "[ SwitchStatement"); | 898 Comment cmnt(masm_, "[ SwitchStatement"); |
895 Breakable nested_statement(this, stmt); | 899 Breakable nested_statement(this, stmt); |
896 SetStatementPosition(stmt); | 900 SetStatementPosition(stmt); |
897 | 901 |
898 // Keep the switch value on the stack until a case matches. | 902 // Keep the switch value on the stack until a case matches. |
899 VisitForStackValue(stmt->tag()); | 903 VisitForStackValue(stmt->tag()); |
900 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 904 PrepareForBailoutForId(stmt->EntryId(), BailoutState::NO_REGISTERS); |
901 | 905 |
902 ZoneList<CaseClause*>* clauses = stmt->cases(); | 906 ZoneList<CaseClause*>* clauses = stmt->cases(); |
903 CaseClause* default_clause = NULL; // Can occur anywhere in the list. | 907 CaseClause* default_clause = NULL; // Can occur anywhere in the list. |
904 | 908 |
905 Label next_test; // Recycled for each test. | 909 Label next_test; // Recycled for each test. |
906 // Compile all the tests with branches to their bodies. | 910 // Compile all the tests with branches to their bodies. |
907 for (int i = 0; i < clauses->length(); i++) { | 911 for (int i = 0; i < clauses->length(); i++) { |
908 CaseClause* clause = clauses->at(i); | 912 CaseClause* clause = clauses->at(i); |
909 clause->body_target()->Unuse(); | 913 clause->body_target()->Unuse(); |
910 | 914 |
(...skipping 29 matching lines...) Expand all Loading... |
940 | 944 |
941 // Record position before stub call for type feedback. | 945 // Record position before stub call for type feedback. |
942 SetExpressionPosition(clause); | 946 SetExpressionPosition(clause); |
943 Handle<Code> ic = | 947 Handle<Code> ic = |
944 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); | 948 CodeFactory::CompareIC(isolate(), Token::EQ_STRICT).code(); |
945 CallIC(ic, clause->CompareId()); | 949 CallIC(ic, clause->CompareId()); |
946 patch_site.EmitPatchInfo(); | 950 patch_site.EmitPatchInfo(); |
947 | 951 |
948 Label skip; | 952 Label skip; |
949 __ Branch(&skip); | 953 __ Branch(&skip); |
950 PrepareForBailout(clause, TOS_REG); | 954 PrepareForBailout(clause, BailoutState::TOS_REGISTER); |
951 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 955 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
952 __ Branch(&next_test, ne, v0, Operand(at)); | 956 __ Branch(&next_test, ne, v0, Operand(at)); |
953 __ Drop(1); | 957 __ Drop(1); |
954 __ Branch(clause->body_target()); | 958 __ Branch(clause->body_target()); |
955 __ bind(&skip); | 959 __ bind(&skip); |
956 | 960 |
957 __ Branch(&next_test, ne, v0, Operand(zero_reg)); | 961 __ Branch(&next_test, ne, v0, Operand(zero_reg)); |
958 __ Drop(1); // Switch value is no longer needed. | 962 __ Drop(1); // Switch value is no longer needed. |
959 __ Branch(clause->body_target()); | 963 __ Branch(clause->body_target()); |
960 } | 964 } |
961 | 965 |
962 // Discard the test value and jump to the default if present, otherwise to | 966 // Discard the test value and jump to the default if present, otherwise to |
963 // the end of the statement. | 967 // the end of the statement. |
964 __ bind(&next_test); | 968 __ bind(&next_test); |
965 DropOperands(1); // Switch value is no longer needed. | 969 DropOperands(1); // Switch value is no longer needed. |
966 if (default_clause == NULL) { | 970 if (default_clause == NULL) { |
967 __ Branch(nested_statement.break_label()); | 971 __ Branch(nested_statement.break_label()); |
968 } else { | 972 } else { |
969 __ Branch(default_clause->body_target()); | 973 __ Branch(default_clause->body_target()); |
970 } | 974 } |
971 | 975 |
972 // Compile all the case bodies. | 976 // Compile all the case bodies. |
973 for (int i = 0; i < clauses->length(); i++) { | 977 for (int i = 0; i < clauses->length(); i++) { |
974 Comment cmnt(masm_, "[ Case body"); | 978 Comment cmnt(masm_, "[ Case body"); |
975 CaseClause* clause = clauses->at(i); | 979 CaseClause* clause = clauses->at(i); |
976 __ bind(clause->body_target()); | 980 __ bind(clause->body_target()); |
977 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); | 981 PrepareForBailoutForId(clause->EntryId(), BailoutState::NO_REGISTERS); |
978 VisitStatements(clause->statements()); | 982 VisitStatements(clause->statements()); |
979 } | 983 } |
980 | 984 |
981 __ bind(nested_statement.break_label()); | 985 __ bind(nested_statement.break_label()); |
982 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 986 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); |
983 } | 987 } |
984 | 988 |
985 | 989 |
986 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 990 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
987 Comment cmnt(masm_, "[ ForInStatement"); | 991 Comment cmnt(masm_, "[ ForInStatement"); |
988 SetStatementPosition(stmt, SKIP_BREAK); | 992 SetStatementPosition(stmt, SKIP_BREAK); |
989 | 993 |
990 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 994 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
991 | 995 |
992 // Get the object to enumerate over. If the object is null or undefined, skip | 996 // Get the object to enumerate over. If the object is null or undefined, skip |
(...skipping 16 matching lines...) Expand all Loading... |
1009 Operand(FIRST_JS_RECEIVER_TYPE)); | 1013 Operand(FIRST_JS_RECEIVER_TYPE)); |
1010 __ LoadRoot(at, Heap::kNullValueRootIndex); // In delay slot. | 1014 __ LoadRoot(at, Heap::kNullValueRootIndex); // In delay slot. |
1011 __ Branch(USE_DELAY_SLOT, &exit, eq, a0, Operand(at)); | 1015 __ Branch(USE_DELAY_SLOT, &exit, eq, a0, Operand(at)); |
1012 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); // In delay slot. | 1016 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); // In delay slot. |
1013 __ Branch(&exit, eq, a0, Operand(at)); | 1017 __ Branch(&exit, eq, a0, Operand(at)); |
1014 __ bind(&convert); | 1018 __ bind(&convert); |
1015 ToObjectStub stub(isolate()); | 1019 ToObjectStub stub(isolate()); |
1016 __ CallStub(&stub); | 1020 __ CallStub(&stub); |
1017 __ mov(a0, v0); | 1021 __ mov(a0, v0); |
1018 __ bind(&done_convert); | 1022 __ bind(&done_convert); |
1019 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); | 1023 PrepareForBailoutForId(stmt->ToObjectId(), BailoutState::TOS_REGISTER); |
1020 __ push(a0); | 1024 __ push(a0); |
1021 | 1025 |
1022 // Check cache validity in generated code. If we cannot guarantee cache | 1026 // Check cache validity in generated code. If we cannot guarantee cache |
1023 // validity, call the runtime system to check cache validity or get the | 1027 // validity, call the runtime system to check cache validity or get the |
1024 // property names in a fixed array. Note: Proxies never have an enum cache, | 1028 // property names in a fixed array. Note: Proxies never have an enum cache, |
1025 // so will always take the slow path. | 1029 // so will always take the slow path. |
1026 Label call_runtime; | 1030 Label call_runtime; |
1027 __ CheckEnumCache(&call_runtime); | 1031 __ CheckEnumCache(&call_runtime); |
1028 | 1032 |
1029 // The enum cache is valid. Load the map of the object being | 1033 // The enum cache is valid. Load the map of the object being |
1030 // iterated over and use the cache for the iteration. | 1034 // iterated over and use the cache for the iteration. |
1031 Label use_cache; | 1035 Label use_cache; |
1032 __ ld(v0, FieldMemOperand(a0, HeapObject::kMapOffset)); | 1036 __ ld(v0, FieldMemOperand(a0, HeapObject::kMapOffset)); |
1033 __ Branch(&use_cache); | 1037 __ Branch(&use_cache); |
1034 | 1038 |
1035 // Get the set of properties to enumerate. | 1039 // Get the set of properties to enumerate. |
1036 __ bind(&call_runtime); | 1040 __ bind(&call_runtime); |
1037 __ push(a0); // Duplicate the enumerable object on the stack. | 1041 __ push(a0); // Duplicate the enumerable object on the stack. |
1038 __ CallRuntime(Runtime::kForInEnumerate); | 1042 __ CallRuntime(Runtime::kForInEnumerate); |
1039 PrepareForBailoutForId(stmt->EnumId(), TOS_REG); | 1043 PrepareForBailoutForId(stmt->EnumId(), BailoutState::TOS_REGISTER); |
1040 | 1044 |
1041 // If we got a map from the runtime call, we can do a fast | 1045 // If we got a map from the runtime call, we can do a fast |
1042 // modification check. Otherwise, we got a fixed array, and we have | 1046 // modification check. Otherwise, we got a fixed array, and we have |
1043 // to do a slow check. | 1047 // to do a slow check. |
1044 Label fixed_array; | 1048 Label fixed_array; |
1045 __ ld(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); | 1049 __ ld(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); |
1046 __ LoadRoot(at, Heap::kMetaMapRootIndex); | 1050 __ LoadRoot(at, Heap::kMetaMapRootIndex); |
1047 __ Branch(&fixed_array, ne, a2, Operand(at)); | 1051 __ Branch(&fixed_array, ne, a2, Operand(at)); |
1048 | 1052 |
1049 // We got a map in register v0. Get the enumeration cache from it. | 1053 // We got a map in register v0. Get the enumeration cache from it. |
(...skipping 17 matching lines...) Expand all Loading... |
1067 __ Drop(1); | 1071 __ Drop(1); |
1068 __ jmp(&exit); | 1072 __ jmp(&exit); |
1069 | 1073 |
1070 // We got a fixed array in register v0. Iterate through that. | 1074 // We got a fixed array in register v0. Iterate through that. |
1071 __ bind(&fixed_array); | 1075 __ bind(&fixed_array); |
1072 | 1076 |
1073 __ li(a1, Operand(Smi::FromInt(1))); // Smi(1) indicates slow check | 1077 __ li(a1, Operand(Smi::FromInt(1))); // Smi(1) indicates slow check |
1074 __ Push(a1, v0); // Smi and array | 1078 __ Push(a1, v0); // Smi and array |
1075 __ ld(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); | 1079 __ ld(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); |
1076 __ Push(a1); // Fixed array length (as smi). | 1080 __ Push(a1); // Fixed array length (as smi). |
1077 PrepareForBailoutForId(stmt->PrepareId(), NO_REGISTERS); | 1081 PrepareForBailoutForId(stmt->PrepareId(), BailoutState::NO_REGISTERS); |
1078 __ li(a0, Operand(Smi::FromInt(0))); | 1082 __ li(a0, Operand(Smi::FromInt(0))); |
1079 __ Push(a0); // Initial index. | 1083 __ Push(a0); // Initial index. |
1080 | 1084 |
1081 // Generate code for doing the condition check. | 1085 // Generate code for doing the condition check. |
1082 __ bind(&loop); | 1086 __ bind(&loop); |
1083 SetExpressionAsStatementPosition(stmt->each()); | 1087 SetExpressionAsStatementPosition(stmt->each()); |
1084 | 1088 |
1085 // Load the current count to a0, load the length to a1. | 1089 // Load the current count to a0, load the length to a1. |
1086 __ ld(a0, MemOperand(sp, 0 * kPointerSize)); | 1090 __ ld(a0, MemOperand(sp, 0 * kPointerSize)); |
1087 __ ld(a1, MemOperand(sp, 1 * kPointerSize)); | 1091 __ ld(a1, MemOperand(sp, 1 * kPointerSize)); |
(...skipping 21 matching lines...) Expand all Loading... |
1109 int const vector_index = SmiFromSlot(slot)->value(); | 1113 int const vector_index = SmiFromSlot(slot)->value(); |
1110 __ EmitLoadTypeFeedbackVector(a0); | 1114 __ EmitLoadTypeFeedbackVector(a0); |
1111 __ li(a2, Operand(TypeFeedbackVector::MegamorphicSentinel(isolate()))); | 1115 __ li(a2, Operand(TypeFeedbackVector::MegamorphicSentinel(isolate()))); |
1112 __ sd(a2, FieldMemOperand(a0, FixedArray::OffsetOfElementAt(vector_index))); | 1116 __ sd(a2, FieldMemOperand(a0, FixedArray::OffsetOfElementAt(vector_index))); |
1113 | 1117 |
1114 // Convert the entry to a string or (smi) 0 if it isn't a property | 1118 // Convert the entry to a string or (smi) 0 if it isn't a property |
1115 // any more. If the property has been removed while iterating, we | 1119 // any more. If the property has been removed while iterating, we |
1116 // just skip it. | 1120 // just skip it. |
1117 __ Push(a1, a3); // Enumerable and current entry. | 1121 __ Push(a1, a3); // Enumerable and current entry. |
1118 __ CallRuntime(Runtime::kForInFilter); | 1122 __ CallRuntime(Runtime::kForInFilter); |
1119 PrepareForBailoutForId(stmt->FilterId(), TOS_REG); | 1123 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); |
1120 __ mov(a3, result_register()); | 1124 __ mov(a3, result_register()); |
1121 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 1125 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
1122 __ Branch(loop_statement.continue_label(), eq, a3, Operand(at)); | 1126 __ Branch(loop_statement.continue_label(), eq, a3, Operand(at)); |
1123 | 1127 |
1124 // Update the 'each' property or variable from the possibly filtered | 1128 // Update the 'each' property or variable from the possibly filtered |
1125 // entry in register a3. | 1129 // entry in register a3. |
1126 __ bind(&update_each); | 1130 __ bind(&update_each); |
1127 __ mov(result_register(), a3); | 1131 __ mov(result_register(), a3); |
1128 // Perform the assignment as if via '='. | 1132 // Perform the assignment as if via '='. |
1129 { EffectContext context(this); | 1133 { EffectContext context(this); |
1130 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1134 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
1131 PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS); | 1135 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); |
1132 } | 1136 } |
1133 | 1137 |
1134 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). | 1138 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). |
1135 PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 1139 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); |
1136 // Generate code for the body of the loop. | 1140 // Generate code for the body of the loop. |
1137 Visit(stmt->body()); | 1141 Visit(stmt->body()); |
1138 | 1142 |
1139 // Generate code for the going to the next element by incrementing | 1143 // Generate code for the going to the next element by incrementing |
1140 // the index (smi) stored on top of the stack. | 1144 // the index (smi) stored on top of the stack. |
1141 __ bind(loop_statement.continue_label()); | 1145 __ bind(loop_statement.continue_label()); |
1142 __ pop(a0); | 1146 __ pop(a0); |
1143 __ Daddu(a0, a0, Operand(Smi::FromInt(1))); | 1147 __ Daddu(a0, a0, Operand(Smi::FromInt(1))); |
1144 __ push(a0); | 1148 __ push(a0); |
1145 | 1149 |
1146 EmitBackEdgeBookkeeping(stmt, &loop); | 1150 EmitBackEdgeBookkeeping(stmt, &loop); |
1147 __ Branch(&loop); | 1151 __ Branch(&loop); |
1148 | 1152 |
1149 // Remove the pointers stored on the stack. | 1153 // Remove the pointers stored on the stack. |
1150 __ bind(loop_statement.break_label()); | 1154 __ bind(loop_statement.break_label()); |
1151 DropOperands(5); | 1155 DropOperands(5); |
1152 | 1156 |
1153 // Exit and decrement the loop depth. | 1157 // Exit and decrement the loop depth. |
1154 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1158 PrepareForBailoutForId(stmt->ExitId(), BailoutState::NO_REGISTERS); |
1155 __ bind(&exit); | 1159 __ bind(&exit); |
1156 decrement_loop_depth(); | 1160 decrement_loop_depth(); |
1157 } | 1161 } |
1158 | 1162 |
1159 | 1163 |
1160 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, | 1164 void FullCodeGenerator::EmitSetHomeObject(Expression* initializer, int offset, |
1161 FeedbackVectorSlot slot) { | 1165 FeedbackVectorSlot slot) { |
1162 DCHECK(NeedsHomeObject(initializer)); | 1166 DCHECK(NeedsHomeObject(initializer)); |
1163 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); | 1167 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); |
1164 __ li(StoreDescriptor::NameRegister(), | 1168 __ li(StoreDescriptor::NameRegister(), |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 __ li(LoadDescriptor::SlotRegister(), | 1307 __ li(LoadDescriptor::SlotRegister(), |
1304 Operand(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1308 Operand(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1305 CallLoadIC(typeof_mode); | 1309 CallLoadIC(typeof_mode); |
1306 } | 1310 } |
1307 | 1311 |
1308 | 1312 |
1309 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1313 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
1310 TypeofMode typeof_mode) { | 1314 TypeofMode typeof_mode) { |
1311 // Record position before possible IC call. | 1315 // Record position before possible IC call. |
1312 SetExpressionPosition(proxy); | 1316 SetExpressionPosition(proxy); |
1313 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1317 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); |
1314 Variable* var = proxy->var(); | 1318 Variable* var = proxy->var(); |
1315 | 1319 |
1316 // Three cases: global variables, lookup variables, and all other types of | 1320 // Three cases: global variables, lookup variables, and all other types of |
1317 // variables. | 1321 // variables. |
1318 switch (var->location()) { | 1322 switch (var->location()) { |
1319 case VariableLocation::GLOBAL: | 1323 case VariableLocation::GLOBAL: |
1320 case VariableLocation::UNALLOCATED: { | 1324 case VariableLocation::UNALLOCATED: { |
1321 Comment cmnt(masm_, "[ Global variable"); | 1325 Comment cmnt(masm_, "[ Global variable"); |
1322 EmitGlobalVariableLoad(proxy, typeof_mode); | 1326 EmitGlobalVariableLoad(proxy, typeof_mode); |
1323 context()->Plug(v0); | 1327 context()->Plug(v0); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 __ li(a1, Operand(constant_properties)); | 1414 __ li(a1, Operand(constant_properties)); |
1411 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); | 1415 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); |
1412 if (MustCreateObjectLiteralWithRuntime(expr)) { | 1416 if (MustCreateObjectLiteralWithRuntime(expr)) { |
1413 __ Push(a3, a2, a1, a0); | 1417 __ Push(a3, a2, a1, a0); |
1414 __ CallRuntime(Runtime::kCreateObjectLiteral); | 1418 __ CallRuntime(Runtime::kCreateObjectLiteral); |
1415 } else { | 1419 } else { |
1416 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); | 1420 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
1417 __ CallStub(&stub); | 1421 __ CallStub(&stub); |
1418 RestoreContext(); | 1422 RestoreContext(); |
1419 } | 1423 } |
1420 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1424 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
1421 | 1425 |
1422 // If result_saved is true the result is on top of the stack. If | 1426 // If result_saved is true the result is on top of the stack. If |
1423 // result_saved is false the result is in v0. | 1427 // result_saved is false the result is in v0. |
1424 bool result_saved = false; | 1428 bool result_saved = false; |
1425 | 1429 |
1426 AccessorTable accessor_table(zone()); | 1430 AccessorTable accessor_table(zone()); |
1427 int property_index = 0; | 1431 int property_index = 0; |
1428 for (; property_index < expr->properties()->length(); property_index++) { | 1432 for (; property_index < expr->properties()->length(); property_index++) { |
1429 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1433 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
1430 if (property->is_computed_name()) break; | 1434 if (property->is_computed_name()) break; |
(...skipping 16 matching lines...) Expand all Loading... |
1447 // contains computed properties with an uninitialized value. | 1451 // contains computed properties with an uninitialized value. |
1448 if (key->value()->IsInternalizedString()) { | 1452 if (key->value()->IsInternalizedString()) { |
1449 if (property->emit_store()) { | 1453 if (property->emit_store()) { |
1450 VisitForAccumulatorValue(value); | 1454 VisitForAccumulatorValue(value); |
1451 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 1455 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
1452 DCHECK(StoreDescriptor::ValueRegister().is(a0)); | 1456 DCHECK(StoreDescriptor::ValueRegister().is(a0)); |
1453 __ li(StoreDescriptor::NameRegister(), Operand(key->value())); | 1457 __ li(StoreDescriptor::NameRegister(), Operand(key->value())); |
1454 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); | 1458 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); |
1455 EmitLoadStoreICSlot(property->GetSlot(0)); | 1459 EmitLoadStoreICSlot(property->GetSlot(0)); |
1456 CallStoreIC(); | 1460 CallStoreIC(); |
1457 PrepareForBailoutForId(key->id(), NO_REGISTERS); | 1461 PrepareForBailoutForId(key->id(), BailoutState::NO_REGISTERS); |
1458 | 1462 |
1459 if (NeedsHomeObject(value)) { | 1463 if (NeedsHomeObject(value)) { |
1460 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); | 1464 EmitSetHomeObjectAccumulator(value, 0, property->GetSlot(1)); |
1461 } | 1465 } |
1462 } else { | 1466 } else { |
1463 VisitForEffect(value); | 1467 VisitForEffect(value); |
1464 } | 1468 } |
1465 break; | 1469 break; |
1466 } | 1470 } |
1467 // Duplicate receiver on stack. | 1471 // Duplicate receiver on stack. |
(...skipping 13 matching lines...) Expand all Loading... |
1481 } | 1485 } |
1482 break; | 1486 break; |
1483 case ObjectLiteral::Property::PROTOTYPE: | 1487 case ObjectLiteral::Property::PROTOTYPE: |
1484 // Duplicate receiver on stack. | 1488 // Duplicate receiver on stack. |
1485 __ ld(a0, MemOperand(sp)); | 1489 __ ld(a0, MemOperand(sp)); |
1486 PushOperand(a0); | 1490 PushOperand(a0); |
1487 VisitForStackValue(value); | 1491 VisitForStackValue(value); |
1488 DCHECK(property->emit_store()); | 1492 DCHECK(property->emit_store()); |
1489 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1493 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
1490 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1494 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
1491 NO_REGISTERS); | 1495 BailoutState::NO_REGISTERS); |
1492 break; | 1496 break; |
1493 case ObjectLiteral::Property::GETTER: | 1497 case ObjectLiteral::Property::GETTER: |
1494 if (property->emit_store()) { | 1498 if (property->emit_store()) { |
1495 accessor_table.lookup(key)->second->getter = property; | 1499 accessor_table.lookup(key)->second->getter = property; |
1496 } | 1500 } |
1497 break; | 1501 break; |
1498 case ObjectLiteral::Property::SETTER: | 1502 case ObjectLiteral::Property::SETTER: |
1499 if (property->emit_store()) { | 1503 if (property->emit_store()) { |
1500 accessor_table.lookup(key)->second->setter = property; | 1504 accessor_table.lookup(key)->second->setter = property; |
1501 } | 1505 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 | 1542 |
1539 __ ld(a0, MemOperand(sp)); // Duplicate receiver. | 1543 __ ld(a0, MemOperand(sp)); // Duplicate receiver. |
1540 PushOperand(a0); | 1544 PushOperand(a0); |
1541 | 1545 |
1542 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { | 1546 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { |
1543 DCHECK(!property->is_computed_name()); | 1547 DCHECK(!property->is_computed_name()); |
1544 VisitForStackValue(value); | 1548 VisitForStackValue(value); |
1545 DCHECK(property->emit_store()); | 1549 DCHECK(property->emit_store()); |
1546 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); | 1550 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
1547 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), | 1551 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
1548 NO_REGISTERS); | 1552 BailoutState::NO_REGISTERS); |
1549 } else { | 1553 } else { |
1550 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); | 1554 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); |
1551 VisitForStackValue(value); | 1555 VisitForStackValue(value); |
1552 if (NeedsHomeObject(value)) { | 1556 if (NeedsHomeObject(value)) { |
1553 EmitSetHomeObject(value, 2, property->GetSlot()); | 1557 EmitSetHomeObject(value, 2, property->GetSlot()); |
1554 } | 1558 } |
1555 | 1559 |
1556 switch (property->kind()) { | 1560 switch (property->kind()) { |
1557 case ObjectLiteral::Property::CONSTANT: | 1561 case ObjectLiteral::Property::CONSTANT: |
1558 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1562 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); | 1614 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); |
1611 __ li(a1, Operand(constant_elements)); | 1615 __ li(a1, Operand(constant_elements)); |
1612 if (MustCreateArrayLiteralWithRuntime(expr)) { | 1616 if (MustCreateArrayLiteralWithRuntime(expr)) { |
1613 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); | 1617 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); |
1614 __ Push(a3, a2, a1, a0); | 1618 __ Push(a3, a2, a1, a0); |
1615 __ CallRuntime(Runtime::kCreateArrayLiteral); | 1619 __ CallRuntime(Runtime::kCreateArrayLiteral); |
1616 } else { | 1620 } else { |
1617 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1621 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
1618 __ CallStub(&stub); | 1622 __ CallStub(&stub); |
1619 } | 1623 } |
1620 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1624 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); |
1621 | 1625 |
1622 bool result_saved = false; // Is the result saved to the stack? | 1626 bool result_saved = false; // Is the result saved to the stack? |
1623 ZoneList<Expression*>* subexprs = expr->values(); | 1627 ZoneList<Expression*>* subexprs = expr->values(); |
1624 int length = subexprs->length(); | 1628 int length = subexprs->length(); |
1625 | 1629 |
1626 // Emit code to evaluate all the non-constant subexpressions and to store | 1630 // Emit code to evaluate all the non-constant subexpressions and to store |
1627 // them into the newly cloned array. | 1631 // them into the newly cloned array. |
1628 int array_index = 0; | 1632 int array_index = 0; |
1629 for (; array_index < length; array_index++) { | 1633 for (; array_index < length; array_index++) { |
1630 Expression* subexpr = subexprs->at(array_index); | 1634 Expression* subexpr = subexprs->at(array_index); |
(...skipping 11 matching lines...) Expand all Loading... |
1642 VisitForAccumulatorValue(subexpr); | 1646 VisitForAccumulatorValue(subexpr); |
1643 | 1647 |
1644 __ li(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); | 1648 __ li(StoreDescriptor::NameRegister(), Operand(Smi::FromInt(array_index))); |
1645 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 1649 __ ld(StoreDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
1646 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 1650 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
1647 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); | 1651 EmitLoadStoreICSlot(expr->LiteralFeedbackSlot()); |
1648 Handle<Code> ic = | 1652 Handle<Code> ic = |
1649 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 1653 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
1650 CallIC(ic); | 1654 CallIC(ic); |
1651 | 1655 |
1652 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1656 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1657 BailoutState::NO_REGISTERS); |
1653 } | 1658 } |
1654 | 1659 |
1655 // In case the array literal contains spread expressions it has two parts. The | 1660 // In case the array literal contains spread expressions it has two parts. The |
1656 // first part is the "static" array which has a literal index is handled | 1661 // first part is the "static" array which has a literal index is handled |
1657 // above. The second part is the part after the first spread expression | 1662 // above. The second part is the part after the first spread expression |
1658 // (inclusive) and these elements gets appended to the array. Note that the | 1663 // (inclusive) and these elements gets appended to the array. Note that the |
1659 // number elements an iterable produces is unknown ahead of time. | 1664 // number elements an iterable produces is unknown ahead of time. |
1660 if (array_index < length && result_saved) { | 1665 if (array_index < length && result_saved) { |
1661 PopOperand(v0); | 1666 PopOperand(v0); |
1662 result_saved = false; | 1667 result_saved = false; |
1663 } | 1668 } |
1664 for (; array_index < length; array_index++) { | 1669 for (; array_index < length; array_index++) { |
1665 Expression* subexpr = subexprs->at(array_index); | 1670 Expression* subexpr = subexprs->at(array_index); |
1666 | 1671 |
1667 PushOperand(v0); | 1672 PushOperand(v0); |
1668 DCHECK(!subexpr->IsSpread()); | 1673 DCHECK(!subexpr->IsSpread()); |
1669 VisitForStackValue(subexpr); | 1674 VisitForStackValue(subexpr); |
1670 CallRuntimeWithOperands(Runtime::kAppendElement); | 1675 CallRuntimeWithOperands(Runtime::kAppendElement); |
1671 | 1676 |
1672 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); | 1677 PrepareForBailoutForId(expr->GetIdForElement(array_index), |
| 1678 BailoutState::NO_REGISTERS); |
1673 } | 1679 } |
1674 | 1680 |
1675 if (result_saved) { | 1681 if (result_saved) { |
1676 context()->PlugTOS(); | 1682 context()->PlugTOS(); |
1677 } else { | 1683 } else { |
1678 context()->Plug(v0); | 1684 context()->Plug(v0); |
1679 } | 1685 } |
1680 } | 1686 } |
1681 | 1687 |
1682 | 1688 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 break; | 1751 break; |
1746 } | 1752 } |
1747 | 1753 |
1748 // For compound assignments we need another deoptimization point after the | 1754 // For compound assignments we need another deoptimization point after the |
1749 // variable/property load. | 1755 // variable/property load. |
1750 if (expr->is_compound()) { | 1756 if (expr->is_compound()) { |
1751 { AccumulatorValueContext context(this); | 1757 { AccumulatorValueContext context(this); |
1752 switch (assign_type) { | 1758 switch (assign_type) { |
1753 case VARIABLE: | 1759 case VARIABLE: |
1754 EmitVariableLoad(expr->target()->AsVariableProxy()); | 1760 EmitVariableLoad(expr->target()->AsVariableProxy()); |
1755 PrepareForBailout(expr->target(), TOS_REG); | 1761 PrepareForBailout(expr->target(), BailoutState::TOS_REGISTER); |
1756 break; | 1762 break; |
1757 case NAMED_PROPERTY: | 1763 case NAMED_PROPERTY: |
1758 EmitNamedPropertyLoad(property); | 1764 EmitNamedPropertyLoad(property); |
1759 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1765 PrepareForBailoutForId(property->LoadId(), |
| 1766 BailoutState::TOS_REGISTER); |
1760 break; | 1767 break; |
1761 case NAMED_SUPER_PROPERTY: | 1768 case NAMED_SUPER_PROPERTY: |
1762 EmitNamedSuperPropertyLoad(property); | 1769 EmitNamedSuperPropertyLoad(property); |
1763 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1770 PrepareForBailoutForId(property->LoadId(), |
| 1771 BailoutState::TOS_REGISTER); |
1764 break; | 1772 break; |
1765 case KEYED_SUPER_PROPERTY: | 1773 case KEYED_SUPER_PROPERTY: |
1766 EmitKeyedSuperPropertyLoad(property); | 1774 EmitKeyedSuperPropertyLoad(property); |
1767 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1775 PrepareForBailoutForId(property->LoadId(), |
| 1776 BailoutState::TOS_REGISTER); |
1768 break; | 1777 break; |
1769 case KEYED_PROPERTY: | 1778 case KEYED_PROPERTY: |
1770 EmitKeyedPropertyLoad(property); | 1779 EmitKeyedPropertyLoad(property); |
1771 PrepareForBailoutForId(property->LoadId(), TOS_REG); | 1780 PrepareForBailoutForId(property->LoadId(), |
| 1781 BailoutState::TOS_REGISTER); |
1772 break; | 1782 break; |
1773 } | 1783 } |
1774 } | 1784 } |
1775 | 1785 |
1776 Token::Value op = expr->binary_op(); | 1786 Token::Value op = expr->binary_op(); |
1777 PushOperand(v0); // Left operand goes on the stack. | 1787 PushOperand(v0); // Left operand goes on the stack. |
1778 VisitForAccumulatorValue(expr->value()); | 1788 VisitForAccumulatorValue(expr->value()); |
1779 | 1789 |
1780 AccumulatorValueContext context(this); | 1790 AccumulatorValueContext context(this); |
1781 if (ShouldInlineSmiCase(op)) { | 1791 if (ShouldInlineSmiCase(op)) { |
1782 EmitInlineSmiBinaryOp(expr->binary_operation(), | 1792 EmitInlineSmiBinaryOp(expr->binary_operation(), |
1783 op, | 1793 op, |
1784 expr->target(), | 1794 expr->target(), |
1785 expr->value()); | 1795 expr->value()); |
1786 } else { | 1796 } else { |
1787 EmitBinaryOp(expr->binary_operation(), op); | 1797 EmitBinaryOp(expr->binary_operation(), op); |
1788 } | 1798 } |
1789 | 1799 |
1790 // Deoptimization point in case the binary operation may have side effects. | 1800 // Deoptimization point in case the binary operation may have side effects. |
1791 PrepareForBailout(expr->binary_operation(), TOS_REG); | 1801 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); |
1792 } else { | 1802 } else { |
1793 VisitForAccumulatorValue(expr->value()); | 1803 VisitForAccumulatorValue(expr->value()); |
1794 } | 1804 } |
1795 | 1805 |
1796 SetExpressionPosition(expr); | 1806 SetExpressionPosition(expr); |
1797 | 1807 |
1798 // Store the value. | 1808 // Store the value. |
1799 switch (assign_type) { | 1809 switch (assign_type) { |
1800 case VARIABLE: | 1810 case VARIABLE: |
1801 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 1811 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
1802 expr->op(), expr->AssignmentSlot()); | 1812 expr->op(), expr->AssignmentSlot()); |
1803 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 1813 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
1804 context()->Plug(v0); | 1814 context()->Plug(v0); |
1805 break; | 1815 break; |
1806 case NAMED_PROPERTY: | 1816 case NAMED_PROPERTY: |
1807 EmitNamedPropertyAssignment(expr); | 1817 EmitNamedPropertyAssignment(expr); |
1808 break; | 1818 break; |
1809 case NAMED_SUPER_PROPERTY: | 1819 case NAMED_SUPER_PROPERTY: |
1810 EmitNamedSuperPropertyStore(property); | 1820 EmitNamedSuperPropertyStore(property); |
1811 context()->Plug(v0); | 1821 context()->Plug(v0); |
1812 break; | 1822 break; |
1813 case KEYED_SUPER_PROPERTY: | 1823 case KEYED_SUPER_PROPERTY: |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2268 DCHECK(prop != NULL); | 2278 DCHECK(prop != NULL); |
2269 DCHECK(prop->key()->IsLiteral()); | 2279 DCHECK(prop->key()->IsLiteral()); |
2270 | 2280 |
2271 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 2281 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
2272 __ li(StoreDescriptor::NameRegister(), | 2282 __ li(StoreDescriptor::NameRegister(), |
2273 Operand(prop->key()->AsLiteral()->value())); | 2283 Operand(prop->key()->AsLiteral()->value())); |
2274 PopOperand(StoreDescriptor::ReceiverRegister()); | 2284 PopOperand(StoreDescriptor::ReceiverRegister()); |
2275 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2285 EmitLoadStoreICSlot(expr->AssignmentSlot()); |
2276 CallStoreIC(); | 2286 CallStoreIC(); |
2277 | 2287 |
2278 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2288 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
2279 context()->Plug(v0); | 2289 context()->Plug(v0); |
2280 } | 2290 } |
2281 | 2291 |
2282 | 2292 |
2283 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { | 2293 void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { |
2284 // Assignment to named property of super. | 2294 // Assignment to named property of super. |
2285 // v0 : value | 2295 // v0 : value |
2286 // stack : receiver ('this'), home_object | 2296 // stack : receiver ('this'), home_object |
2287 DCHECK(prop != NULL); | 2297 DCHECK(prop != NULL); |
2288 Literal* key = prop->key()->AsLiteral(); | 2298 Literal* key = prop->key()->AsLiteral(); |
(...skipping 30 matching lines...) Expand all Loading... |
2319 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 2329 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
2320 PopOperands(StoreDescriptor::ReceiverRegister(), | 2330 PopOperands(StoreDescriptor::ReceiverRegister(), |
2321 StoreDescriptor::NameRegister()); | 2331 StoreDescriptor::NameRegister()); |
2322 DCHECK(StoreDescriptor::ValueRegister().is(a0)); | 2332 DCHECK(StoreDescriptor::ValueRegister().is(a0)); |
2323 | 2333 |
2324 Handle<Code> ic = | 2334 Handle<Code> ic = |
2325 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 2335 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
2326 EmitLoadStoreICSlot(expr->AssignmentSlot()); | 2336 EmitLoadStoreICSlot(expr->AssignmentSlot()); |
2327 CallIC(ic); | 2337 CallIC(ic); |
2328 | 2338 |
2329 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2339 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
2330 context()->Plug(v0); | 2340 context()->Plug(v0); |
2331 } | 2341 } |
2332 | 2342 |
2333 | 2343 |
2334 void FullCodeGenerator::CallIC(Handle<Code> code, | 2344 void FullCodeGenerator::CallIC(Handle<Code> code, |
2335 TypeFeedbackId id) { | 2345 TypeFeedbackId id) { |
2336 ic_total_count_++; | 2346 ic_total_count_++; |
2337 __ Call(code, RelocInfo::CODE_TARGET, id); | 2347 __ Call(code, RelocInfo::CODE_TARGET, id); |
2338 } | 2348 } |
2339 | 2349 |
2340 | 2350 |
2341 // Code common for calls using the IC. | 2351 // Code common for calls using the IC. |
2342 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { | 2352 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
2343 Expression* callee = expr->expression(); | 2353 Expression* callee = expr->expression(); |
2344 | 2354 |
2345 // Get the target function. | 2355 // Get the target function. |
2346 ConvertReceiverMode convert_mode; | 2356 ConvertReceiverMode convert_mode; |
2347 if (callee->IsVariableProxy()) { | 2357 if (callee->IsVariableProxy()) { |
2348 { StackValueContext context(this); | 2358 { StackValueContext context(this); |
2349 EmitVariableLoad(callee->AsVariableProxy()); | 2359 EmitVariableLoad(callee->AsVariableProxy()); |
2350 PrepareForBailout(callee, NO_REGISTERS); | 2360 PrepareForBailout(callee, BailoutState::NO_REGISTERS); |
2351 } | 2361 } |
2352 // Push undefined as receiver. This is patched in the method prologue if it | 2362 // Push undefined as receiver. This is patched in the method prologue if it |
2353 // is a sloppy mode method. | 2363 // is a sloppy mode method. |
2354 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 2364 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
2355 PushOperand(at); | 2365 PushOperand(at); |
2356 convert_mode = ConvertReceiverMode::kNullOrUndefined; | 2366 convert_mode = ConvertReceiverMode::kNullOrUndefined; |
2357 } else { | 2367 } else { |
2358 // Load the function from the receiver. | 2368 // Load the function from the receiver. |
2359 DCHECK(callee->IsProperty()); | 2369 DCHECK(callee->IsProperty()); |
2360 DCHECK(!callee->AsProperty()->IsSuperAccess()); | 2370 DCHECK(!callee->AsProperty()->IsSuperAccess()); |
2361 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2371 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
2362 EmitNamedPropertyLoad(callee->AsProperty()); | 2372 EmitNamedPropertyLoad(callee->AsProperty()); |
2363 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2373 PrepareForBailoutForId(callee->AsProperty()->LoadId(), |
| 2374 BailoutState::TOS_REGISTER); |
2364 // Push the target function under the receiver. | 2375 // Push the target function under the receiver. |
2365 __ ld(at, MemOperand(sp, 0)); | 2376 __ ld(at, MemOperand(sp, 0)); |
2366 PushOperand(at); | 2377 PushOperand(at); |
2367 __ sd(v0, MemOperand(sp, kPointerSize)); | 2378 __ sd(v0, MemOperand(sp, kPointerSize)); |
2368 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; | 2379 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; |
2369 } | 2380 } |
2370 | 2381 |
2371 EmitCall(expr, convert_mode); | 2382 EmitCall(expr, convert_mode); |
2372 } | 2383 } |
2373 | 2384 |
(...skipping 16 matching lines...) Expand all Loading... |
2390 PushOperands(scratch, v0, v0, scratch); | 2401 PushOperands(scratch, v0, v0, scratch); |
2391 PushOperand(key->value()); | 2402 PushOperand(key->value()); |
2392 | 2403 |
2393 // Stack here: | 2404 // Stack here: |
2394 // - home_object | 2405 // - home_object |
2395 // - this (receiver) | 2406 // - this (receiver) |
2396 // - this (receiver) <-- LoadFromSuper will pop here and below. | 2407 // - this (receiver) <-- LoadFromSuper will pop here and below. |
2397 // - home_object | 2408 // - home_object |
2398 // - key | 2409 // - key |
2399 CallRuntimeWithOperands(Runtime::kLoadFromSuper); | 2410 CallRuntimeWithOperands(Runtime::kLoadFromSuper); |
2400 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 2411 PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER); |
2401 | 2412 |
2402 // Replace home_object with target function. | 2413 // Replace home_object with target function. |
2403 __ sd(v0, MemOperand(sp, kPointerSize)); | 2414 __ sd(v0, MemOperand(sp, kPointerSize)); |
2404 | 2415 |
2405 // Stack here: | 2416 // Stack here: |
2406 // - target function | 2417 // - target function |
2407 // - this (receiver) | 2418 // - this (receiver) |
2408 EmitCall(expr); | 2419 EmitCall(expr); |
2409 } | 2420 } |
2410 | 2421 |
2411 | 2422 |
2412 // Code common for calls using the IC. | 2423 // Code common for calls using the IC. |
2413 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, | 2424 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
2414 Expression* key) { | 2425 Expression* key) { |
2415 // Load the key. | 2426 // Load the key. |
2416 VisitForAccumulatorValue(key); | 2427 VisitForAccumulatorValue(key); |
2417 | 2428 |
2418 Expression* callee = expr->expression(); | 2429 Expression* callee = expr->expression(); |
2419 | 2430 |
2420 // Load the function from the receiver. | 2431 // Load the function from the receiver. |
2421 DCHECK(callee->IsProperty()); | 2432 DCHECK(callee->IsProperty()); |
2422 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); | 2433 __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); |
2423 __ Move(LoadDescriptor::NameRegister(), v0); | 2434 __ Move(LoadDescriptor::NameRegister(), v0); |
2424 EmitKeyedPropertyLoad(callee->AsProperty()); | 2435 EmitKeyedPropertyLoad(callee->AsProperty()); |
2425 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2436 PrepareForBailoutForId(callee->AsProperty()->LoadId(), |
| 2437 BailoutState::TOS_REGISTER); |
2426 | 2438 |
2427 // Push the target function under the receiver. | 2439 // Push the target function under the receiver. |
2428 __ ld(at, MemOperand(sp, 0)); | 2440 __ ld(at, MemOperand(sp, 0)); |
2429 PushOperand(at); | 2441 PushOperand(at); |
2430 __ sd(v0, MemOperand(sp, kPointerSize)); | 2442 __ sd(v0, MemOperand(sp, kPointerSize)); |
2431 | 2443 |
2432 EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); | 2444 EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); |
2433 } | 2445 } |
2434 | 2446 |
2435 | 2447 |
(...skipping 13 matching lines...) Expand all Loading... |
2449 PushOperands(scratch, v0, v0, scratch); | 2461 PushOperands(scratch, v0, v0, scratch); |
2450 VisitForStackValue(prop->key()); | 2462 VisitForStackValue(prop->key()); |
2451 | 2463 |
2452 // Stack here: | 2464 // Stack here: |
2453 // - home_object | 2465 // - home_object |
2454 // - this (receiver) | 2466 // - this (receiver) |
2455 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. | 2467 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
2456 // - home_object | 2468 // - home_object |
2457 // - key | 2469 // - key |
2458 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); | 2470 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); |
2459 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 2471 PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER); |
2460 | 2472 |
2461 // Replace home_object with target function. | 2473 // Replace home_object with target function. |
2462 __ sd(v0, MemOperand(sp, kPointerSize)); | 2474 __ sd(v0, MemOperand(sp, kPointerSize)); |
2463 | 2475 |
2464 // Stack here: | 2476 // Stack here: |
2465 // - target function | 2477 // - target function |
2466 // - this (receiver) | 2478 // - this (receiver) |
2467 EmitCall(expr); | 2479 EmitCall(expr); |
2468 } | 2480 } |
2469 | 2481 |
2470 | 2482 |
2471 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { | 2483 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
2472 // Load the arguments. | 2484 // Load the arguments. |
2473 ZoneList<Expression*>* args = expr->arguments(); | 2485 ZoneList<Expression*>* args = expr->arguments(); |
2474 int arg_count = args->length(); | 2486 int arg_count = args->length(); |
2475 for (int i = 0; i < arg_count; i++) { | 2487 for (int i = 0; i < arg_count; i++) { |
2476 VisitForStackValue(args->at(i)); | 2488 VisitForStackValue(args->at(i)); |
2477 } | 2489 } |
2478 | 2490 |
2479 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2491 PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS); |
2480 // Record source position of the IC call. | 2492 // Record source position of the IC call. |
2481 SetCallPosition(expr, expr->tail_call_mode()); | 2493 SetCallPosition(expr, expr->tail_call_mode()); |
2482 if (expr->tail_call_mode() == TailCallMode::kAllow) { | 2494 if (expr->tail_call_mode() == TailCallMode::kAllow) { |
2483 if (FLAG_trace) { | 2495 if (FLAG_trace) { |
2484 __ CallRuntime(Runtime::kTraceTailCall); | 2496 __ CallRuntime(Runtime::kTraceTailCall); |
2485 } | 2497 } |
2486 // Update profiling counters before the tail call since we will | 2498 // Update profiling counters before the tail call since we will |
2487 // not return to this function. | 2499 // not return to this function. |
2488 EmitProfilingCounterHandlingForReturnSequence(true); | 2500 EmitProfilingCounterHandlingForReturnSequence(true); |
2489 } | 2501 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2539 // Generate code for loading from variables potentially shadowed by | 2551 // Generate code for loading from variables potentially shadowed by |
2540 // eval-introduced variables. | 2552 // eval-introduced variables. |
2541 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); | 2553 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); |
2542 | 2554 |
2543 __ bind(&slow); | 2555 __ bind(&slow); |
2544 // Call the runtime to find the function to call (returned in v0) | 2556 // Call the runtime to find the function to call (returned in v0) |
2545 // and the object holding it (returned in v1). | 2557 // and the object holding it (returned in v1). |
2546 __ Push(callee->name()); | 2558 __ Push(callee->name()); |
2547 __ CallRuntime(Runtime::kLoadLookupSlotForCall); | 2559 __ CallRuntime(Runtime::kLoadLookupSlotForCall); |
2548 PushOperands(v0, v1); // Function, receiver. | 2560 PushOperands(v0, v1); // Function, receiver. |
2549 PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); | 2561 PrepareForBailoutForId(expr->LookupId(), BailoutState::NO_REGISTERS); |
2550 | 2562 |
2551 // If fast case code has been generated, emit code to push the | 2563 // If fast case code has been generated, emit code to push the |
2552 // function and receiver and have the slow path jump around this | 2564 // function and receiver and have the slow path jump around this |
2553 // code. | 2565 // code. |
2554 if (done.is_linked()) { | 2566 if (done.is_linked()) { |
2555 Label call; | 2567 Label call; |
2556 __ Branch(&call); | 2568 __ Branch(&call); |
2557 __ bind(&done); | 2569 __ bind(&done); |
2558 // Push function. | 2570 // Push function. |
2559 __ push(v0); | 2571 __ push(v0); |
(...skipping 27 matching lines...) Expand all Loading... |
2587 | 2599 |
2588 // Push a copy of the function (found below the arguments) and | 2600 // Push a copy of the function (found below the arguments) and |
2589 // resolve eval. | 2601 // resolve eval. |
2590 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2602 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
2591 __ push(a1); | 2603 __ push(a1); |
2592 EmitResolvePossiblyDirectEval(expr); | 2604 EmitResolvePossiblyDirectEval(expr); |
2593 | 2605 |
2594 // Touch up the stack with the resolved function. | 2606 // Touch up the stack with the resolved function. |
2595 __ sd(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2607 __ sd(v0, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
2596 | 2608 |
2597 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2609 PrepareForBailoutForId(expr->EvalId(), BailoutState::NO_REGISTERS); |
2598 // Record source position for debugger. | 2610 // Record source position for debugger. |
2599 SetCallPosition(expr); | 2611 SetCallPosition(expr); |
2600 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2612 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
2601 __ li(a0, Operand(arg_count)); | 2613 __ li(a0, Operand(arg_count)); |
2602 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2614 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
2603 expr->tail_call_mode()), | 2615 expr->tail_call_mode()), |
2604 RelocInfo::CODE_TARGET); | 2616 RelocInfo::CODE_TARGET); |
2605 OperandStackDepthDecrement(arg_count + 1); | 2617 OperandStackDepthDecrement(arg_count + 1); |
2606 RecordJSReturnSite(expr); | 2618 RecordJSReturnSite(expr); |
2607 RestoreContext(); | 2619 RestoreContext(); |
(...skipping 28 matching lines...) Expand all Loading... |
2636 __ li(a0, Operand(arg_count)); | 2648 __ li(a0, Operand(arg_count)); |
2637 __ ld(a1, MemOperand(sp, arg_count * kPointerSize)); | 2649 __ ld(a1, MemOperand(sp, arg_count * kPointerSize)); |
2638 | 2650 |
2639 // Record call targets in unoptimized code. | 2651 // Record call targets in unoptimized code. |
2640 __ EmitLoadTypeFeedbackVector(a2); | 2652 __ EmitLoadTypeFeedbackVector(a2); |
2641 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 2653 __ li(a3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
2642 | 2654 |
2643 CallConstructStub stub(isolate()); | 2655 CallConstructStub stub(isolate()); |
2644 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); | 2656 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); |
2645 OperandStackDepthDecrement(arg_count + 1); | 2657 OperandStackDepthDecrement(arg_count + 1); |
2646 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2658 PrepareForBailoutForId(expr->ReturnId(), BailoutState::TOS_REGISTER); |
2647 RestoreContext(); | 2659 RestoreContext(); |
2648 context()->Plug(v0); | 2660 context()->Plug(v0); |
2649 } | 2661 } |
2650 | 2662 |
2651 | 2663 |
2652 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 2664 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
2653 SuperCallReference* super_call_ref = | 2665 SuperCallReference* super_call_ref = |
2654 expr->expression()->AsSuperCallReference(); | 2666 expr->expression()->AsSuperCallReference(); |
2655 DCHECK_NOT_NULL(super_call_ref); | 2667 DCHECK_NOT_NULL(super_call_ref); |
2656 | 2668 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 } | 3096 } |
3085 | 3097 |
3086 | 3098 |
3087 void FullCodeGenerator::EmitCall(CallRuntime* expr) { | 3099 void FullCodeGenerator::EmitCall(CallRuntime* expr) { |
3088 ZoneList<Expression*>* args = expr->arguments(); | 3100 ZoneList<Expression*>* args = expr->arguments(); |
3089 DCHECK_LE(2, args->length()); | 3101 DCHECK_LE(2, args->length()); |
3090 // Push target, receiver and arguments onto the stack. | 3102 // Push target, receiver and arguments onto the stack. |
3091 for (Expression* const arg : *args) { | 3103 for (Expression* const arg : *args) { |
3092 VisitForStackValue(arg); | 3104 VisitForStackValue(arg); |
3093 } | 3105 } |
3094 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 3106 PrepareForBailoutForId(expr->CallId(), BailoutState::NO_REGISTERS); |
3095 // Move target to a1. | 3107 // Move target to a1. |
3096 int const argc = args->length() - 2; | 3108 int const argc = args->length() - 2; |
3097 __ ld(a1, MemOperand(sp, (argc + 1) * kPointerSize)); | 3109 __ ld(a1, MemOperand(sp, (argc + 1) * kPointerSize)); |
3098 // Call the target. | 3110 // Call the target. |
3099 __ li(a0, Operand(argc)); | 3111 __ li(a0, Operand(argc)); |
3100 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 3112 __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
3101 OperandStackDepthDecrement(argc + 1); | 3113 OperandStackDepthDecrement(argc + 1); |
3102 RestoreContext(); | 3114 RestoreContext(); |
3103 // Discard the function left on TOS. | 3115 // Discard the function left on TOS. |
3104 context()->DropAndPlug(1, v0); | 3116 context()->DropAndPlug(1, v0); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3295 // because we need to prepare a pair of extra administrative AST ids | 3307 // because we need to prepare a pair of extra administrative AST ids |
3296 // for the optimizing compiler. | 3308 // for the optimizing compiler. |
3297 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); | 3309 DCHECK(context()->IsAccumulatorValue() || context()->IsStackValue()); |
3298 Label materialize_true, materialize_false, done; | 3310 Label materialize_true, materialize_false, done; |
3299 VisitForControl(expr->expression(), | 3311 VisitForControl(expr->expression(), |
3300 &materialize_false, | 3312 &materialize_false, |
3301 &materialize_true, | 3313 &materialize_true, |
3302 &materialize_true); | 3314 &materialize_true); |
3303 if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1); | 3315 if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1); |
3304 __ bind(&materialize_true); | 3316 __ bind(&materialize_true); |
3305 PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS); | 3317 PrepareForBailoutForId(expr->MaterializeTrueId(), |
| 3318 BailoutState::NO_REGISTERS); |
3306 __ LoadRoot(v0, Heap::kTrueValueRootIndex); | 3319 __ LoadRoot(v0, Heap::kTrueValueRootIndex); |
3307 if (context()->IsStackValue()) __ push(v0); | 3320 if (context()->IsStackValue()) __ push(v0); |
3308 __ jmp(&done); | 3321 __ jmp(&done); |
3309 __ bind(&materialize_false); | 3322 __ bind(&materialize_false); |
3310 PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS); | 3323 PrepareForBailoutForId(expr->MaterializeFalseId(), |
| 3324 BailoutState::NO_REGISTERS); |
3311 __ LoadRoot(v0, Heap::kFalseValueRootIndex); | 3325 __ LoadRoot(v0, Heap::kFalseValueRootIndex); |
3312 if (context()->IsStackValue()) __ push(v0); | 3326 if (context()->IsStackValue()) __ push(v0); |
3313 __ bind(&done); | 3327 __ bind(&done); |
3314 } | 3328 } |
3315 break; | 3329 break; |
3316 } | 3330 } |
3317 | 3331 |
3318 case Token::TYPEOF: { | 3332 case Token::TYPEOF: { |
3319 Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)"); | 3333 Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)"); |
3320 { | 3334 { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3400 } | 3414 } |
3401 | 3415 |
3402 case VARIABLE: | 3416 case VARIABLE: |
3403 UNREACHABLE(); | 3417 UNREACHABLE(); |
3404 } | 3418 } |
3405 } | 3419 } |
3406 | 3420 |
3407 // We need a second deoptimization point after loading the value | 3421 // We need a second deoptimization point after loading the value |
3408 // in case evaluating the property load my have a side effect. | 3422 // in case evaluating the property load my have a side effect. |
3409 if (assign_type == VARIABLE) { | 3423 if (assign_type == VARIABLE) { |
3410 PrepareForBailout(expr->expression(), TOS_REG); | 3424 PrepareForBailout(expr->expression(), BailoutState::TOS_REGISTER); |
3411 } else { | 3425 } else { |
3412 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 3426 PrepareForBailoutForId(prop->LoadId(), BailoutState::TOS_REGISTER); |
3413 } | 3427 } |
3414 | 3428 |
3415 // Inline smi case if we are in a loop. | 3429 // Inline smi case if we are in a loop. |
3416 Label stub_call, done; | 3430 Label stub_call, done; |
3417 JumpPatchSite patch_site(masm_); | 3431 JumpPatchSite patch_site(masm_); |
3418 | 3432 |
3419 int count_value = expr->op() == Token::INC ? 1 : -1; | 3433 int count_value = expr->op() == Token::INC ? 1 : -1; |
3420 __ mov(a0, v0); | 3434 __ mov(a0, v0); |
3421 if (ShouldInlineSmiCase(expr->op())) { | 3435 if (ShouldInlineSmiCase(expr->op())) { |
3422 Label slow; | 3436 Label slow; |
(...skipping 30 matching lines...) Expand all Loading... |
3453 __ DaddBranchNoOvf(v0, v0, Operand(scratch1), &done); | 3467 __ DaddBranchNoOvf(v0, v0, Operand(scratch1), &done); |
3454 // Call stub. Undo operation first. | 3468 // Call stub. Undo operation first. |
3455 __ Move(v0, a0); | 3469 __ Move(v0, a0); |
3456 __ jmp(&stub_call); | 3470 __ jmp(&stub_call); |
3457 __ bind(&slow); | 3471 __ bind(&slow); |
3458 } | 3472 } |
3459 | 3473 |
3460 // Convert old value into a number. | 3474 // Convert old value into a number. |
3461 ToNumberStub convert_stub(isolate()); | 3475 ToNumberStub convert_stub(isolate()); |
3462 __ CallStub(&convert_stub); | 3476 __ CallStub(&convert_stub); |
3463 PrepareForBailoutForId(expr->ToNumberId(), TOS_REG); | 3477 PrepareForBailoutForId(expr->ToNumberId(), BailoutState::TOS_REGISTER); |
3464 | 3478 |
3465 // Save result for postfix expressions. | 3479 // Save result for postfix expressions. |
3466 if (expr->is_postfix()) { | 3480 if (expr->is_postfix()) { |
3467 if (!context()->IsEffect()) { | 3481 if (!context()->IsEffect()) { |
3468 // Save the result on the stack. If we have a named or keyed property | 3482 // Save the result on the stack. If we have a named or keyed property |
3469 // we store the result under the receiver that is currently on top | 3483 // we store the result under the receiver that is currently on top |
3470 // of the stack. | 3484 // of the stack. |
3471 switch (assign_type) { | 3485 switch (assign_type) { |
3472 case VARIABLE: | 3486 case VARIABLE: |
3473 PushOperand(v0); | 3487 PushOperand(v0); |
(...skipping 25 matching lines...) Expand all Loading... |
3499 patch_site.EmitPatchInfo(); | 3513 patch_site.EmitPatchInfo(); |
3500 __ bind(&done); | 3514 __ bind(&done); |
3501 | 3515 |
3502 // Store the value returned in v0. | 3516 // Store the value returned in v0. |
3503 switch (assign_type) { | 3517 switch (assign_type) { |
3504 case VARIABLE: | 3518 case VARIABLE: |
3505 if (expr->is_postfix()) { | 3519 if (expr->is_postfix()) { |
3506 { EffectContext context(this); | 3520 { EffectContext context(this); |
3507 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3521 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3508 Token::ASSIGN, expr->CountSlot()); | 3522 Token::ASSIGN, expr->CountSlot()); |
3509 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3523 PrepareForBailoutForId(expr->AssignmentId(), |
| 3524 BailoutState::TOS_REGISTER); |
3510 context.Plug(v0); | 3525 context.Plug(v0); |
3511 } | 3526 } |
3512 // For all contexts except EffectConstant we have the result on | 3527 // For all contexts except EffectConstant we have the result on |
3513 // top of the stack. | 3528 // top of the stack. |
3514 if (!context()->IsEffect()) { | 3529 if (!context()->IsEffect()) { |
3515 context()->PlugTOS(); | 3530 context()->PlugTOS(); |
3516 } | 3531 } |
3517 } else { | 3532 } else { |
3518 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3533 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
3519 Token::ASSIGN, expr->CountSlot()); | 3534 Token::ASSIGN, expr->CountSlot()); |
3520 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3535 PrepareForBailoutForId(expr->AssignmentId(), |
| 3536 BailoutState::TOS_REGISTER); |
3521 context()->Plug(v0); | 3537 context()->Plug(v0); |
3522 } | 3538 } |
3523 break; | 3539 break; |
3524 case NAMED_PROPERTY: { | 3540 case NAMED_PROPERTY: { |
3525 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 3541 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
3526 __ li(StoreDescriptor::NameRegister(), | 3542 __ li(StoreDescriptor::NameRegister(), |
3527 Operand(prop->key()->AsLiteral()->value())); | 3543 Operand(prop->key()->AsLiteral()->value())); |
3528 PopOperand(StoreDescriptor::ReceiverRegister()); | 3544 PopOperand(StoreDescriptor::ReceiverRegister()); |
3529 EmitLoadStoreICSlot(expr->CountSlot()); | 3545 EmitLoadStoreICSlot(expr->CountSlot()); |
3530 CallStoreIC(); | 3546 CallStoreIC(); |
3531 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3547 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3532 if (expr->is_postfix()) { | 3548 if (expr->is_postfix()) { |
3533 if (!context()->IsEffect()) { | 3549 if (!context()->IsEffect()) { |
3534 context()->PlugTOS(); | 3550 context()->PlugTOS(); |
3535 } | 3551 } |
3536 } else { | 3552 } else { |
3537 context()->Plug(v0); | 3553 context()->Plug(v0); |
3538 } | 3554 } |
3539 break; | 3555 break; |
3540 } | 3556 } |
3541 case NAMED_SUPER_PROPERTY: { | 3557 case NAMED_SUPER_PROPERTY: { |
(...skipping 19 matching lines...) Expand all Loading... |
3561 break; | 3577 break; |
3562 } | 3578 } |
3563 case KEYED_PROPERTY: { | 3579 case KEYED_PROPERTY: { |
3564 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 3580 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
3565 PopOperands(StoreDescriptor::ReceiverRegister(), | 3581 PopOperands(StoreDescriptor::ReceiverRegister(), |
3566 StoreDescriptor::NameRegister()); | 3582 StoreDescriptor::NameRegister()); |
3567 Handle<Code> ic = | 3583 Handle<Code> ic = |
3568 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | 3584 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
3569 EmitLoadStoreICSlot(expr->CountSlot()); | 3585 EmitLoadStoreICSlot(expr->CountSlot()); |
3570 CallIC(ic); | 3586 CallIC(ic); |
3571 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 3587 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3572 if (expr->is_postfix()) { | 3588 if (expr->is_postfix()) { |
3573 if (!context()->IsEffect()) { | 3589 if (!context()->IsEffect()) { |
3574 context()->PlugTOS(); | 3590 context()->PlugTOS(); |
3575 } | 3591 } |
3576 } else { | 3592 } else { |
3577 context()->Plug(v0); | 3593 context()->Plug(v0); |
3578 } | 3594 } |
3579 break; | 3595 break; |
3580 } | 3596 } |
3581 } | 3597 } |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3952 reinterpret_cast<uint64_t>( | 3968 reinterpret_cast<uint64_t>( |
3953 isolate->builtins()->OnStackReplacement()->entry())); | 3969 isolate->builtins()->OnStackReplacement()->entry())); |
3954 return ON_STACK_REPLACEMENT; | 3970 return ON_STACK_REPLACEMENT; |
3955 } | 3971 } |
3956 | 3972 |
3957 | 3973 |
3958 } // namespace internal | 3974 } // namespace internal |
3959 } // namespace v8 | 3975 } // namespace v8 |
3960 | 3976 |
3961 #endif // V8_TARGET_ARCH_MIPS64 | 3977 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |