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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions)); | 51 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions)); |
52 if (!maybe_array->To(&array)) return maybe_array; | 52 if (!maybe_array->To(&array)) return maybe_array; |
53 | 53 |
54 array->set(kDescriptorsPointerIndex, descriptors_cell); | 54 array->set(kDescriptorsPointerIndex, descriptors_cell); |
55 array->set(kElementsTransitionIndex, Smi::FromInt(0)); | 55 array->set(kElementsTransitionIndex, Smi::FromInt(0)); |
56 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); | 56 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); |
57 return array; | 57 return array; |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 void TransitionArray::CopyFrom(TransitionArray* origin, | 61 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, |
62 int origin_transition, | 62 int origin_transition, |
63 int target_transition, | 63 int target_transition) { |
64 const WhitenessWitness& witness) { | 64 NoIncrementalWriteBarrierSet(target_transition, |
65 Set(target_transition, | 65 origin->GetKey(origin_transition), |
66 origin->GetKey(origin_transition), | 66 origin->GetTarget(origin_transition)); |
67 origin->GetTarget(origin_transition), | |
68 witness); | |
69 } | 67 } |
70 | 68 |
71 | 69 |
72 static bool InsertionPointFound(String* key1, String* key2) { | 70 static bool InsertionPointFound(String* key1, String* key2) { |
73 return key1->Hash() > key2->Hash(); | 71 return key1->Hash() > key2->Hash(); |
74 } | 72 } |
75 | 73 |
76 | 74 |
77 MaybeObject* TransitionArray::NewWith( | 75 MaybeObject* TransitionArray::NewWith( |
78 String* name, | 76 String* name, |
79 Map* target, | 77 Map* target, |
80 JSGlobalPropertyCell* descriptors_pointer, | 78 JSGlobalPropertyCell* descriptors_pointer, |
81 Object* back_pointer) { | 79 Object* back_pointer) { |
82 TransitionArray* result; | 80 TransitionArray* result; |
83 | 81 |
84 MaybeObject* maybe_array = TransitionArray::Allocate(1, descriptors_pointer); | 82 MaybeObject* maybe_array = TransitionArray::Allocate(1, descriptors_pointer); |
85 if (!maybe_array->To(&result)) return maybe_array; | 83 if (!maybe_array->To(&result)) return maybe_array; |
86 | 84 |
87 FixedArray::WhitenessWitness witness(result); | 85 result->NoIncrementalWriteBarrierSet(0, name, target); |
88 | |
89 result->Set(0, name, target, witness); | |
90 result->set_back_pointer_storage(back_pointer); | 86 result->set_back_pointer_storage(back_pointer); |
91 return result; | 87 return result; |
92 } | 88 } |
93 | 89 |
94 | 90 |
95 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) { | 91 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) { |
96 TransitionArray* result; | 92 TransitionArray* result; |
97 | 93 |
98 int number_of_transitions = this->number_of_transitions(); | 94 int number_of_transitions = this->number_of_transitions(); |
99 int new_size = number_of_transitions; | 95 int new_size = number_of_transitions; |
100 | 96 |
101 int insertion_index = this->Search(name); | 97 int insertion_index = this->Search(name); |
102 if (insertion_index == kNotFound) ++new_size; | 98 if (insertion_index == kNotFound) ++new_size; |
103 | 99 |
104 MaybeObject* maybe_array; | 100 MaybeObject* maybe_array; |
105 maybe_array = TransitionArray::Allocate(new_size, descriptors_pointer()); | 101 maybe_array = TransitionArray::Allocate(new_size, descriptors_pointer()); |
106 if (!maybe_array->To(&result)) return maybe_array; | 102 if (!maybe_array->To(&result)) return maybe_array; |
107 | 103 |
108 if (HasElementsTransition()) { | 104 if (HasElementsTransition()) { |
109 result->set_elements_transition(elements_transition()); | 105 result->set_elements_transition(elements_transition()); |
110 } | 106 } |
111 | 107 |
112 if (HasPrototypeTransitions()) { | 108 if (HasPrototypeTransitions()) { |
113 result->SetPrototypeTransitions(GetPrototypeTransitions()); | 109 result->SetPrototypeTransitions(GetPrototypeTransitions()); |
114 } | 110 } |
115 | 111 |
116 FixedArray::WhitenessWitness witness(result); | |
117 | |
118 if (insertion_index != kNotFound) { | 112 if (insertion_index != kNotFound) { |
119 for (int i = 0; i < number_of_transitions; ++i) { | 113 for (int i = 0; i < number_of_transitions; ++i) { |
120 if (i != insertion_index) result->CopyFrom(this, i, i, witness); | 114 if (i != insertion_index) { |
| 115 result->NoIncrementalWriteBarrierCopyFrom(this, i, i); |
| 116 } |
121 } | 117 } |
122 result->Set(insertion_index, name, target, witness); | 118 result->NoIncrementalWriteBarrierSet(insertion_index, name, target); |
123 return result; | 119 return result; |
124 } | 120 } |
125 | 121 |
126 insertion_index = 0; | 122 insertion_index = 0; |
127 for (; insertion_index < number_of_transitions; ++insertion_index) { | 123 for (; insertion_index < number_of_transitions; ++insertion_index) { |
128 if (InsertionPointFound(GetKey(insertion_index), name)) break; | 124 if (InsertionPointFound(GetKey(insertion_index), name)) break; |
129 result->CopyFrom(this, insertion_index, insertion_index, witness); | 125 result->NoIncrementalWriteBarrierCopyFrom( |
| 126 this, insertion_index, insertion_index); |
130 } | 127 } |
131 | 128 |
132 result->Set(insertion_index, name, target, witness); | 129 result->NoIncrementalWriteBarrierSet(insertion_index, name, target); |
133 | 130 |
134 for (; insertion_index < number_of_transitions; ++insertion_index) { | 131 for (; insertion_index < number_of_transitions; ++insertion_index) { |
135 result->CopyFrom(this, insertion_index, insertion_index + 1, witness); | 132 result->NoIncrementalWriteBarrierCopyFrom( |
| 133 this, insertion_index, insertion_index + 1); |
136 } | 134 } |
137 | 135 |
138 result->set_back_pointer_storage(back_pointer_storage()); | 136 result->set_back_pointer_storage(back_pointer_storage()); |
139 return result; | 137 return result; |
140 } | 138 } |
141 | 139 |
142 | 140 |
143 } } // namespace v8::internal | 141 } } // namespace v8::internal |
OLD | NEW |