Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 3c23e011fc6285453934decd98e884a1f10db89a..3a33996b1bd373be11df8824d1e180a91d230efb 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -719,14 +719,9 @@ MaybeHandle<FixedArray> Object::CreateListFromArrayLike( |
} |
// 4. Let len be ? ToLength(? Get(obj, "length")). |
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object); |
- Handle<Object> raw_length_obj; |
- ASSIGN_RETURN_ON_EXCEPTION( |
- isolate, raw_length_obj, |
- JSReceiver::GetProperty(receiver, isolate->factory()->length_string()), |
- FixedArray); |
Handle<Object> raw_length_number; |
ASSIGN_RETURN_ON_EXCEPTION(isolate, raw_length_number, |
- Object::ToLength(isolate, raw_length_obj), |
+ Object::GetLengthFromArrayLike(isolate, receiver), |
FixedArray); |
uint32_t len; |
if (!raw_length_number->ToUint32(&len) || |
@@ -773,6 +768,16 @@ MaybeHandle<FixedArray> Object::CreateListFromArrayLike( |
// static |
+MaybeHandle<Object> Object::GetLengthFromArrayLike(Isolate* isolate, |
+ Handle<Object> object) { |
+ Handle<Object> val; |
+ Handle<Object> key = isolate->factory()->length_string(); |
+ ASSIGN_RETURN_ON_EXCEPTION( |
+ isolate, val, Runtime::GetObjectProperty(isolate, object, key), Object); |
+ return Object::ToLength(isolate, val); |
+} |
+ |
+// static |
Maybe<bool> JSReceiver::HasProperty(LookupIterator* it) { |
for (; it->IsFound(); it->Next()) { |
switch (it->state()) { |