Index: src/elements.cc |
diff --git a/src/elements.cc b/src/elements.cc |
index 6258da399c6c7d1983e71a4e4cee87745b055353..fd440a54be129a7a1c02ed75312c97d88827f9e2 100644 |
--- a/src/elements.cc |
+++ b/src/elements.cc |
@@ -1261,6 +1261,10 @@ class ElementsAccessorBase : public ElementsAccessor { |
return Subclass::LastIndexOfValueImpl(isolate, receiver, value, start_from); |
} |
+ static void ReverseImpl(JSObject* receiver) { UNREACHABLE(); } |
+ |
+ void Reverse(JSObject* receiver) final { Subclass::ReverseImpl(receiver); } |
+ |
static uint32_t GetIndexForEntryImpl(FixedArrayBase* backing_store, |
uint32_t entry) { |
return entry; |
@@ -3035,6 +3039,19 @@ class TypedElementsAccessor |
} while (k-- != 0); |
return Just<int64_t>(-1); |
} |
+ |
+ static void ReverseImpl(JSObject* receiver) { |
+ DisallowHeapAllocation no_gc; |
+ DCHECK(!WasNeutered(receiver)); |
+ |
+ BackingStore* elements = BackingStore::cast(receiver->elements()); |
+ |
+ uint32_t len = elements->length(); |
+ if (len == 0) return; |
+ |
+ ctype* data = static_cast<ctype*>(elements->DataPtr()); |
+ std::reverse(data, data + len); |
+ } |
}; |
#define FIXED_ELEMENTS_ACCESSOR(Type, type, TYPE, ctype, size) \ |