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 7006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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_ |
OLD | NEW |