Skip to content

Commit 064b9a7

Browse files
LeszekSwirskiV8 LUCI CQ
authored andcommitted
[tagged-ptr] Convert more Objects to Tagged<>
Convert a large amount of Objects to Tagged<Object>, by using a clang tool to convert all variables and parameters to Tagged<>, and manually fixing up any build failures this caused. Bug: v8:12710 Change-Id: I2bfc90220fe92ebc6487b5cddbc4166164637a71 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4827204 Commit-Queue: Leszek Swirski <[email protected]> Reviewed-by: Michael Lippautz <[email protected]> Auto-Submit: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/main@{#89750}
1 parent 9b319ef commit 064b9a7

724 files changed

Lines changed: 9811 additions & 8753 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/api/api-arguments-inl.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ Handle<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) const {
4141
// Check the ReturnValue.
4242
FullObjectSlot slot = slot_at(kReturnValueIndex);
4343
// Nothing was set, return empty handle as per previous behaviour.
44-
Object raw_object = *slot;
44+
Tagged<Object> raw_object = *slot;
4545
if (IsTheHole(raw_object, isolate)) return Handle<V>();
4646
DCHECK(IsApiCallResultType(raw_object));
4747
return Handle<V>::cast(Handle<Object>(slot.location()));
4848
}
4949

