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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
9 #include "src/elements.h" | 9 #include "src/elements.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 if (!array->elements()->IsDictionary()) { | 201 if (!array->elements()->IsDictionary()) { |
202 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || | 202 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || |
203 array->HasFastDoubleElements()); | 203 array->HasFastDoubleElements()); |
204 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 204 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
205 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 205 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
206 } | 206 } |
207 | 207 |
208 KeyAccumulator accumulator(isolate); | 208 KeyAccumulator accumulator(isolate); |
209 // No need to separate protoype levels since we only get numbers/element keys | 209 // No need to separate protoype levels since we only get numbers/element keys |
210 accumulator.NextPrototype(); | |
211 for (PrototypeIterator iter(isolate, array, | 210 for (PrototypeIterator iter(isolate, array, |
212 PrototypeIterator::START_AT_RECEIVER); | 211 PrototypeIterator::START_AT_RECEIVER); |
213 !iter.IsAtEnd(); iter.Advance()) { | 212 !iter.IsAtEnd(); iter.Advance()) { |
214 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || | 213 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || |
215 PrototypeIterator::GetCurrent<JSObject>(iter) | 214 PrototypeIterator::GetCurrent<JSObject>(iter) |
216 ->HasIndexedInterceptor()) { | 215 ->HasIndexedInterceptor()) { |
217 // Bail out if we find a proxy or interceptor, likely not worth | 216 // Bail out if we find a proxy or interceptor, likely not worth |
218 // collecting keys in that case. | 217 // collecting keys in that case. |
219 return *isolate->factory()->NewNumberFromUint(length); | 218 return *isolate->factory()->NewNumberFromUint(length); |
220 } | 219 } |
| 220 accumulator.NextPrototype(); |
221 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); | 221 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); |
222 JSObject::CollectOwnElementKeys(current, &accumulator, NONE); | 222 JSObject::CollectOwnElementKeys(current, &accumulator, NONE); |
223 } | 223 } |
224 // Erase any keys >= length. | 224 // Erase any keys >= length. |
225 // TODO(adamk): Remove this step when the contract of %GetArrayKeys | 225 // TODO(adamk): Remove this step when the contract of %GetArrayKeys |
226 // is changed to let this happen on the JS side. | 226 // is changed to let this happen on the JS side. |
227 Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS); | 227 Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS); |
228 for (int i = 0; i < keys->length(); i++) { | 228 for (int i = 0; i < keys->length(); i++) { |
229 if (NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i); | 229 if (NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i); |
230 } | 230 } |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { | 493 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { |
494 SealHandleScope shs(isolate); | 494 SealHandleScope shs(isolate); |
495 DCHECK(args.length() == 2); | 495 DCHECK(args.length() == 2); |
496 // Returning undefined means that this fast path fails and one has to resort | 496 // Returning undefined means that this fast path fails and one has to resort |
497 // to a slow path. | 497 // to a slow path. |
498 return isolate->heap()->undefined_value(); | 498 return isolate->heap()->undefined_value(); |
499 } | 499 } |
500 } // namespace internal | 500 } // namespace internal |
501 } // namespace v8 | 501 } // namespace v8 |
OLD | NEW |