| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE)); | 554 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE)); |
| 555 } | 555 } |
| 556 | 556 |
| 557 | 557 |
| 558 LOperand* LChunkBuilder::UseAtStart(HValue* value) { | 558 LOperand* LChunkBuilder::UseAtStart(HValue* value) { |
| 559 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE, | 559 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE, |
| 560 LUnallocated::USED_AT_START)); | 560 LUnallocated::USED_AT_START)); |
| 561 } | 561 } |
| 562 | 562 |
| 563 | 563 |
| 564 static inline bool CanBeImmediateConstant(HValue* value) { |
| 565 return value->IsConstant() && HConstant::cast(value)->NotInNewSpace(); |
| 566 } |
| 567 |
| 568 |
| 564 LOperand* LChunkBuilder::UseOrConstant(HValue* value) { | 569 LOperand* LChunkBuilder::UseOrConstant(HValue* value) { |
| 565 return value->IsConstant() | 570 return CanBeImmediateConstant(value) |
| 566 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | 571 ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 567 : Use(value); | 572 : Use(value); |
| 568 } | 573 } |
| 569 | 574 |
| 570 | 575 |
| 571 LOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) { | 576 LOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) { |
| 572 return value->IsConstant() | 577 return CanBeImmediateConstant(value) |
| 573 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | 578 ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 574 : UseAtStart(value); | 579 : UseAtStart(value); |
| 575 } | 580 } |
| 576 | 581 |
| 577 | 582 |
| 578 LOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) { | 583 LOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) { |
| 579 return value->IsConstant() | 584 return CanBeImmediateConstant(value) |
| 580 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | 585 ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 581 : UseRegister(value); | 586 : UseRegister(value); |
| 582 } | 587 } |
| 583 | 588 |
| 584 | 589 |
| 585 LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { | 590 LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { |
| 586 return value->IsConstant() | 591 return CanBeImmediateConstant(value) |
| 587 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | 592 ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 588 : UseRegisterAtStart(value); | 593 : UseRegisterAtStart(value); |
| 589 } | 594 } |
| 590 | 595 |
| 591 | 596 |
| 592 LOperand* LChunkBuilder::UseConstant(HValue* value) { | 597 LOperand* LChunkBuilder::UseConstant(HValue* value) { |
| 593 return chunk_->DefineConstantOperand(HConstant::cast(value)); | 598 return chunk_->DefineConstantOperand(HConstant::cast(value)); |
| 594 } | 599 } |
| 595 | 600 |
| 596 | 601 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 if (needs_environment && !instr->HasEnvironment()) { | 706 if (needs_environment && !instr->HasEnvironment()) { |
| 702 instr = AssignEnvironment(instr); | 707 instr = AssignEnvironment(instr); |
| 703 } | 708 } |
| 704 | 709 |
| 705 return instr; | 710 return instr; |
| 706 } | 711 } |
| 707 | 712 |
| 708 | 713 |
| 709 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { | 714 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { |
| 710 ASSERT(!instr->HasPointerMap()); | 715 ASSERT(!instr->HasPointerMap()); |
| 711 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); | 716 instr->set_pointer_map(new(zone()) LPointerMap(zone())); |
| 712 return instr; | 717 return instr; |
| 713 } | 718 } |
| 714 | 719 |
| 715 | 720 |
| 716 LUnallocated* LChunkBuilder::TempRegister() { | 721 LUnallocated* LChunkBuilder::TempRegister() { |
| 717 LUnallocated* operand = | 722 LUnallocated* operand = |
| 718 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 723 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
| 719 int vreg = allocator_->GetVirtualRegister(); | 724 int vreg = allocator_->GetVirtualRegister(); |
| 720 if (!allocator_->AllocationOk()) { | 725 if (!allocator_->AllocationOk()) { |
| 721 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); | 726 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 } | 906 } |
| 902 block->set_argument_count(argument_count_); | 907 block->set_argument_count(argument_count_); |
| 903 next_block_ = NULL; | 908 next_block_ = NULL; |
| 904 current_block_ = NULL; | 909 current_block_ = NULL; |
| 905 } | 910 } |
| 906 | 911 |
| 907 | 912 |
| 908 void LChunkBuilder::VisitInstruction(HInstruction* current) { | 913 void LChunkBuilder::VisitInstruction(HInstruction* current) { |
| 909 HInstruction* old_current = current_instruction_; | 914 HInstruction* old_current = current_instruction_; |
| 910 current_instruction_ = current; | 915 current_instruction_ = current; |
| 911 if (current->has_position()) position_ = current->position(); | |
| 912 | 916 |
| 913 LInstruction* instr = NULL; | 917 LInstruction* instr = NULL; |
| 914 if (current->CanReplaceWithDummyUses()) { | 918 if (current->CanReplaceWithDummyUses()) { |
| 915 HValue* first_operand = current->OperandCount() == 0 | 919 HValue* first_operand = current->OperandCount() == 0 |
| 916 ? graph()->GetConstant1() | 920 ? graph()->GetConstant1() |
| 917 : current->OperandAt(0); | 921 : current->OperandAt(0); |
| 918 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand))); | 922 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand))); |
| 919 for (int i = 1; i < current->OperandCount(); ++i) { | 923 for (int i = 1; i < current->OperandCount(); ++i) { |
| 920 LInstruction* dummy = | 924 LInstruction* dummy = |
| 921 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); | 925 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; | 960 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; |
| 957 } | 961 } |
| 958 for (TempIterator it(instr); !it.Done(); it.Advance()) { | 962 for (TempIterator it(instr); !it.Done(); it.Advance()) { |
| 959 LUnallocated* operand = LUnallocated::cast(it.Current()); | 963 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 960 if (operand->HasFixedPolicy()) ++fixed; | 964 if (operand->HasFixedPolicy()) ++fixed; |
| 961 } | 965 } |
| 962 ASSERT(fixed == 0 || used_at_start == 0); | 966 ASSERT(fixed == 0 || used_at_start == 0); |
| 963 } | 967 } |
| 964 #endif | 968 #endif |
| 965 | 969 |
| 966 instr->set_position(position_); | |
| 967 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 970 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 968 instr = AssignPointerMap(instr); | 971 instr = AssignPointerMap(instr); |
| 969 } | 972 } |
| 970 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 973 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 971 instr = AssignEnvironment(instr); | 974 instr = AssignEnvironment(instr); |
| 972 } | 975 } |
| 973 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && instr->IsGoto() && | 976 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && instr->IsGoto() && |
| 974 LGoto::cast(instr)->jumps_to_join()) { | 977 LGoto::cast(instr)->jumps_to_join()) { |
| 975 // TODO(olivf) Since phis of spilled values are joined as registers | 978 // TODO(olivf) Since phis of spilled values are joined as registers |
| 976 // (not in the stack slot), we need to allow the goto gaps to keep one | 979 // (not in the stack slot), we need to allow the goto gaps to keep one |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 LOperand* value = UseRegister(instr->value()); | 1922 LOperand* value = UseRegister(instr->value()); |
| 1920 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1923 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1921 } | 1924 } |
| 1922 from = Representation::Tagged(); | 1925 from = Representation::Tagged(); |
| 1923 } | 1926 } |
| 1924 // Only mark conversions that might need to allocate as calling rather than | 1927 // Only mark conversions that might need to allocate as calling rather than |
| 1925 // all changes. This makes simple, non-allocating conversion not have to force | 1928 // all changes. This makes simple, non-allocating conversion not have to force |
| 1926 // building a stack frame. | 1929 // building a stack frame. |
| 1927 if (from.IsTagged()) { | 1930 if (from.IsTagged()) { |
| 1928 if (to.IsDouble()) { | 1931 if (to.IsDouble()) { |
| 1929 info()->MarkAsDeferredCalling(); | |
| 1930 LOperand* value = UseRegister(instr->value()); | 1932 LOperand* value = UseRegister(instr->value()); |
| 1931 // Temp register only necessary for minus zero check. | 1933 // Temp register only necessary for minus zero check. |
| 1932 LOperand* temp = TempRegister(); | 1934 LOperand* temp = TempRegister(); |
| 1933 LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp); | 1935 LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp); |
| 1934 return AssignEnvironment(DefineAsRegister(res)); | 1936 return AssignEnvironment(DefineAsRegister(res)); |
| 1935 } else if (to.IsSmi()) { | 1937 } else if (to.IsSmi()) { |
| 1936 HValue* val = instr->value(); | 1938 HValue* val = instr->value(); |
| 1937 LOperand* value = UseRegister(val); | 1939 LOperand* value = UseRegister(val); |
| 1938 if (val->type().IsSmi()) { | 1940 if (val->type().IsSmi()) { |
| 1939 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1941 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2730 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2732 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2731 LOperand* object = UseRegister(instr->object()); | 2733 LOperand* object = UseRegister(instr->object()); |
| 2732 LOperand* index = UseTempRegister(instr->index()); | 2734 LOperand* index = UseTempRegister(instr->index()); |
| 2733 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2735 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2734 } | 2736 } |
| 2735 | 2737 |
| 2736 | 2738 |
| 2737 } } // namespace v8::internal | 2739 } } // namespace v8::internal |
| 2738 | 2740 |
| 2739 #endif // V8_TARGET_ARCH_IA32 | 2741 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |