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

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

Issue 2827443002: Reland [typedarrays] Check detached buffer at start of typed array methods (Closed)
Patch Set: rebase Created 3 years, 7 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 7006 matching lines...) Expand 10 before | Expand all | Expand 10 after
7017 7017
7018 // static 7018 // static
7019 MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate, 7019 MaybeHandle<JSTypedArray> JSTypedArray::Validate(Isolate* isolate,
7020 Handle<Object> receiver, 7020 Handle<Object> receiver,
7021 const char* method_name) { 7021 const char* method_name) {
7022 if (V8_UNLIKELY(!receiver->IsJSTypedArray())) { 7022 if (V8_UNLIKELY(!receiver->IsJSTypedArray())) {
7023 const MessageTemplate::Template message = MessageTemplate::kNotTypedArray; 7023 const MessageTemplate::Template message = MessageTemplate::kNotTypedArray;
7024 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray); 7024 THROW_NEW_ERROR(isolate, NewTypeError(message), JSTypedArray);
7025 } 7025 }
7026 7026
7027 // TODO(caitp): throw if array.[[ViewedArrayBuffer]] is neutered (per v8:4648) 7027 Handle<JSTypedArray> array = Handle<JSTypedArray>::cast(receiver);
7028 return Handle<JSTypedArray>::cast(receiver); 7028 if (V8_UNLIKELY(array->WasNeutered())) {
7029 const MessageTemplate::Template message =
7030 MessageTemplate::kDetachedOperation;
7031 Handle<String> operation =
7032 isolate->factory()->NewStringFromAsciiChecked(method_name);
7033 THROW_NEW_ERROR(isolate, NewTypeError(message, operation), JSTypedArray);
7034 }
7035
7036 // spec describes to return `buffer`, but it may disrupt current
7037 // implementations, and it's much useful to return array for now.
7038 return array;
7029 } 7039 }
7030 7040
7031 #ifdef VERIFY_HEAP 7041 #ifdef VERIFY_HEAP
7032 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset) 7042 ACCESSORS(JSTypedArray, raw_length, Object, kLengthOffset)
7033 #endif 7043 #endif
7034 7044
7035 ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset) 7045 ACCESSORS(JSPromiseCapability, promise, Object, kPromiseOffset)
7036 ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset) 7046 ACCESSORS(JSPromiseCapability, resolve, Object, kResolveOffset)
7037 ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset) 7047 ACCESSORS(JSPromiseCapability, reject, Object, kRejectOffset)
7038 7048
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
8363 #undef WRITE_BYTE_FIELD 8373 #undef WRITE_BYTE_FIELD
8364 #undef NOBARRIER_READ_BYTE_FIELD 8374 #undef NOBARRIER_READ_BYTE_FIELD
8365 #undef NOBARRIER_WRITE_BYTE_FIELD 8375 #undef NOBARRIER_WRITE_BYTE_FIELD
8366 8376
8367 } // namespace internal 8377 } // namespace internal
8368 } // namespace v8 8378 } // namespace v8
8369 8379
8370 #include "src/objects/object-macros-undef.h" 8380 #include "src/objects/object-macros-undef.h"
8371 8381
8372 #endif // V8_OBJECTS_INL_H_ 8382 #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