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