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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 } | 764 } |
765 | 765 |
766 | 766 |
767 template <> | 767 template <> |
768 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 768 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
769 ToBooleanStub* stub = casted_stub(); | 769 ToBooleanStub* stub = casted_stub(); |
770 | 770 |
771 IfBuilder if_true(this); | 771 IfBuilder if_true(this); |
772 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 772 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
773 if_true.Then(); | 773 if_true.Then(); |
774 if_true.Return(graph()->GetConstant1()); | 774 if_true.Return(graph()->GetConstant1()); |
775 if_true.Else(); | 775 if_true.Else(); |
776 if_true.End(); | 776 if_true.End(); |
777 return graph()->GetConstant0(); | 777 return graph()->GetConstant0(); |
778 } | 778 } |
779 | 779 |
780 | 780 |
781 Handle<Code> ToBooleanStub::GenerateCode() { | 781 Handle<Code> ToBooleanStub::GenerateCode() { |
782 return DoGenerateCode(this); | 782 return DoGenerateCode(this); |
783 } | 783 } |
784 | 784 |
785 | 785 |
786 template <> | |
787 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { | |
788 StoreGlobalStub* stub = casted_stub(); | |
789 Handle<Object> hole(isolate()->heap()->the_hole_value(), isolate()); | |
790 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); | |
791 Handle<PropertyCell> placeholder_cell = | |
792 isolate()->factory()->NewPropertyCell(placeholer_value); | |
793 | |
794 HParameter* receiver = GetParameter(0); | |
795 HParameter* value = GetParameter(2); | |
796 | |
797 if (stub->is_constant()) { | |
798 // Assume every store to a constant value changes it. | |
799 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | |
800 set_current_block(NULL); | |
801 } else { | |
802 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); | |
803 // Check that the map of the global has not changed. | |
804 AddInstruction(HCheckMaps::New(receiver, | |
805 Handle<Map>(isolate()->heap()->meta_map()), | |
806 zone())); | |
807 | |
808 // Load the payload of the global parameter cell. A hole indicates that the | |
809 // property has been deleted and that the store must be handled by the | |
810 // runtime. | |
811 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); | |
812 HValue* cell_contents = Add<HLoadNamedField>(cell, access); | |
813 IfBuilder builder(this); | |
814 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); | |
815 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); | |
816 builder.Then(); | |
817 builder.Deopt(); | |
818 builder.Else(); | |
819 Add<HStoreNamedField>(cell, access, value); | |
820 builder.End(); | |
821 } | |
822 return value; | |
823 } | |
824 | |
825 | |
826 Handle<Code> StoreGlobalStub::GenerateCode() { | |
827 return DoGenerateCode(this); | |
828 } | |
829 | |
830 | |
831 } } // namespace v8::internal | 786 } } // namespace v8::internal |
OLD | NEW |