OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/elements.h" | 8 #include "src/elements.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/runtime/runtime-utils.h" | 10 #include "src/runtime/runtime-utils.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Our initial estimate of length was foiled, possibly by | 147 // Our initial estimate of length was foiled, possibly by |
148 // getters on the arrays increasing the length of later arrays | 148 // getters on the arrays increasing the length of later arrays |
149 // during iteration. | 149 // during iteration. |
150 // This shouldn't happen in anything but pathological cases. | 150 // This shouldn't happen in anything but pathological cases. |
151 SetDictionaryMode(); | 151 SetDictionaryMode(); |
152 // Fall-through to dictionary mode. | 152 // Fall-through to dictionary mode. |
153 } | 153 } |
154 DCHECK(!fast_elements()); | 154 DCHECK(!fast_elements()); |
155 Handle<SeededNumberDictionary> dict( | 155 Handle<SeededNumberDictionary> dict( |
156 SeededNumberDictionary::cast(*storage_)); | 156 SeededNumberDictionary::cast(*storage_)); |
| 157 // The object holding this backing store has just been allocated, so |
| 158 // it cannot yet be used as a prototype. |
157 Handle<SeededNumberDictionary> result = | 159 Handle<SeededNumberDictionary> result = |
158 SeededNumberDictionary::AtNumberPut(dict, index, elm); | 160 SeededNumberDictionary::AtNumberPut(dict, index, elm, false); |
159 if (!result.is_identical_to(dict)) { | 161 if (!result.is_identical_to(dict)) { |
160 // Dictionary needed to grow. | 162 // Dictionary needed to grow. |
161 clear_storage(); | 163 clear_storage(); |
162 set_storage(*result); | 164 set_storage(*result); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 void increase_index_offset(uint32_t delta) { | 168 void increase_index_offset(uint32_t delta) { |
167 if (JSObject::kMaxElementCount - index_offset_ < delta) { | 169 if (JSObject::kMaxElementCount - index_offset_ < delta) { |
168 index_offset_ = JSObject::kMaxElementCount; | 170 index_offset_ = JSObject::kMaxElementCount; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void SetDictionaryMode() { | 202 void SetDictionaryMode() { |
201 DCHECK(fast_elements()); | 203 DCHECK(fast_elements()); |
202 Handle<FixedArray> current_storage(*storage_); | 204 Handle<FixedArray> current_storage(*storage_); |
203 Handle<SeededNumberDictionary> slow_storage( | 205 Handle<SeededNumberDictionary> slow_storage( |
204 SeededNumberDictionary::New(isolate_, current_storage->length())); | 206 SeededNumberDictionary::New(isolate_, current_storage->length())); |
205 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); | 207 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); |
206 for (uint32_t i = 0; i < current_length; i++) { | 208 for (uint32_t i = 0; i < current_length; i++) { |
207 HandleScope loop_scope(isolate_); | 209 HandleScope loop_scope(isolate_); |
208 Handle<Object> element(current_storage->get(i), isolate_); | 210 Handle<Object> element(current_storage->get(i), isolate_); |
209 if (!element->IsTheHole()) { | 211 if (!element->IsTheHole()) { |
| 212 // The object holding this backing store has just been allocated, so |
| 213 // it cannot yet be used as a prototype. |
210 Handle<SeededNumberDictionary> new_storage = | 214 Handle<SeededNumberDictionary> new_storage = |
211 SeededNumberDictionary::AtNumberPut(slow_storage, i, element); | 215 SeededNumberDictionary::AtNumberPut(slow_storage, i, element, |
| 216 false); |
212 if (!new_storage.is_identical_to(slow_storage)) { | 217 if (!new_storage.is_identical_to(slow_storage)) { |
213 slow_storage = loop_scope.CloseAndEscape(new_storage); | 218 slow_storage = loop_scope.CloseAndEscape(new_storage); |
214 } | 219 } |
215 } | 220 } |
216 } | 221 } |
217 clear_storage(); | 222 clear_storage(); |
218 set_storage(*slow_storage); | 223 set_storage(*slow_storage); |
219 set_fast_elements(false); | 224 set_fast_elements(false); |
220 } | 225 } |
221 | 226 |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 | 1269 |
1265 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { | 1270 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { |
1266 SealHandleScope shs(isolate); | 1271 SealHandleScope shs(isolate); |
1267 DCHECK(args.length() == 2); | 1272 DCHECK(args.length() == 2); |
1268 // Returning undefined means that this fast path fails and one has to resort | 1273 // Returning undefined means that this fast path fails and one has to resort |
1269 // to a slow path. | 1274 // to a slow path. |
1270 return isolate->heap()->undefined_value(); | 1275 return isolate->heap()->undefined_value(); |
1271 } | 1276 } |
1272 } // namespace internal | 1277 } // namespace internal |
1273 } // namespace v8 | 1278 } // namespace v8 |
OLD | NEW |