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

Side by Side Diff: src/elements.cc

Issue 2694783002: [builtins] treat all elements of detached TypedArray as undefined in A.p.includes (Closed)
Patch Set: also respect startFrom vs length Created 3 years, 10 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 | « no previous file | test/mjsunit/es7/regress/regress-691323-includes-typedarray.js » ('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/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 } 2808 }
2809 } 2809 }
2810 *nof_items = count; 2810 *nof_items = count;
2811 return Just(true); 2811 return Just(true);
2812 } 2812 }
2813 2813
2814 static Maybe<bool> IncludesValueImpl(Isolate* isolate, 2814 static Maybe<bool> IncludesValueImpl(Isolate* isolate,
2815 Handle<JSObject> receiver, 2815 Handle<JSObject> receiver,
2816 Handle<Object> value, 2816 Handle<Object> value,
2817 uint32_t start_from, uint32_t length) { 2817 uint32_t start_from, uint32_t length) {
2818 DisallowHeapAllocation no_gc;
2818 DCHECK(JSObject::PrototypeHasNoElements(isolate, *receiver)); 2819 DCHECK(JSObject::PrototypeHasNoElements(isolate, *receiver));
2819 DisallowHeapAllocation no_gc; 2820
2821 // Path should only be reached for JSTypedArrays
2822 Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
2823 Handle<JSArrayBuffer> buffer = array->GetBuffer();
2824 if (V8_UNLIKELY(buffer->was_neutered())) {
2825 // If buffer was neutered, all accesses yield `undefined`, so return
2826 // true if searching for undefined, otherwise false.
2827 return Just(value->IsUndefined(isolate) && length > start_from);
2828 }
2820 2829
2821 BackingStore* elements = BackingStore::cast(receiver->elements()); 2830 BackingStore* elements = BackingStore::cast(receiver->elements());
2822 if (value->IsUndefined(isolate) && 2831 if (value->IsUndefined(isolate) &&
2823 length > static_cast<uint32_t>(elements->length())) { 2832 length > static_cast<uint32_t>(elements->length())) {
2824 return Just(true); 2833 return Just(true);
2825 } 2834 }
2826 if (!value->IsNumber()) return Just(false); 2835 if (!value->IsNumber()) return Just(false);
2827 2836
2828 double search_value = value->Number(); 2837 double search_value = value->Number();
2829 2838
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 insertion_index += len; 3862 insertion_index += len;
3854 } 3863 }
3855 3864
3856 DCHECK_EQ(insertion_index, result_len); 3865 DCHECK_EQ(insertion_index, result_len);
3857 return result_array; 3866 return result_array;
3858 } 3867 }
3859 3868
3860 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 3869 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3861 } // namespace internal 3870 } // namespace internal
3862 } // namespace v8 3871 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es7/regress/regress-691323-includes-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698