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

Side by Side Diff: src/transitions.cc

Issue 10915260: Reduce space usage of simple transitions and descriptors holders. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 8 years, 3 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 MaybeObject* TransitionArray::Allocate(int number_of_transitions, 38 static MaybeObject* AllocateRaw(int length,
39 JSGlobalPropertyCell* descriptors_cell) { 39 JSGlobalPropertyCell* descriptors_cell) {
40 Heap* heap = Isolate::Current()->heap(); 40 Heap* heap = Isolate::Current()->heap();
41 41
42 if (descriptors_cell == NULL) { 42 if (descriptors_cell == NULL) {
43 MaybeObject* maybe_cell = 43 MaybeObject* maybe_cell =
44 heap->AllocateJSGlobalPropertyCell(heap->empty_descriptor_array()); 44 heap->AllocateJSGlobalPropertyCell(heap->empty_descriptor_array());
45 if (!maybe_cell->To(&descriptors_cell)) return maybe_cell; 45 if (!maybe_cell->To(&descriptors_cell)) return maybe_cell;
46 } 46 }
47 47
48 // Use FixedArray to not use DescriptorArray::cast on incomplete object. 48 // Use FixedArray to not use TransitionArray::cast on incomplete object.
49 FixedArray* array;
50 MaybeObject* maybe_array = heap->AllocateFixedArray(length);
51 if (!maybe_array->To(&array)) return maybe_array;
52
53 array->set(TransitionArray::kDescriptorsPointerIndex, descriptors_cell);
54 return array;
55 }
56
57
58 MaybeObject* TransitionArray::Allocate(int number_of_transitions,
59 JSGlobalPropertyCell* descriptors_cell) {
49 FixedArray* array; 60 FixedArray* array;
50 MaybeObject* maybe_array = 61 MaybeObject* maybe_array =
51 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions)); 62 AllocateRaw(ToKeyIndex(number_of_transitions), descriptors_cell);
52 if (!maybe_array->To(&array)) return maybe_array; 63 if (!maybe_array->To(&array)) return maybe_array;
53
54 array->set(kDescriptorsPointerIndex, descriptors_cell);
55 array->set(kElementsTransitionIndex, Smi::FromInt(0)); 64 array->set(kElementsTransitionIndex, Smi::FromInt(0));
56 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); 65 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0));
57 return array; 66 return array;
58 } 67 }
59 68
60 69
61 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, 70 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin,
62 int origin_transition, 71 int origin_transition,
63 int target_transition) { 72 int target_transition) {
64 NoIncrementalWriteBarrierSet(target_transition, 73 NoIncrementalWriteBarrierSet(target_transition,
65 origin->GetKey(origin_transition), 74 origin->GetKey(origin_transition),
66 origin->GetTarget(origin_transition)); 75 origin->GetTarget(origin_transition));
67 } 76 }
68 77
69 78
70 static bool InsertionPointFound(String* key1, String* key2) { 79 static bool InsertionPointFound(String* key1, String* key2) {
71 return key1->Hash() > key2->Hash(); 80 return key1->Hash() > key2->Hash();
72 } 81 }
73 82
74 83
75 MaybeObject* TransitionArray::NewWith( 84 MaybeObject* TransitionArray::NewWith(SimpleTransitionFlag flag,
76 String* name, 85 String* key,
77 Map* target, 86 Map* target,
78 JSGlobalPropertyCell* descriptors_pointer, 87 JSGlobalPropertyCell* descriptors_pointer,
79 Object* back_pointer) { 88 Object* back_pointer) {
80 TransitionArray* result; 89 TransitionArray* result;
90 MaybeObject* maybe_result;
81 91
82 MaybeObject* maybe_array = TransitionArray::Allocate(1, descriptors_pointer); 92 if (flag == SIMPLE_TRANSITION) {
83 if (!maybe_array->To(&result)) return maybe_array; 93 maybe_result = AllocateRaw(kSimpleTransitionSize, descriptors_pointer);
84 94 if (!maybe_result->To(&result)) return maybe_result;
85 result->NoIncrementalWriteBarrierSet(0, name, target); 95 result->set(kSimpleTransitionTarget, target);
96 } else {
97 maybe_result = Allocate(1, descriptors_pointer);
98 if (!maybe_result->To(&result)) return maybe_result;
99 result->NoIncrementalWriteBarrierSet(0, key, target);
100 }
86 result->set_back_pointer_storage(back_pointer); 101 result->set_back_pointer_storage(back_pointer);
87 return result; 102 return result;
88 } 103 }
89 104
105
106 MaybeObject* TransitionArray::AllocateDescriptorsHolder(
107 JSGlobalPropertyCell* descriptors_pointer) {
108 return AllocateRaw(kDescriptorsHolderSize, descriptors_pointer);
109 }
110
111
112 MaybeObject* TransitionArray::ExtendToFullTransitionArray() {
113 ASSERT(!IsFullTransitionArray());
114 int nof = number_of_transitions();
115 TransitionArray* result;
116 MaybeObject* maybe_result = Allocate(nof, descriptors_pointer());
117 if (!maybe_result->To(&result)) return maybe_result;
118
119 if (nof == 1) {
120 result->NoIncrementalWriteBarrierCopyFrom(this, kSimpleTransitionIndex, 0);
121 }
122
123 result->set_back_pointer_storage(back_pointer_storage());
124 return result;
125 }
126
90 127
91 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) { 128 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) {
92 TransitionArray* result; 129 TransitionArray* result;
93 130
94 int number_of_transitions = this->number_of_transitions(); 131 int number_of_transitions = this->number_of_transitions();
95 int new_size = number_of_transitions; 132 int new_size = number_of_transitions;
96 133
97 int insertion_index = this->Search(name); 134 int insertion_index = this->Search(name);
98 if (insertion_index == kNotFound) ++new_size; 135 if (insertion_index == kNotFound) ++new_size;
99 136
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 result->NoIncrementalWriteBarrierCopyFrom( 169 result->NoIncrementalWriteBarrierCopyFrom(
133 this, insertion_index, insertion_index + 1); 170 this, insertion_index, insertion_index + 1);
134 } 171 }
135 172
136 result->set_back_pointer_storage(back_pointer_storage()); 173 result->set_back_pointer_storage(back_pointer_storage());
137 return result; 174 return result;
138 } 175 }
139 176
140 177
141 } } // namespace v8::internal 178 } } // 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