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

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

Issue 2778623003: [typedarrays] Check detached buffer at start of typed array methods (Closed)
Patch Set: Use inline IS_TYPEDARRAY 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
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 6879 matching lines...) Expand 10 before | Expand all | Expand 10 after
6890 6890
6891 // static 6891 // static
6892 MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate, 6892 MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate,
6893 Handle<Object> receiver, 6893 Handle<Object> receiver,
6894 const char* method_name) { 6894 const char* method_name) {
6895 if (V8_UNLIKELY(!receiver->IsJSTypedArray())) { 6895 if (V8_UNLIKELY(!receiver->IsJSTypedArray())) {
6896 const MessageTemplate::Template message = MessageTemplate::kNotTypedArray; 6896 const MessageTemplate::Template message = MessageTemplate::kNotTypedArray;
6897 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray); 6897 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
6898 } 6898 }
6899 6899
6900 // TODO(caitp): throw if array.[[ViewedArrayBuffer]] is neutered (per v8:4648) 6900 Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
6901 return Handle<JSTypedArray>::cast(receiver); 6901 if (V8_UNLIKELY(array->WasNeutered())) {
6902 const MessageTemplate::Template message =
6903 MessageTemplate::kDetachedOperation;
6904 Handle<String> operation =
6905 isolate->factory()->NewStringFromAsciiChecked(method_name);
6906 THROW_NEW_ERROR(isolate, NewTypeError(message, operation), JSTypedArray);
6907 }
6908
6909 // TODO(cwhan.tunz): spec describes to return `buffer`, but it may disrupt
6910 // current implementations, and it's much useful to return array for now.
Dan Ehrenberg 2017/03/28 19:39:28 Nit: I agree with your reasoning here; I think you
Choongwoo Han 2017/03/29 05:36:54 Done.
6911 return array;
6902 } 6912 }
6903 6913
6904 #ifdef VERIFY_HEAP 6914 #ifdef VERIFY_HEAP
6905 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset) 6915 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset)
6906 #endif 6916 #endif
6907 6917
6908 ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset) 6918 ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset)
6909 ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset) 6919 ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset)
6910 ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset) 6920 ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset)
6911 6921
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
8239 #undef WRITE_BYTE_FIELD 8249 #undef WRITE_BYTE_FIELD
8240 #undef NOBARRIER_READ_BYTE_FIELD 8250 #undef NOBARRIER_READ_BYTE_FIELD
8241 #undef NOBARRIER_WRITE_BYTE_FIELD 8251 #undef NOBARRIER_WRITE_BYTE_FIELD
8242 8252
8243 } // namespace internal 8253 } // namespace internal
8244 } // namespace v8 8254 } // namespace v8
8245 8255
8246 #include "src/objects/object-macros-undef.h" 8256 #include "src/objects/object-macros-undef.h"
8247 8257
8248 #endif // V8_OBJECTS_INL_H_ 8258 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698