Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: src/elements.cc

Issue 1325483002: Adding ElementsAccessor::Pop (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-08-27_array_builtin_slice
Patch Set: Addressing comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/elements.h ('k') | src/elements-kind.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index d17efafcebb2c6c88e585381ffda311db20d63bc..2cf64c52f744c6c08e8af614165641a22e7554b9 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -639,6 +639,16 @@ class ElementsAccessorBase : public ElementsAccessor {
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,
@@ -1219,6 +1229,21 @@ class FastElementsAccessor
#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,
« no previous file with comments | « src/elements.h ('k') | src/elements-kind.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698