v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtins-shared-array.cc
Go to the documentation of this file.
1// Copyright 2022 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
7
8namespace v8 {
9namespace internal {
10
11BUILTIN(SharedArrayConstructor) {
12 DCHECK(v8_flags.shared_string_table);
13
14 HandleScope scope(isolate);
15
16 Handle<Object> length_arg = args.atOrUndefined(isolate, 1);
17 DirectHandle<Object> length_number;
18 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, length_number,
19 Object::ToInteger(isolate, length_arg));
20 if (!IsSmi(*length_number)) {
22 isolate, NewRangeError(MessageTemplate::kSharedArraySizeOutOfRange));
23 }
24
25 int length = Cast<Smi>(*length_number).value();
28 isolate, NewRangeError(MessageTemplate::kSharedArraySizeOutOfRange));
29 }
30
31 return *isolate->factory()->NewJSSharedArray(args.target(), length);
32}
33
34BUILTIN(SharedArrayIsSharedArray) {
35 HandleScope scope(isolate);
36 return isolate->heap()->ToBoolean(
37 IsJSSharedArray(*args.atOrUndefined(isolate, 1)));
38}
39
40} // namespace internal
41} // namespace v8
#define BUILTIN(name)
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToInteger(Isolate *isolate, HandleType< T > input)
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
Definition isolate.h:284
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
Definition isolate.h:294
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:665
V8_EXPORT_PRIVATE FlagValues v8_flags
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK(condition)
Definition logging.h:482