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

Side by Side Diff: src/transitions.cc

Issue 11099064: Remove descriptors pointer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed nits Created 8 years, 2 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/transitions.h ('k') | src/transitions-inl.h » ('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 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
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 static MaybeObject* AllocateRaw(int length, 38 static MaybeObject* AllocateRaw(int length) {
39 JSGlobalPropertyCell* descriptors_cell) {
40 Heap* heap = Isolate::Current()->heap(); 39 Heap* heap = Isolate::Current()->heap();
41 40
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 TransitionArray::cast on incomplete object. 41 // Use FixedArray to not use TransitionArray::cast on incomplete object.
49 FixedArray* array; 42 FixedArray* array;
50 MaybeObject* maybe_array = heap->AllocateFixedArray(length); 43 MaybeObject* maybe_array = heap->AllocateFixedArray(length);
51 if (!maybe_array->To(&array)) return maybe_array; 44 if (!maybe_array->To(&array)) return maybe_array;
52
53 array->set(TransitionArray::kDescriptorsPointerIndex, descriptors_cell);
54 return array; 45 return array;
55 } 46 }
56 47
57 48
58 MaybeObject* TransitionArray::Allocate(int number_of_transitions, 49 MaybeObject* TransitionArray::Allocate(int number_of_transitions) {
59 JSGlobalPropertyCell* descriptors_cell) {
60 FixedArray* array; 50 FixedArray* array;
61 MaybeObject* maybe_array = 51 MaybeObject* maybe_array = AllocateRaw(ToKeyIndex(number_of_transitions));
62 AllocateRaw(ToKeyIndex(number_of_transitions), descriptors_cell);
63 if (!maybe_array->To(&array)) return maybe_array; 52 if (!maybe_array->To(&array)) return maybe_array;
64 array->set(kElementsTransitionIndex, Smi::FromInt(0)); 53 array->set(kElementsTransitionIndex, Smi::FromInt(0));
65 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); 54 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0));
66 return array; 55 return array;
67 } 56 }
68 57
69 58
70 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, 59 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin,
71 int origin_transition, 60 int origin_transition,
72 int target_transition) { 61 int target_transition) {
73 NoIncrementalWriteBarrierSet(target_transition, 62 NoIncrementalWriteBarrierSet(target_transition,
74 origin->GetKey(origin_transition), 63 origin->GetKey(origin_transition),
75 origin->GetTarget(origin_transition)); 64 origin->GetTarget(origin_transition));
76 } 65 }
77 66
78 67
79 static bool InsertionPointFound(String* key1, String* key2) { 68 static bool InsertionPointFound(String* key1, String* key2) {
80 return key1->Hash() > key2->Hash(); 69 return key1->Hash() > key2->Hash();
81 } 70 }
82 71
83 72
84 MaybeObject* TransitionArray::NewWith(SimpleTransitionFlag flag, 73 MaybeObject* TransitionArray::NewWith(SimpleTransitionFlag flag,
85 String* key, 74 String* key,
86 Map* target, 75 Map* target,
87 JSGlobalPropertyCell* descriptors_pointer, 76 DescriptorArray* descriptors,
88 Object* back_pointer) { 77 Object* back_pointer) {
89 TransitionArray* result; 78 TransitionArray* result;
90 MaybeObject* maybe_result; 79 MaybeObject* maybe_result;
91 80
92 if (flag == SIMPLE_TRANSITION) { 81 if (flag == SIMPLE_TRANSITION) {
93 maybe_result = AllocateRaw(kSimpleTransitionSize, descriptors_pointer); 82 maybe_result = AllocateRaw(kSimpleTransitionSize);
94 if (!maybe_result->To(&result)) return maybe_result; 83 if (!maybe_result->To(&result)) return maybe_result;
95 result->set(kSimpleTransitionTarget, target); 84 result->set(kSimpleTransitionTarget, target);
96 } else { 85 } else {
97 maybe_result = Allocate(1, descriptors_pointer); 86 maybe_result = Allocate(1);
98 if (!maybe_result->To(&result)) return maybe_result; 87 if (!maybe_result->To(&result)) return maybe_result;
99 result->NoIncrementalWriteBarrierSet(0, key, target); 88 result->NoIncrementalWriteBarrierSet(0, key, target);
100 } 89 }
101 result->set_back_pointer_storage(back_pointer); 90 result->set_back_pointer_storage(back_pointer);
91 result->set_descriptors(descriptors);
102 return result; 92 return result;
103 } 93 }
104 94
105 95
106 MaybeObject* TransitionArray::AllocateDescriptorsHolder( 96 MaybeObject* TransitionArray::AllocateDescriptorsHolder() {
107 JSGlobalPropertyCell* descriptors_pointer) { 97 return AllocateRaw(kDescriptorsHolderSize);
108 return AllocateRaw(kDescriptorsHolderSize, descriptors_pointer);
109 } 98 }
110 99
111 100
112 MaybeObject* TransitionArray::ExtendToFullTransitionArray() { 101 MaybeObject* TransitionArray::ExtendToFullTransitionArray() {
113 ASSERT(!IsFullTransitionArray()); 102 ASSERT(!IsFullTransitionArray());
114 int nof = number_of_transitions(); 103 int nof = number_of_transitions();
115 TransitionArray* result; 104 TransitionArray* result;
116 MaybeObject* maybe_result = Allocate(nof, descriptors_pointer()); 105 MaybeObject* maybe_result = Allocate(nof);
117 if (!maybe_result->To(&result)) return maybe_result; 106 if (!maybe_result->To(&result)) return maybe_result;
118 107
119 if (nof == 1) { 108 if (nof == 1) {
120 result->NoIncrementalWriteBarrierCopyFrom(this, kSimpleTransitionIndex, 0); 109 result->NoIncrementalWriteBarrierCopyFrom(this, kSimpleTransitionIndex, 0);
121 } 110 }
122 111
112 result->set_descriptors(descriptors());
123 result->set_back_pointer_storage(back_pointer_storage()); 113 result->set_back_pointer_storage(back_pointer_storage());
124 return result; 114 return result;
125 } 115 }
126 116
127 117
128 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) { 118 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) {
129 TransitionArray* result; 119 TransitionArray* result;
130 120
131 int number_of_transitions = this->number_of_transitions(); 121 int number_of_transitions = this->number_of_transitions();
132 int new_size = number_of_transitions; 122 int new_size = number_of_transitions;
133 123
134 int insertion_index = this->Search(name); 124 int insertion_index = this->Search(name);
135 if (insertion_index == kNotFound) ++new_size; 125 if (insertion_index == kNotFound) ++new_size;
136 126
137 MaybeObject* maybe_array; 127 MaybeObject* maybe_array;
138 maybe_array = TransitionArray::Allocate(new_size, descriptors_pointer()); 128 maybe_array = TransitionArray::Allocate(new_size);
139 if (!maybe_array->To(&result)) return maybe_array; 129 if (!maybe_array->To(&result)) return maybe_array;
140 130
131 result->set_descriptors(descriptors());
132
141 if (HasElementsTransition()) { 133 if (HasElementsTransition()) {
142 result->set_elements_transition(elements_transition()); 134 result->set_elements_transition(elements_transition());
143 } 135 }
144 136
145 if (HasPrototypeTransitions()) { 137 if (HasPrototypeTransitions()) {
146 result->SetPrototypeTransitions(GetPrototypeTransitions()); 138 result->SetPrototypeTransitions(GetPrototypeTransitions());
147 } 139 }
148 140
149 if (insertion_index != kNotFound) { 141 if (insertion_index != kNotFound) {
150 for (int i = 0; i < number_of_transitions; ++i) { 142 for (int i = 0; i < number_of_transitions; ++i) {
(...skipping 18 matching lines...) Expand all
169 result->NoIncrementalWriteBarrierCopyFrom( 161 result->NoIncrementalWriteBarrierCopyFrom(
170 this, insertion_index, insertion_index + 1); 162 this, insertion_index, insertion_index + 1);
171 } 163 }
172 164
173 result->set_back_pointer_storage(back_pointer_storage()); 165 result->set_back_pointer_storage(back_pointer_storage());
174 return result; 166 return result;
175 } 167 }
176 168
177 169
178 } } // namespace v8::internal 170 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/transitions.h ('k') | src/transitions-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698