OLD | NEW |
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 Loading... |
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 // spec describes to return `buffer`, but it may disrupt current |
| 6910 // implementations, and it's much useful to return array for now. |
| 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 Loading... |
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_ |
OLD | NEW |