Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/ia32/macro-assembler-ia32.h

Issue 6824078: Move most of the incremental marking write barrier to generated code. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Forward declaration. 52 // Forward declaration.
53 class JumpTarget; 53 class JumpTarget;
54 class PostCallGenerator; 54 class PostCallGenerator;
55 55
56 enum EmitRememberedSet { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; 56 enum EmitRememberedSet { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET };
57 enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; 57 enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK };
58 enum ObjectMode { PRESERVE_OBJECT, DESTROY_OBJECT }; 58 enum ObjectMode { PRESERVE_OBJECT, DESTROY_OBJECT };
59 enum ValueMode { PRESERVE_VALUE, DESTROY_VALUE }; 59 enum ValueMode { PRESERVE_VALUE, DESTROY_VALUE };
60 enum AddressMode { PRESERVE_ADDRESS, DESTROY_ADDRESS }; 60 enum AddressMode { PRESERVE_ADDRESS, DESTROY_ADDRESS };
61 61
62 bool Aliasing(Register r1, Register r2, Register r3, Register r4);
63
62 // MacroAssembler implements a collection of frequently used macros. 64 // MacroAssembler implements a collection of frequently used macros.
63 class MacroAssembler: public Assembler { 65 class MacroAssembler: public Assembler {
64 public: 66 public:
65 MacroAssembler(void* buffer, int size); 67 MacroAssembler(void* buffer, int size);
66 68
67 // --------------------------------------------------------------------------- 69 // ---------------------------------------------------------------------------
68 // GC Support 70 // GC Support
69 71
70 void IncrementalMarkingRecordWriteHelper(Register object, 72 void IncrementalMarkingRecordWriteHelper(Register object,
71 Register value, 73 Register value,
72 Register address); 74 Register address);
73 75
74 // For page containing |object| mark region covering |addr| dirty. 76 // For page containing |object| mark region covering |addr| dirty.
75 // RememberedSetHelper only works if the object is not in new 77 // RememberedSetHelper only works if the object is not in new
76 // space. 78 // space.
77 void RememberedSetHelper(Register object, 79 void RememberedSetHelper(Register addr,
78 Register addr,
79 Register scratch, 80 Register scratch,
80 SaveFPRegsMode save_fp); 81 SaveFPRegsMode save_fp);
81 82
82 // Check if object is in new space. 83 // Check if object is in new space.
83 // scratch can be object itself, but it will be clobbered. 84 // scratch can be object itself, but it will be clobbered.
84 template <typename LabelType> 85 template <typename LabelType>
85 void InNewSpace(Register object, 86 void InNewSpace(Register object,
86 Register scratch, 87 Register scratch,
87 Condition cc, // equal for new space, not_equal otherwise. 88 Condition cc, // equal for new space, not_equal otherwise.
88 LabelType* branch); 89 LabelType* branch);
89 90
90 // For page containing |object| mark region covering [object+offset] 91 // Check if old-space object is on a scan-on-scavenge page.
91 // dirty. |object| is the object being stored into, |value| is the 92 template <typename LabelType>
92 // object being stored. If offset is zero, then the scratch register 93 void HasScanOnScavenge(Register object,
93 // contains the array index into the elements array represented as a 94 Register scratch,
94 // Smi. All registers are clobbered by the operation. RecordWrite 95 LabelType* scan_on_scavenge);
96
97 // Check if an object has a given incremental marking colour. Also uses ecx!
98 // The colour bits are found by splitting the address at the bit offset
99 // indicated by the mask: bits that are zero in the mask are used for the
100 // address of the bitmap, and bits that are one in the mask are used for the
101 // index of the bit.
102 template <typename LabelType>
103 void HasColour(Register object,
104 Register scratch0,
105 Register scratch1,
106 LabelType* has_colour,
107 uint32_t mask,
108 int header_size,
109 int first_bit,
110 int second_bit,
111 bool in_new_space);
112
113 template <typename LabelType>
114 void InOldSpaceIsBlack(Register object,
115 Register scratch0,
116 Register scratch1,
117 LabelType* is_black);
118
119 template <typename LabelType>
120 void InNewSpaceIsBlack(Register object,
121 Register scratch0,
122 Register scratch1,
123 LabelType* is_black);
124
125 // Checks the colour of an object. If the object is already grey or black
126 // then we just fall through, since it is already live. If it is white and
127 // we can determine that it doesn't need to be scanned, then we just mark it
128 // black and fall through. For the rest we jump to the label so the
129 // incremental marker can fix its assumptions.
130 template <typename LabelType>
131 void EnsureNotWhite(Register object,
132 Register scratch1,
133 Register scratch2,
134 LabelType* object_is_white_and_not_data,
135 bool in_new_space);
136
137 // Checks whether an object is data-only, ie it does need to be scanned by the
138 // garbage collector.
139 template <typename LabelType>
140 void IsDataObject(Register value,
141 Register scratch,
142 LabelType* not_data_object,
143 bool in_new_space);
144
145 // Notify the garbage collector that we wrote a pointer into an object.
146 // |object| is the object being stored into, |value| is the object being
147 // stored. All registers are clobbered by the operation. RecordWriteField
148 // filters out smis so it does not update the write barrier if the value is a
149 // smi. The offset is the offset from the start of the object, not the offset
150 // from the tagged HeapObject pointer. For use with FieldOperand(reg, off).
151 void RecordWriteField(Register object,
152 int offset,
153 Register value,
154 Register scratch,
155 SaveFPRegsMode save_fp);
156
157 // As above, but the offset has the tag presubtracted. For use with
158 // Operand(reg, off).
159 inline void RecordWriteContextSlot(Register context,
160 int offset,
161 Register value,
162 Register scratch,
163 SaveFPRegsMode save_fp) {
164 RecordWriteField(context,
165 offset + kHeapObjectTag,
166 value,
167 scratch,
168 save_fp);
169 }
170
171
172
173
174 // Notify the garbage collector that we wrote a pointer into a fixed array.
175 // |array| is the array being stored into, |value| is the
176 // object being stored. |index| is the array index represented as a
177 // Smi. All registers are clobbered by the operation RecordWriteArray
95 // filters out smis so it does not update the write barrier if the 178 // filters out smis so it does not update the write barrier if the
96 // value is a smi. 179 // value is a smi.
97 void RecordWrite(Register object, 180 void RecordWriteArray(Register array,
98 int offset, 181 Register value,
99 Register value, 182 Register index,
100 Register scratch, 183 SaveFPRegsMode save_fp);
101 SaveFPRegsMode save_fp);
102 184
103 // For page containing |object| mark region covering |address| 185 // For page containing |object| mark region covering |address|
104 // dirty. |object| is the object being stored into, |value| is the 186 // dirty. |object| is the object being stored into, |value| is the
105 // object being stored. All registers are clobbered by the 187 // object being stored. All registers are clobbered by the
106 // operation. RecordWrite filters out smis so it does not update the 188 // operation. RecordWrite filters out smis so it does not update the
107 // write barrier if the value is a smi. 189 // write barrier if the value is a smi.
108 void RecordWrite(Register object, 190 void RecordWrite(Register object,
109 Register address, 191 Register address,
110 Register value, 192 Register value,
111 EmitRememberedSet emit_remembered_set, 193 EmitRememberedSet emit_remembered_set,
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 AllocationFlags flags); 762 AllocationFlags flags);
681 void UpdateAllocationTopHelper(Register result_end, Register scratch); 763 void UpdateAllocationTopHelper(Register result_end, Register scratch);
682 764
683 // Helper for PopHandleScope. Allowed to perform a GC and returns 765 // Helper for PopHandleScope. Allowed to perform a GC and returns
684 // NULL if gc_allowed. Does not perform a GC if !gc_allowed, and 766 // NULL if gc_allowed. Does not perform a GC if !gc_allowed, and
685 // possibly returns a failure object indicating an allocation failure. 767 // possibly returns a failure object indicating an allocation failure.
686 MUST_USE_RESULT MaybeObject* PopHandleScopeHelper(Register saved, 768 MUST_USE_RESULT MaybeObject* PopHandleScopeHelper(Register saved,
687 Register scratch, 769 Register scratch,
688 bool gc_allowed); 770 bool gc_allowed);
689 771
772 // Helper for finding the mark bits for an address. Afterwards, the
773 // bitmap register points at the word with the mark bits and the mask
774 // the position of the first bit. Uses ecx as scratch and leaves addr_reg
775 // unchanged.
776 inline void MarkBits(Register addr_reg,
777 Register bitmap_reg,
778 Register mask_reg,
779 int32_t high_mask,
780 bool in_new_space);
690 781
691 // Compute memory operands for safepoint stack slots. 782 // Compute memory operands for safepoint stack slots.
692 Operand SafepointRegisterSlot(Register reg); 783 Operand SafepointRegisterSlot(Register reg);
693 static int SafepointRegisterStackIndex(int reg_code); 784 static int SafepointRegisterStackIndex(int reg_code);
694 785
695 // Needs access to SafepointRegisterStackIndex for optimized frame 786 // Needs access to SafepointRegisterStackIndex for optimized frame
696 // traversal. 787 // traversal.
697 friend class OptimizedFrame; 788 friend class OptimizedFrame;
698 }; 789 };
699 790
700 791
701 template <typename LabelType> 792 template <typename LabelType>
702 void MacroAssembler::InNewSpace(Register object, 793 void MacroAssembler::InNewSpace(Register object,
703 Register scratch, 794 Register scratch,
704 Condition cc, 795 Condition cc,
705 LabelType* branch) { 796 LabelType* branch) {
706 ASSERT(cc == equal || cc == not_equal); 797 ASSERT(cc == equal || cc == not_equal);
707 if (Serializer::enabled()) { 798 if (Serializer::enabled()) {
708 // Can't do arithmetic on external references if it might get serialized. 799 // Can't do arithmetic on external references if it might get serialized.
709 mov(scratch, Operand(object)); 800 Move(scratch, object);
710 // The mask isn't really an address. We load it as an external reference in 801 // The mask isn't really an address. We load it as an external reference in
711 // case the size of the new space is different between the snapshot maker 802 // case the size of the new space is different between the snapshot maker
712 // and the running system. 803 // and the running system.
713 and_(Operand(scratch), Immediate(ExternalReference::new_space_mask())); 804 and_(Operand(scratch), Immediate(ExternalReference::new_space_mask()));
714 cmp(Operand(scratch), Immediate(ExternalReference::new_space_start())); 805 cmp(Operand(scratch), Immediate(ExternalReference::new_space_start()));
715 j(cc, branch); 806 j(cc, branch);
716 } else { 807 } else {
717 int32_t new_space_start = reinterpret_cast<int32_t>( 808 int32_t new_space_start = reinterpret_cast<int32_t>(
718 ExternalReference::new_space_start().address()); 809 ExternalReference::new_space_start().address());
719 lea(scratch, Operand(object, -new_space_start)); 810 if (object.is(scratch)) {
811 sub(Operand(scratch), Immediate(new_space_start));
812 } else {
813 lea(scratch, Operand(object, -new_space_start));
814 }
720 and_(scratch, HEAP->NewSpaceMask()); 815 and_(scratch, HEAP->NewSpaceMask());
721 j(cc, branch); 816 j(cc, branch);
722 } 817 }
723 } 818 }
724 819
725 820
726 // The code patcher is used to patch (typically) small parts of code e.g. for 821 // The code patcher is used to patch (typically) small parts of code e.g. for
727 // debugging and other types of instrumentation. When using the code patcher 822 // debugging and other types of instrumentation. When using the code patcher
728 // the exact number of bytes specified must be emitted. Is not legal to emit 823 // the exact number of bytes specified must be emitted. Is not legal to emit
729 // relocation information. If any of these constraints are violated it causes 824 // relocation information. If any of these constraints are violated it causes
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } \ 899 } \
805 masm-> 900 masm->
806 #else 901 #else
807 #define ACCESS_MASM(masm) masm-> 902 #define ACCESS_MASM(masm) masm->
808 #endif 903 #endif
809 904
810 905
811 } } // namespace v8::internal 906 } } // namespace v8::internal
812 907
813 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ 908 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698