50-
inline JSObject PropertyCallbackArguments::holder() const {
50+
inline Tagged<JSObject> PropertyCallbackArguments::holder() const {
5151
return JSObject::cast(*slot_at(T::kHolderIndex));
5252
}
5353

54-
inline Object PropertyCallbackArguments::receiver() const {
54+
inline Tagged<Object> PropertyCallbackArguments::receiver() const {
5555
return *slot_at(T::kThisIndex);
5656
}
5757

58-
inline JSReceiver FunctionCallbackArguments::holder() const {
58+
inline Tagged<JSReceiver> FunctionCallbackArguments::holder() const {
5959
return JSReceiver::cast(*slot_at(T::kHolderIndex));
6060
}
6161

@@ -84,7 +84,8 @@ inline JSReceiver FunctionCallbackArguments::holder() const {
8484
ExternalCallbackScope call_scope(ISOLATE, FUNCTION_ADDR(F)); \
8585
PropertyCallbackInfo<API_RETURN_TYPE> callback_info(values_);
8686

87-
Handle<Object> FunctionCallbackArguments::Call(CallHandlerInfo handler) {
87+
Handle<Object> FunctionCallbackArguments::Call(
88+
Tagged<CallHandlerInfo> handler) {
8889
Isolate* isolate = this->isolate();
8990
RCS_SCOPE(isolate, RuntimeCallCounterId::kFunctionCallback);
9091
v8::FunctionCallback f =

src/api/api-arguments.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace v8 {
1010
namespace internal {
1111

1212
PropertyCallbackArguments::PropertyCallbackArguments(
13-
Isolate* isolate, Object data, Object self, JSObject holder,
14-
Maybe<ShouldThrow> should_throw)
13+
Isolate* isolate, Tagged<Object> data, Tagged<Object> self,
14+
Tagged<JSObject> holder, Maybe<ShouldThrow> should_throw)
1515
: Super(isolate)
1616
#ifdef DEBUG
1717
,
@@ -29,16 +29,18 @@ PropertyCallbackArguments::PropertyCallbackArguments(
2929
slot_at(T::kShouldThrowOnErrorIndex).store(Smi::FromInt(value));
3030
// Here the hole is set as default value.
3131
// It cannot escape into js as it's removed in Call below.
32-
HeapObject the_hole_value = ReadOnlyRoots(isolate).the_hole_value();
32+
Tagged<HeapObject> the_hole_value = ReadOnlyRoots(isolate).the_hole_value();
3333
slot_at(T::kReturnValueIndex).store(the_hole_value);
3434
slot_at(T::kUnusedIndex).store(Smi::zero());
3535
DCHECK(IsHeapObject(*slot_at(T::kHolderIndex)));
3636
DCHECK(IsSmi(*slot_at(T::kIsolateIndex)));
3737
}
3838

3939
FunctionCallbackArguments::FunctionCallbackArguments(
40-
internal::Isolate* isolate, internal::Object data, internal::Object holder,
41-
internal::HeapObject new_target, internal::Address* argv, int argc)
40+
internal::Isolate* isolate, internal::Tagged<internal::Object> data,
41+
internal::Tagged<internal::Object> holder,
42+
internal::Tagged<internal::HeapObject> new_target, internal::Address* argv,
43+
int argc)
4244
: Super(isolate), argv_(argv), argc_(argc) {
4345
slot_at(T::kDataIndex).store(data);
4446
slot_at(T::kHolderIndex).store(holder);
@@ -47,7 +49,7 @@ FunctionCallbackArguments::FunctionCallbackArguments(
4749
// Here the hole is set as default value. It's converted to and not
4850
// directly exposed to js.
4951
// TODO(cbruni): Remove and/or use custom sentinel value.
50-
HeapObject the_hole_value = ReadOnlyRoots(isolate).the_hole_value();
52+
Tagged<HeapObject> the_hole_value = ReadOnlyRoots(isolate).the_hole_value();
5153
slot_at(T::kReturnValueIndex).store(the_hole_value);
5254
slot_at(T::kUnusedIndex).store(Smi::zero());
5355
DCHECK(IsHeapObject(*slot_at(T::kHolderIndex)));

src/api/api-arguments.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ class PropertyCallbackArguments final
8080
static constexpr int kIsolateIndex = T::kIsolateIndex;
8181
static constexpr int kShouldThrowOnErrorIndex = T::kShouldThrowOnErrorIndex;
8282

83-
PropertyCallbackArguments(Isolate* isolate, Object data, Object self,
84-
JSObject holder, Maybe<ShouldThrow> should_throw);
83+
PropertyCallbackArguments(Isolate* isolate, Tagged<Object> data,
84+
Tagged<Object> self, Tagged<JSObject> holder,
85+
Maybe<ShouldThrow> should_throw);
8586
inline ~PropertyCallbackArguments();
8687

8788
// Don't copy PropertyCallbackArguments, because they would both have the
@@ -157,8 +158,8 @@ class PropertyCallbackArguments final
157158
inline Handle<JSObject> CallPropertyEnumerator(
158159
Handle<InterceptorInfo> interceptor);
159160

160-
inline JSObject holder() const;
161-
inline Object receiver() const;
161+
inline Tagged<JSObject> holder() const;
162+
inline Tagged<Object> receiver() const;
162163

163164
#ifdef DEBUG
164165
// This stores current value of Isolate::javascript_execution_counter().
@@ -195,8 +196,10 @@ class FunctionCallbackArguments
195196
static_assert(T::kValuesOffset == offsetof(T, values_));
196197
static_assert(T::kLengthOffset == offsetof(T, length_));
197198

198-
FunctionCallbackArguments(Isolate* isolate, Object data, Object holder,
199-
HeapObject new_target, Address* argv, int argc);
199+
FunctionCallbackArguments(Isolate* isolate, Tagged<Object> data,
200+
Tagged<Object> holder,
201+
Tagged<HeapObject> new_target, Address* argv,
202+
int argc);
200203

201204
/*
202205
* The following Call function wraps the calling of all callbacks to handle
@@ -206,10 +209,10 @@ class FunctionCallbackArguments
206209
* and used if it's been set to anything inside the callback.
207210
* New style callbacks always use the return value.
208211
*/
209-
inline Handle<Object> Call(CallHandlerInfo handler);
212+
inline Handle<Object> Call(Tagged<CallHandlerInfo> handler);
210213

211214
private:
212-
inline JSReceiver holder() const;
215+
inline Tagged<JSReceiver> holder() const;
213216

214217
internal::Address* argv_;
215218
int const argc_;

src/api/api-inl.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
namespace v8 {
2020

2121
template <typename T>
22-
inline T ToCData(v8::internal::Object obj) {
22+
inline T ToCData(v8::internal::Tagged<v8::internal::Object> obj) {
2323
static_assert(sizeof(T) == sizeof(v8::internal::Address));
2424
if (obj == v8::internal::Smi::zero()) return nullptr;
2525
return reinterpret_cast<T>(
2626
v8::internal::Foreign::cast(obj)->foreign_address());
2727
}
2828

2929
template <>
30-
inline v8::internal::Address ToCData(v8::internal::Object obj) {
30+
inline v8::internal::Address ToCData(
31+
v8::internal::Tagged<v8::internal::Object> obj) {
3132
if (obj == v8::internal::Smi::zero()) return v8::internal::kNullAddress;
3233
return v8::internal::Foreign::cast(obj)->foreign_address();
3334
}
@@ -191,7 +192,7 @@ class V8_NODISCARD CallDepthScope {
191192
isolate_->set_next_v8_call_is_safe_for_termination(false);
192193
if (!context.IsEmpty()) {
193194
i::DisallowGarbageCollection no_gc;
194-
i::Context env = *Utils::OpenHandle(*context);
195+
i::Tagged<i::Context> env = *Utils::OpenHandle(*context);
195196
i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
196197
if (isolate->context().is_null() ||
197198
isolate->context()->native_context() != env->native_context()) {
@@ -276,7 +277,7 @@ class V8_NODISCARD InternalEscapableScope : public EscapableHandleScope {
276277

277278
template <typename T>
278279
void CopySmiElementsToTypedBuffer(T* dst, uint32_t length,
279-
i::FixedArray elements) {
280+
i::Tagged<i::FixedArray> elements) {
280281
for (uint32_t i = 0; i < length; ++i) {
281282
double value = i::Object::Number(elements->get(static_cast<int>(i)));
282283
// TODO(mslekova): Avoid converting back-and-forth when possible, e.g
@@ -287,7 +288,7 @@ void CopySmiElementsToTypedBuffer(T* dst, uint32_t length,
287288

288289
template <typename T>
289290
void CopyDoubleElementsToTypedBuffer(T* dst, uint32_t length,
290-
i::FixedDoubleArray elements) {
291+
i::Tagged<i::FixedDoubleArray> elements) {
291292
for (uint32_t i = 0; i < length; ++i) {
292293
double value = elements->get_scalar(static_cast<int>(i));
293294
// TODO(mslekova): There are certain cases, e.g. double->double, in which
@@ -311,13 +312,13 @@ bool CopyAndConvertArrayToCppBuffer(Local<Array> src, T* dst,
311312
}
312313

313314
i::DisallowGarbageCollection no_gc;
314-
i::JSArray obj = *reinterpret_cast<i::JSArray*>(*src);
315+
i::Tagged<i::JSArray> obj = *reinterpret_cast<i::JSArray*>(*src);
315316
if (i::Object::IterationHasObservableEffects(obj)) {
316317
// The array has a custom iterator.
317318
return false;
318319
}
319320

320-
i::FixedArrayBase elements = obj->elements();
321+
i::Tagged<i::FixedArrayBase> elements = obj->elements();
321322
switch (obj->GetElementsKind()) {
322323
case i::PACKED_SMI_ELEMENTS:
323324
CopySmiElementsToTypedBuffer(dst, length, i::FixedArray::cast(elements));
@@ -349,14 +350,15 @@ inline bool V8_EXPORT TryToCopyAndConvertArrayToCppBuffer(Local<Array> src,
349350

350351
namespace internal {
351352

352-
void HandleScopeImplementer::EnterContext(NativeContext context) {
353+
void HandleScopeImplementer::EnterContext(Tagged<NativeContext> context) {
353354
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
354355
DCHECK_EQ(entered_contexts_.size(), is_microtask_context_.size());
355356
entered_contexts_.push_back(context);
356357
is_microtask_context_.push_back(0);
357358
}
358359

359-
void HandleScopeImplementer::EnterMicrotaskContext(NativeContext context) {
360+
void HandleScopeImplementer::EnterMicrotaskContext(
361+
Tagged<NativeContext> context) {
360362
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
361363
DCHECK_EQ(entered_contexts_.size(), is_microtask_context_.size());
362364
entered_contexts_.push_back(context);

src/api/api-natives.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class V8_NODISCARD AccessCheckDisableScope {
172172
Handle<JSObject> obj_;
173173
};
174174

175-
Object GetIntrinsic(Isolate* isolate, v8::Intrinsic intrinsic) {
175+
Tagged<Object> GetIntrinsic(Isolate* isolate, v8::Intrinsic intrinsic) {
176176
Handle<Context> native_context = isolate->native_context();
177177
DCHECK(!native_context.is_null());
178178
switch (intrinsic) {
@@ -197,7 +197,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
197197
int max_number_of_properties = 0;
198198
TemplateInfoT info = *data;
199199
while (!info.is_null()) {
200-
Object props = info.property_accessors();
200+
Tagged<Object> props = info.property_accessors();
201201
if (!IsUndefined(props, isolate)) {
202202
max_number_of_properties += TemplateList::cast(props)->length();
203203
}
@@ -213,7 +213,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
213213
for (Handle<TemplateInfoT> temp(*data, isolate); !temp->is_null();
214214
temp = handle(temp->GetParent(isolate), isolate)) {
215215
// Accumulate accessors.
216-
Object maybe_properties = temp->property_accessors();
216+
Tagged<Object> maybe_properties = temp->property_accessors();
217217
if (!IsUndefined(maybe_properties, isolate)) {
218218
valid_descriptors = AccessorInfo::AppendUnique(
219219
isolate, handle(maybe_properties, isolate), array,
@@ -231,7 +231,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
231231
}
232232
}
233233

234-
Object maybe_property_list = data->property_list();
234+
Tagged<Object> maybe_property_list = data->property_list();
235235
if (IsUndefined(maybe_property_list, isolate)) return obj;
236236
Handle<TemplateList> properties(TemplateList::cast(maybe_property_list),
237237
isolate);
@@ -240,7 +240,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
240240
int i = 0;
241241
for (int c = 0; c < data->number_of_properties(); c++) {
242242
auto name = handle(Name::cast(properties->get(i++)), isolate);
243-
Object bit = properties->get(i++);
243+
Tagged<Object> bit = properties->get(i++);
244244
if (IsSmi(bit)) {
245245
PropertyDetails details(Smi::cast(bit));
246246
PropertyAttributes attributes = details.attributes();
@@ -297,15 +297,15 @@ MaybeHandle<JSObject> ProbeInstantiationsCache(
297297
}
298298

299299
if (serial_number < TemplateInfo::kFastTemplateInstantiationsCacheSize) {
300-
FixedArray fast_cache =
300+
Tagged<FixedArray> fast_cache =
301301
native_context->fast_template_instantiations_cache();
302302
Handle<Object> object{fast_cache->get(serial_number), isolate};
303303
if (IsTheHole(*object, isolate)) return {};
304304
return Handle<JSObject>::cast(object);
305305
}
306306
if (caching_mode == CachingMode::kUnlimited ||
307307
(serial_number < TemplateInfo::kSlowTemplateInstantiationsCacheSize)) {
308-
SimpleNumberDictionary slow_cache =
308+
Tagged<SimpleNumberDictionary> slow_cache =
309309
native_context->slow_template_instantiations_cache();
310310
InternalIndex entry = slow_cache->FindEntry(isolate, serial_number);
311311
if (entry.is_found()) {
@@ -361,7 +361,7 @@ void UncacheTemplateInstantiation(Isolate* isolate,
361361
if (serial_number < 0) return;
362362

363363
if (serial_number < TemplateInfo::kFastTemplateInstantiationsCacheSize) {
364-
FixedArray fast_cache =
364+
Tagged<FixedArray> fast_cache =
365365
native_context->fast_template_instantiations_cache();
366366
DCHECK(!IsUndefined(fast_cache->get(serial_number), isolate));
367367
fast_cache->set_undefined(serial_number);
@@ -379,12 +379,12 @@ void UncacheTemplateInstantiation(Isolate* isolate,
379379
}
380380
}
381381

382-
bool IsSimpleInstantiation(Isolate* isolate, ObjectTemplateInfo info,
383-
JSReceiver new_target) {
382+
bool IsSimpleInstantiation(Isolate* isolate, Tagged<ObjectTemplateInfo> info,
383+
Tagged<JSReceiver> new_target) {
384384
DisallowGarbageCollection no_gc;
385385

386386
if (!IsJSFunction(new_target)) return false;
387-
JSFunction fun = JSFunction::cast(new_target);
387+
Tagged<JSFunction> fun = JSFunction::cast(new_target);
388388
if (fun->shared()->function_data(kAcquireLoad) != info->constructor())
389389
return false;
390390
if (info->immutable_proto()) return false;
@@ -417,7 +417,7 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
417417
}
418418

419419
if (constructor.is_null()) {
420-
Object maybe_constructor_info = info->constructor();
420+
Tagged<Object> maybe_constructor_info = info->constructor();
421421
if (IsUndefined(maybe_constructor_info, isolate)) {
422422
constructor = isolate->object_function();
423423
} else {
@@ -559,7 +559,7 @@ MaybeHandle<JSFunction> InstantiateFunction(
559559

560560
void AddPropertyToPropertyList(Isolate* isolate, Handle<TemplateInfo> templ,
561561
int length, Handle<Object>* data) {
562-
Object maybe_list = templ->property_list();
562+
Tagged<Object> maybe_list = templ->property_list();
563563
Handle<TemplateList> list;
564564
if (IsUndefined(maybe_list, isolate)) {
565565
list = TemplateList::New(isolate, length);
@@ -677,7 +677,7 @@ void ApiNatives::AddAccessorProperty(Isolate* isolate,
677677
void ApiNatives::AddNativeDataProperty(Isolate* isolate,
678678
Handle<TemplateInfo> info,
679679
Handle<AccessorInfo> property) {
680-
Object maybe_list = info->property_accessors();
680+
Tagged<Object> maybe_list = info->property_accessors();
681681
Handle<TemplateList> list;
682682
if (IsUndefined(maybe_list, isolate)) {
683683
list = TemplateList::New(isolate, 1);

0 commit comments

Comments
 (0)