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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 HInstruction* argument = AddInstruction( | 592 HInstruction* argument = AddInstruction( |
593 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); | 593 new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); |
594 | 594 |
595 HConstant* max_alloc_length = | 595 HConstant* max_alloc_length = |
596 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); | 596 new(zone()) HConstant(JSObject::kInitialMaxFastElementArray); |
597 AddInstruction(max_alloc_length); | 597 AddInstruction(max_alloc_length); |
598 const int initial_capacity = JSArray::kPreallocatedArrayElements; | 598 const int initial_capacity = JSArray::kPreallocatedArrayElements; |
599 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); | 599 HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity); |
600 AddInstruction(initial_capacity_node); | 600 AddInstruction(initial_capacity_node); |
601 | 601 |
602 HBoundsCheck* checked_arg = AddBoundsCheck(argument, max_alloc_length); | 602 HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); |
603 IfBuilder if_builder(this); | 603 IfBuilder if_builder(this); |
604 if_builder.IfCompare(checked_arg, constant_zero, Token::EQ); | 604 if_builder.IfCompare(checked_arg, constant_zero, Token::EQ); |
605 if_builder.Then(); | 605 if_builder.Then(); |
606 Push(initial_capacity_node); // capacity | 606 Push(initial_capacity_node); // capacity |
607 Push(constant_zero); // length | 607 Push(constant_zero); // length |
608 if_builder.Else(); | 608 if_builder.Else(); |
609 Push(checked_arg); // capacity | 609 Push(checked_arg); // capacity |
610 Push(checked_arg); // length | 610 Push(checked_arg); // length |
611 if_builder.End(); | 611 if_builder.End(); |
612 | 612 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 } | 755 } |
756 | 756 |
757 | 757 |
758 template <> | 758 template <> |
759 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 759 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
760 ToBooleanStub* stub = casted_stub(); | 760 ToBooleanStub* stub = casted_stub(); |
761 | 761 |
762 IfBuilder if_true(this); | 762 IfBuilder if_true(this); |
763 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 763 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
764 if_true.Then(); | 764 if_true.Then(); |
765 if_true.Return(graph()->GetConstant1()); | 765 if_true.Return(graph()->GetConstant1()); |
766 if_true.Else(); | 766 if_true.Else(); |
767 if_true.End(); | 767 if_true.End(); |
768 return graph()->GetConstant0(); | 768 return graph()->GetConstant0(); |
769 } | 769 } |
770 | 770 |
771 | 771 |
772 Handle<Code> ToBooleanStub::GenerateCode() { | 772 Handle<Code> ToBooleanStub::GenerateCode() { |
773 return DoGenerateCode(this); | 773 return DoGenerateCode(this); |
774 } | 774 } |
775 | 775 |
776 | 776 |
| 777 template <> |
| 778 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { |
| 779 StoreGlobalStub* stub = casted_stub(); |
| 780 Handle<Object> hole = Handle<Object>(isolate()->heap()->the_hole_value(), |
| 781 isolate()); |
| 782 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); |
| 783 Handle<PropertyCell> placeholder_cell = |
| 784 isolate()->factory()->NewPropertyCell(placeholer_value); |
| 785 |
| 786 HParameter* receiver = GetParameter(0); |
| 787 HParameter* value = GetParameter(2); |
| 788 |
| 789 if (stub->is_constant()) { |
| 790 // Assume every store to a constant value changes it. |
| 791 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); |
| 792 set_current_block(NULL); |
| 793 } else { |
| 794 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); |
| 795 |
| 796 // Check that the map of the global has not changed. |
| 797 AddInstruction(HCheckMaps::New(receiver, |
| 798 Handle<Map>(isolate()->heap()->meta_map()), |
| 799 zone())); |
| 800 |
| 801 // Load the payload of the global parameter cell. A hole indicates that the |
| 802 // property has been deleted and that the store must be handled by the |
| 803 // runtime. |
| 804 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); |
| 805 HValue* cell_contents = Add<HLoadNamedField>(cell, access); |
| 806 IfBuilder builder(this); |
| 807 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); |
| 808 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
| 809 builder.Then(); |
| 810 builder.Deopt(); |
| 811 builder.Else(); |
| 812 Add<HStoreNamedField>(cell, access, value); |
| 813 builder.End(); |
| 814 } |
| 815 return value; |
| 816 } |
| 817 |
| 818 |
| 819 Handle<Code> StoreGlobalStub::GenerateCode() { |
| 820 return DoGenerateCode(this); |
| 821 } |
| 822 |
| 823 |
777 } } // namespace v8::internal | 824 } } // namespace v8::internal |
OLD | NEW |