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

Side by Side Diff: src/objects-inl.h

Issue 2778623003: [typedarrays] Check detached buffer at start of typed array methods (Closed)
Patch Set: pass test262 for subarray Created 3 years, 8 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/js/typedarray.js ('k') | src/runtime/runtime.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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 6885 matching lines...) Expand 10 before | Expand all | Expand 10 after
6896 6896
6897 // static 6897 // static
6898 MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate, 6898 MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate,
6899 Handle<Object> receiver, 6899 Handle<Object> receiver,
6900 const char* method_name) { 6900 const char* method_name) {
6901 if (V8_UNLIKELY(!receiver->IsJSTypedArray())) { 6901 if (V8_UNLIKELY(!receiver->IsJSTypedArray())) {
6902 const MessageTemplate::Template message = MessageTemplate::kNotTypedArray; 6902 const MessageTemplate::Template message = MessageTemplate::kNotTypedArray;
6903 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray); 6903 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
6904 } 6904 }
6905 6905
6906 // TODO(caitp): throw if array.[[ViewedArrayBuffer]] is neutered (per v8:4648) 6906 Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
6907 return Handle<JSTypedArray>::cast(receiver); 6907 if (V8_UNLIKELY(array->WasNeutered())) {
6908 const MessageTemplate::Template message =
6909 MessageTemplate::kDetachedOperation;
6910 Handle<String> operation =
6911 isolate->factory()->NewStringFromAsciiChecked(method_name);
6912 THROW_NEW_ERROR(isolate, NewTypeError(message, operation), JSTypedArray);
6913 }
6914
6915 // spec describes to return `buffer`, but it may disrupt current
6916 // implementations, and it's much useful to return array for now.
6917 return array;
6908 } 6918 }
6909 6919
6910 #ifdef VERIFY_HEAP 6920 #ifdef VERIFY_HEAP
6911 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset) 6921 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset)
6912 #endif 6922 #endif
6913 6923
6914 ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset) 6924 ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset)
6915 ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset) 6925 ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset)
6916 ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset) 6926 ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset)
6917 6927
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
8246 #undef WRITE_BYTE_FIELD 8256 #undef WRITE_BYTE_FIELD
8247 #undef NOBARRIER_READ_BYTE_FIELD 8257 #undef NOBARRIER_READ_BYTE_FIELD
8248 #undef NOBARRIER_WRITE_BYTE_FIELD 8258 #undef NOBARRIER_WRITE_BYTE_FIELD
8249 8259
8250 } // namespace internal 8260 } // namespace internal
8251 } // namespace v8 8261 } // namespace v8
8252 8262
8253 #include "src/objects/object-macros-undef.h" 8263 #include "src/objects/object-macros-undef.h"
8254 8264
8255 #endif // V8_OBJECTS_INL_H_ 8265 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/js/typedarray.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698