| 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 17 matching lines...) Expand all Loading... |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "objects.h" | 30 #include "objects.h" |
| 31 #include "transitions-inl.h" | 31 #include "transitions-inl.h" |
| 32 #include "utils.h" | 32 #include "utils.h" |
| 33 | 33 |
| 34 namespace v8 { | 34 namespace v8 { |
| 35 namespace internal { | 35 namespace internal { |
| 36 | 36 |
| 37 | 37 |
| 38 MaybeObject* TransitionArray::Allocate(int number_of_transitions, | 38 MaybeObject* TransitionArray::Allocate(int number_of_transitions) { |
| 39 JSGlobalPropertyCell* descriptors_cell) { | |
| 40 Heap* heap = Isolate::Current()->heap(); | 39 Heap* heap = Isolate::Current()->heap(); |
| 41 | |
| 42 if (descriptors_cell == NULL) { | |
| 43 MaybeObject* maybe_cell = | |
| 44 heap->AllocateJSGlobalPropertyCell(heap->empty_descriptor_array()); | |
| 45 if (!maybe_cell->To(&descriptors_cell)) return maybe_cell; | |
| 46 } | |
| 47 | |
| 48 // Use FixedArray to not use DescriptorArray::cast on incomplete object. | 40 // Use FixedArray to not use DescriptorArray::cast on incomplete object. |
| 49 FixedArray* array; | 41 FixedArray* array; |
| 50 MaybeObject* maybe_array = | 42 MaybeObject* maybe_array = |
| 51 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions)); | 43 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions)); |
| 52 if (!maybe_array->To(&array)) return maybe_array; | 44 if (!maybe_array->To(&array)) return maybe_array; |
| 53 | 45 |
| 54 array->set(kDescriptorsPointerIndex, descriptors_cell); | |
| 55 array->set(kElementsTransitionIndex, Smi::FromInt(0)); | 46 array->set(kElementsTransitionIndex, Smi::FromInt(0)); |
| 56 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); | 47 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); |
| 57 return array; | 48 return array; |
| 58 } | 49 } |
| 59 | 50 |
| 60 | 51 |
| 61 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, | 52 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, |
| 62 int origin_transition, | 53 int origin_transition, |
| 63 int target_transition) { | 54 int target_transition) { |
| 64 NoIncrementalWriteBarrierSet(target_transition, | 55 NoIncrementalWriteBarrierSet(target_transition, |
| 65 origin->GetKey(origin_transition), | 56 origin->GetKey(origin_transition), |
| 66 origin->GetTarget(origin_transition)); | 57 origin->GetTarget(origin_transition)); |
| 67 } | 58 } |
| 68 | 59 |
| 69 | 60 |
| 70 static bool InsertionPointFound(String* key1, String* key2) { | 61 static bool InsertionPointFound(String* key1, String* key2) { |
| 71 return key1->Hash() > key2->Hash(); | 62 return key1->Hash() > key2->Hash(); |
| 72 } | 63 } |
| 73 | 64 |
| 74 | 65 |
| 75 MaybeObject* TransitionArray::NewWith( | 66 MaybeObject* TransitionArray::NewWith(String* name, Map* target) { |
| 76 String* name, | |
| 77 Map* target, | |
| 78 JSGlobalPropertyCell* descriptors_pointer, | |
| 79 Object* back_pointer) { | |
| 80 TransitionArray* result; | 67 TransitionArray* result; |
| 81 | 68 |
| 82 MaybeObject* maybe_array = TransitionArray::Allocate(1, descriptors_pointer); | 69 MaybeObject* maybe_array = TransitionArray::Allocate(1); |
| 83 if (!maybe_array->To(&result)) return maybe_array; | 70 if (!maybe_array->To(&result)) return maybe_array; |
| 84 | 71 |
| 85 result->NoIncrementalWriteBarrierSet(0, name, target); | 72 result->NoIncrementalWriteBarrierSet(0, name, target); |
| 86 result->set_back_pointer_storage(back_pointer); | |
| 87 return result; | 73 return result; |
| 88 } | 74 } |
| 89 | 75 |
| 90 | 76 |
| 91 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) { | 77 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) { |
| 92 TransitionArray* result; | 78 TransitionArray* result; |
| 93 | 79 |
| 94 int number_of_transitions = this->number_of_transitions(); | 80 int number_of_transitions = this->number_of_transitions(); |
| 95 int new_size = number_of_transitions; | 81 int new_size = number_of_transitions; |
| 96 | 82 |
| 97 int insertion_index = this->Search(name); | 83 int insertion_index = this->Search(name); |
| 98 if (insertion_index == kNotFound) ++new_size; | 84 if (insertion_index == kNotFound) ++new_size; |
| 99 | 85 |
| 100 MaybeObject* maybe_array; | 86 MaybeObject* maybe_array; |
| 101 maybe_array = TransitionArray::Allocate(new_size, descriptors_pointer()); | 87 maybe_array = TransitionArray::Allocate(new_size); |
| 102 if (!maybe_array->To(&result)) return maybe_array; | 88 if (!maybe_array->To(&result)) return maybe_array; |
| 103 | 89 |
| 104 if (HasElementsTransition()) { | 90 if (HasElementsTransition()) { |
| 105 result->set_elements_transition(elements_transition()); | 91 result->set_elements_transition(elements_transition()); |
| 106 } | 92 } |
| 107 | 93 |
| 108 if (HasPrototypeTransitions()) { | 94 if (HasPrototypeTransitions()) { |
| 109 result->SetPrototypeTransitions(GetPrototypeTransitions()); | 95 result->SetPrototypeTransitions(GetPrototypeTransitions()); |
| 110 } | 96 } |
| 111 | 97 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 126 this, insertion_index, insertion_index); | 112 this, insertion_index, insertion_index); |
| 127 } | 113 } |
| 128 | 114 |
| 129 result->NoIncrementalWriteBarrierSet(insertion_index, name, target); | 115 result->NoIncrementalWriteBarrierSet(insertion_index, name, target); |
| 130 | 116 |
| 131 for (; insertion_index < number_of_transitions; ++insertion_index) { | 117 for (; insertion_index < number_of_transitions; ++insertion_index) { |
| 132 result->NoIncrementalWriteBarrierCopyFrom( | 118 result->NoIncrementalWriteBarrierCopyFrom( |
| 133 this, insertion_index, insertion_index + 1); | 119 this, insertion_index, insertion_index + 1); |
| 134 } | 120 } |
| 135 | 121 |
| 136 result->set_back_pointer_storage(back_pointer_storage()); | |
| 137 return result; | 122 return result; |
| 138 } | 123 } |
| 139 | 124 |
| 140 | 125 |
| 141 } } // namespace v8::internal | 126 } } // namespace v8::internal |
| OLD | NEW |