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

Side by Side Diff: src/transitions.cc

Issue 11035053: Rollback trunk to bleeding_edge revision 12525 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: 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 MaybeObject* TransitionArray::Allocate(int number_of_transitions,
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 TransitionArray::cast on incomplete object. 48 // Use FixedArray to not use DescriptorArray::cast on incomplete object.
49 FixedArray* array; 49 FixedArray* array;
50 MaybeObject* maybe_array = heap->AllocateFixedArray(length); 50 MaybeObject* maybe_array =
51 heap->AllocateFixedArray(ToKeyIndex(number_of_transitions));
51 if (!maybe_array->To(&array)) return maybe_array; 52 if (!maybe_array->To(&array)) return maybe_array;
52 53
53 array->set(TransitionArray::kDescriptorsPointerIndex, descriptors_cell); 54 array->set(kDescriptorsPointerIndex, descriptors_cell);
54 return array;
55 }
56
57
58 MaybeObject* TransitionArray::Allocate(int number_of_transitions,
59 JSGlobalPropertyCell* descriptors_cell) {
60 FixedArray* array;
61 MaybeObject* maybe_array =
62 AllocateRaw(ToKeyIndex(number_of_transitions), descriptors_cell);
63 if (!maybe_array->To(&array)) return maybe_array;
64 array->set(kElementsTransitionIndex, Smi::FromInt(0)); 55 array->set(kElementsTransitionIndex, Smi::FromInt(0));
65 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); 56 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0));
66 return array; 57 return array;
67 } 58 }
68 59
69 60
70 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin, 61 void TransitionArray::NoIncrementalWriteBarrierCopyFrom(TransitionArray* origin,
71 int origin_transition, 62 int origin_transition,
72 int target_transition) { 63 int target_transition) {
73 NoIncrementalWriteBarrierSet(target_transition, 64 NoIncrementalWriteBarrierSet(target_transition,
74 origin->GetKey(origin_transition), 65 origin->GetKey(origin_transition),
75 origin->GetTarget(origin_transition)); 66 origin->GetTarget(origin_transition));
76 } 67 }
77 68
78 69
79 static bool InsertionPointFound(String* key1, String* key2) { 70 static bool InsertionPointFound(String* key1, String* key2) {
80 return key1->Hash() > key2->Hash(); 71 return key1->Hash() > key2->Hash();
81 } 72 }
82 73
83 74
84 MaybeObject* TransitionArray::NewWith(SimpleTransitionFlag flag, 75 MaybeObject* TransitionArray::NewWith(
85 String* key, 76 String* name,
86 Map* target, 77 Map* target,
87 JSGlobalPropertyCell* descriptors_pointer, 78 JSGlobalPropertyCell* descriptors_pointer,
88 Object* back_pointer) { 79 Object* back_pointer) {
89 TransitionArray* result; 80 TransitionArray* result;
90 MaybeObject* maybe_result;
91 81
92 if (flag == SIMPLE_TRANSITION) { 82 MaybeObject* maybe_array = TransitionArray::Allocate(1, descriptors_pointer);
93 maybe_result = AllocateRaw(kSimpleTransitionSize, descriptors_pointer); 83 if (!maybe_array->To(&result)) return maybe_array;
94 if (!maybe_result->To(&result)) return maybe_result; 84
95 result->set(kSimpleTransitionTarget, target); 85 result->NoIncrementalWriteBarrierSet(0, name, 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 }
101 result->set_back_pointer_storage(back_pointer); 86 result->set_back_pointer_storage(back_pointer);
102 return result; 87 return result;
103 } 88 }
104 89
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
127 90
128 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) { 91 MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) {
129 TransitionArray* result; 92 TransitionArray* result;
130 93
131 int number_of_transitions = this->number_of_transitions(); 94 int number_of_transitions = this->number_of_transitions();
132 int new_size = number_of_transitions; 95 int new_size = number_of_transitions;
133 96
134 int insertion_index = this->Search(name); 97 int insertion_index = this->Search(name);
135 if (insertion_index == kNotFound) ++new_size; 98 if (insertion_index == kNotFound) ++new_size;
136 99
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 result->NoIncrementalWriteBarrierCopyFrom( 132 result->NoIncrementalWriteBarrierCopyFrom(
170 this, insertion_index, insertion_index + 1); 133 this, insertion_index, insertion_index + 1);
171 } 134 }
172 135
173 result->set_back_pointer_storage(back_pointer_storage()); 136 result->set_back_pointer_storage(back_pointer_storage());
174 return result; 137 return result;
175 } 138 }
176 139
177 140
178 } } // namespace v8::internal 141 } } // 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