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 27 matching lines...) Expand all Loading... |
38 MaybeObject* TransitionArray::Allocate(int number_of_transitions) { | 38 MaybeObject* TransitionArray::Allocate(int number_of_transitions) { |
39 Heap* heap = Isolate::Current()->heap(); | 39 Heap* heap = Isolate::Current()->heap(); |
40 // Use FixedArray to not use DescriptorArray::cast on incomplete object. | 40 // Use FixedArray to not use DescriptorArray::cast on incomplete object. |
41 FixedArray* array; | 41 FixedArray* array; |
42 { MaybeObject* maybe_array = | 42 { MaybeObject* maybe_array = |
43 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions)); | 43 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions)); |
44 if (!maybe_array->To(&array)) return maybe_array; | 44 if (!maybe_array->To(&array)) return maybe_array; |
45 } | 45 } |
46 | 46 |
47 array->set(kElementsTransitionIndex, Smi::FromInt(0)); | 47 array->set(kElementsTransitionIndex, Smi::FromInt(0)); |
| 48 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); |
48 return array; | 49 return array; |
49 } | 50 } |
50 | 51 |
51 | 52 |
52 void TransitionArray::CopyFrom(TransitionArray* origin, | 53 void TransitionArray::CopyFrom(TransitionArray* origin, |
53 int origin_transition, | 54 int origin_transition, |
54 int target_transition, | 55 int target_transition, |
55 const WhitenessWitness& witness) { | 56 const WhitenessWitness& witness) { |
56 this->Set(target_transition, | 57 this->Set(target_transition, |
57 origin->GetKey(origin_transition), | 58 origin->GetKey(origin_transition), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 92 |
92 { MaybeObject* maybe_array; | 93 { MaybeObject* maybe_array; |
93 maybe_array = TransitionArray::Allocate(new_size); | 94 maybe_array = TransitionArray::Allocate(new_size); |
94 if (!maybe_array->To(&result)) return maybe_array; | 95 if (!maybe_array->To(&result)) return maybe_array; |
95 } | 96 } |
96 | 97 |
97 if (HasElementsTransition()) { | 98 if (HasElementsTransition()) { |
98 result->set_elements_transition(elements_transition()); | 99 result->set_elements_transition(elements_transition()); |
99 } | 100 } |
100 | 101 |
| 102 if (HasPrototypeTransitions()) { |
| 103 result->set_prototype_transitions(prototype_transitions()); |
| 104 } |
| 105 |
101 FixedArray::WhitenessWitness witness(result); | 106 FixedArray::WhitenessWitness witness(result); |
102 | 107 |
103 if (insertion_index != kNotFound) { | 108 if (insertion_index != kNotFound) { |
104 for (int i = 0; i < number_of_transitions; ++i) { | 109 for (int i = 0; i < number_of_transitions; ++i) { |
105 if (i != insertion_index) result->CopyFrom(this, i, i, witness); | 110 if (i != insertion_index) result->CopyFrom(this, i, i, witness); |
106 } | 111 } |
107 result->Set(insertion_index, name, value, witness); | 112 result->Set(insertion_index, name, value, witness); |
108 return result; | 113 return result; |
109 } | 114 } |
110 | 115 |
111 insertion_index = 0; | 116 insertion_index = 0; |
112 for (; insertion_index < number_of_transitions; ++insertion_index) { | 117 for (; insertion_index < number_of_transitions; ++insertion_index) { |
113 if (InsertionPointFound(GetKey(insertion_index), name)) break; | 118 if (InsertionPointFound(GetKey(insertion_index), name)) break; |
114 result->CopyFrom(this, insertion_index, insertion_index, witness); | 119 result->CopyFrom(this, insertion_index, insertion_index, witness); |
115 } | 120 } |
116 | 121 |
117 result->Set(insertion_index, name, value, witness); | 122 result->Set(insertion_index, name, value, witness); |
118 | 123 |
119 for (; insertion_index < number_of_transitions; ++insertion_index) { | 124 for (; insertion_index < number_of_transitions; ++insertion_index) { |
120 result->CopyFrom(this, insertion_index, insertion_index + 1, witness); | 125 result->CopyFrom(this, insertion_index, insertion_index + 1, witness); |
121 } | 126 } |
122 | 127 |
123 return result; | 128 return result; |
124 } | 129 } |
125 | 130 |
126 | 131 |
127 } } // namespace v8::internal | 132 } } // namespace v8::internal |
OLD | NEW |