Commit 73401b11 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Eliminate some object casts

...mainly by giving a more precise type to global_proxy getters.

Change-Id: If4aef6b25baa2c641a45b177c59690e3ebfc3985
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1505578
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60072}
parent 365b637c
......@@ -6077,16 +6077,14 @@ MaybeLocal<Object> v8::Context::NewRemoteContext(
Utils::ApiCheck(access_check_info->named_interceptor() != i::Object(),
"v8::Context::NewRemoteContext",
"Global template needs to have access check handlers.");
i::Handle<i::JSGlobalProxy> global_proxy =
CreateEnvironment<i::JSGlobalProxy>(
isolate, nullptr, global_template, global_object, 0,
DeserializeInternalFieldsCallback(), nullptr);
i::Handle<i::JSObject> global_proxy = CreateEnvironment<i::JSGlobalProxy>(
isolate, nullptr, global_template, global_object, 0,
DeserializeInternalFieldsCallback(), nullptr);
if (global_proxy.is_null()) {
if (isolate->has_pending_exception()) isolate->clear_pending_exception();
return MaybeLocal<Object>();
}
return Utils::ToLocal(
scope.CloseAndEscape(i::Handle<i::JSObject>::cast(global_proxy)));
return Utils::ToLocal(scope.CloseAndEscape(global_proxy));
}
void v8::Context::SetSecurityToken(Local<Value> token) {
......
......@@ -349,8 +349,7 @@ void Bootstrapper::DetachGlobal(Handle<Context> env) {
env->GetErrorsThrown());
ReadOnlyRoots roots(isolate_);
Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy()),
isolate_);
Handle<JSGlobalProxy> global_proxy(env->global_proxy(), isolate_);
global_proxy->set_native_context(roots.null_value());
JSObject::ForceSetPrototype(global_proxy, isolate_->factory()->null_value());
global_proxy->map()->SetConstructor(roots.null_value());
......@@ -5306,10 +5305,8 @@ bool Genesis::InstallExtension(Isolate* isolate,
bool Genesis::ConfigureGlobalObjects(
v8::Local<v8::ObjectTemplate> global_proxy_template) {
Handle<JSObject> global_proxy(
JSObject::cast(native_context()->global_proxy()), isolate());
Handle<JSObject> global_object(
JSObject::cast(native_context()->global_object()), isolate());
Handle<JSObject> global_proxy(native_context()->global_proxy(), isolate());
Handle<JSObject> global_object(native_context()->global_object(), isolate());
if (!global_proxy_template.IsEmpty()) {
// Configure the global proxy object.
......
......@@ -67,8 +67,7 @@ JSNativeContextSpecialization::JSNativeContextSpecialization(
broker_(broker),
flags_(flags),
global_object_(native_context->global_object(), jsgraph->isolate()),
global_proxy_(JSGlobalProxy::cast(native_context->global_proxy()),
jsgraph->isolate()),
global_proxy_(native_context->global_proxy(), jsgraph->isolate()),
dependencies_(dependencies),
zone_(zone),
shared_zone_(shared_zone),
......
......@@ -94,11 +94,10 @@ Handle<JSGlobalObject> Isolate::global_object() {
return handle(context()->global_object(), this);
}
Handle<JSObject> Isolate::global_proxy() {
Handle<JSGlobalProxy> Isolate::global_proxy() {
return handle(context()->global_proxy(), this);
}
Isolate::ExceptionScope::ExceptionScope(Isolate* isolate)
: isolate_(isolate),
pending_exception_(isolate_->pending_exception(), isolate_) {}
......
......@@ -640,7 +640,7 @@ class Isolate final : private HiddenFactory {
inline Handle<JSGlobalObject> global_object();
// Returns the global proxy object of the current context.
inline Handle<JSObject> global_proxy();
inline Handle<JSGlobalProxy> global_proxy();
static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); }
void FreeThreadResources() { thread_local_top()->Free(); }
......
......@@ -458,7 +458,7 @@ ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset)
ACCESSORS(JSFunction, raw_feedback_cell, FeedbackCell, kFeedbackCellOffset)
ACCESSORS(JSGlobalObject, native_context, NativeContext, kNativeContextOffset)
ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset)
ACCESSORS(JSGlobalObject, global_proxy, JSGlobalProxy, kGlobalProxyOffset)
ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset)
......@@ -954,7 +954,7 @@ Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttributes(
}
bool JSGlobalObject::IsDetached() {
return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(*this);
return global_proxy()->IsDetachedFrom(*this);
}
bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject global) const {
......
......@@ -1159,7 +1159,7 @@ class JSGlobalObject : public JSObject {
DECL_ACCESSORS(native_context, NativeContext)
// [global proxy]: the global proxy object of the context
DECL_ACCESSORS(global_proxy, JSObject)
DECL_ACCESSORS(global_proxy, JSGlobalProxy)
// Gets global object properties.
inline GlobalDictionary global_dictionary();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment