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

Side by Side 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, 3 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 unified diff | Download patch
« no previous file with comments | « src/elements.h ('k') | src/elements-kind.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/elements.h" 5 #include "src/elements.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } 632 }
633 633
634 static Handle<JSArray> SpliceImpl(Handle<JSArray> receiver, 634 static Handle<JSArray> SpliceImpl(Handle<JSArray> receiver,
635 Handle<FixedArrayBase> backing_store, 635 Handle<FixedArrayBase> backing_store,
636 uint32_t start, uint32_t delete_count, 636 uint32_t start, uint32_t delete_count,
637 Arguments args, uint32_t add_count) { 637 Arguments args, uint32_t add_count) {
638 UNREACHABLE(); 638 UNREACHABLE();
639 return Handle<JSArray>(); 639 return Handle<JSArray>();
640 } 640 }
641 641
642 virtual Handle<Object> Pop(Handle<JSArray> receiver,
643 Handle<FixedArrayBase> backing_store) final {
644 return ElementsAccessorSubclass::PopImpl(receiver, backing_store);
645 }
646
647 static Handle<Object> PopImpl(Handle<JSArray> receiver,
648 Handle<FixedArrayBase> backing_store) {
649 UNREACHABLE();
650 return Handle<Object>();
651 }
642 652
643 virtual void SetLength(Handle<JSArray> array, uint32_t length) final { 653 virtual void SetLength(Handle<JSArray> array, uint32_t length) final {
644 ElementsAccessorSubclass::SetLengthImpl(array, length, 654 ElementsAccessorSubclass::SetLengthImpl(array, length,
645 handle(array->elements())); 655 handle(array->elements()));
646 } 656 }
647 657
648 static void SetLengthImpl(Handle<JSArray> array, uint32_t length, 658 static void SetLengthImpl(Handle<JSArray> array, uint32_t length,
649 Handle<FixedArrayBase> backing_store); 659 Handle<FixedArrayBase> backing_store);
650 660
651 static Handle<FixedArrayBase> ConvertElementsWithCapacity( 661 static Handle<FixedArrayBase> ConvertElementsWithCapacity(
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 if (IsFastSmiElementsKind(KindTraits::Kind)) { 1222 if (IsFastSmiElementsKind(KindTraits::Kind)) {
1213 for (int i = 0; i < length; i++) { 1223 for (int i = 0; i < length; i++) {
1214 DCHECK(BackingStore::get(backing_store, i)->IsSmi() || 1224 DCHECK(BackingStore::get(backing_store, i)->IsSmi() ||
1215 (IsFastHoleyElementsKind(KindTraits::Kind) && 1225 (IsFastHoleyElementsKind(KindTraits::Kind) &&
1216 backing_store->is_the_hole(i))); 1226 backing_store->is_the_hole(i)));
1217 } 1227 }
1218 } 1228 }
1219 #endif 1229 #endif
1220 } 1230 }
1221 1231
1232 static Handle<Object> PopImpl(Handle<JSArray> receiver,
1233 Handle<FixedArrayBase> backing_store) {
1234 uint32_t new_length =
1235 static_cast<uint32_t>(Smi::cast(receiver->length())->value()) - 1;
1236 Handle<Object> result =
1237 FastElementsAccessorSubclass::GetImpl(backing_store, new_length);
1238 FastElementsAccessorSubclass::SetLengthImpl(receiver, new_length,
1239 backing_store);
1240
1241 if (IsHoleyElementsKind(KindTraits::Kind) && result->IsTheHole()) {
1242 result = receiver->GetIsolate()->factory()->undefined_value();
1243 }
1244 return result;
1245 }
1246
1222 static uint32_t PushImpl(Handle<JSArray> receiver, 1247 static uint32_t PushImpl(Handle<JSArray> receiver,
1223 Handle<FixedArrayBase> backing_store, 1248 Handle<FixedArrayBase> backing_store,
1224 Object** objects, uint32_t push_size, 1249 Object** objects, uint32_t push_size,
1225 int direction) { 1250 int direction) {
1226 uint32_t len = Smi::cast(receiver->length())->value(); 1251 uint32_t len = Smi::cast(receiver->length())->value();
1227 if (push_size == 0) { 1252 if (push_size == 0) {
1228 return len; 1253 return len;
1229 } 1254 }
1230 uint32_t elms_len = backing_store->length(); 1255 uint32_t elms_len = backing_store->length();
1231 // Currently fixed arrays cannot grow too big, so 1256 // Currently fixed arrays cannot grow too big, so
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; 2221 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
2197 ELEMENTS_LIST(ACCESSOR_DELETE) 2222 ELEMENTS_LIST(ACCESSOR_DELETE)
2198 #undef ACCESSOR_DELETE 2223 #undef ACCESSOR_DELETE
2199 elements_accessors_ = NULL; 2224 elements_accessors_ = NULL;
2200 } 2225 }
2201 2226
2202 2227
2203 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 2228 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
2204 } // namespace internal 2229 } // namespace internal
2205 } // namespace v8 2230 } // namespace v8
OLDNEW
« 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