}
-bool PrototypeHasNoElements(PrototypeIterator* iter) {
+inline bool PrototypeHasNoElements(PrototypeIterator* iter) {
DisallowHeapAllocation no_gc;
for (; !iter->IsAtEnd(); iter->Advance()) {
if (iter->GetCurrent()->IsJSProxy()) return false;
return CallJsIntrinsic(isolate, isolate->array_pop(), args);
}
- uint32_t new_length = len - 1;
- Handle<Object> element;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, element, Object::GetElement(isolate, array, new_length));
-
- JSArray::SetLength(array, new_length);
- return *element;
+ Handle<Object> result;
+ if (IsJSArrayFastElementMovingAllowed(isolate, JSArray::cast(*receiver))) {
+ // Fast Elements Path
+ result = array->GetElementsAccessor()->Pop(array, elms_obj);
+ } else {
+ // Use Slow Lookup otherwise
+ uint32_t new_length = len - 1;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, Object::GetElement(isolate, array, new_length));
+ JSArray::SetLength(array, new_length);
+ }
+ return *result;
}
inline bool IsFastPackedElementsKind(ElementsKind kind) {
- return kind == FAST_SMI_ELEMENTS ||
- kind == FAST_DOUBLE_ELEMENTS ||
- kind == FAST_ELEMENTS;
+ return kind == FAST_SMI_ELEMENTS || kind == FAST_DOUBLE_ELEMENTS ||
+ kind == FAST_ELEMENTS;
}
return Handle<JSArray>();
}
+ virtual Handle<Object> Pop(Handle<JSArray> receiver,
+ Handle<FixedArrayBase> backing_store) final {
+ return ElementsAccessorSubclass::PopImpl(receiver, backing_store);
+ }
+
+ static Handle<Object> PopImpl(Handle<JSArray> receiver,
+ Handle<FixedArrayBase> backing_store) {
+ UNREACHABLE();
+ return Handle<Object>();
+ }
virtual void SetLength(Handle<JSArray> array, uint32_t length) final {
ElementsAccessorSubclass::SetLengthImpl(array, length,
#endif
}
+ static Handle<Object> PopImpl(Handle<JSArray> receiver,
+ Handle<FixedArrayBase> backing_store) {
+ uint32_t new_length =
+ static_cast<uint32_t>(Smi::cast(receiver->length())->value()) - 1;
+ Handle<Object> result =
+ FastElementsAccessorSubclass::GetImpl(backing_store, new_length);
+ FastElementsAccessorSubclass::SetLengthImpl(receiver, new_length,
+ backing_store);
+
+ if (IsHoleyElementsKind(KindTraits::Kind) && result->IsTheHole()) {
+ result = receiver->GetIsolate()->factory()->undefined_value();
+ }
+ return result;
+ }
+
static uint32_t PushImpl(Handle<JSArray> receiver,
Handle<FixedArrayBase> backing_store,
Object** objects, uint32_t push_size,
uint32_t start, uint32_t delete_count,
Arguments args, uint32_t add_count) = 0;
+ virtual Handle<Object> Pop(Handle<JSArray> receiver,
+ Handle<FixedArrayBase> backing_store) = 0;
+
protected:
friend class LookupIterator;