[isolate] Don't create unnecessary handles
IsAnyInitialArrayPrototype doesn't need an handlified input argument as it doesn't cause GC. This improves performance of MapData::MapData as canonical handle scope creation is expensive. Change-Id: I2e1a46354276857b64867ea3e994356faef8950e Bug: v8:9684 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2671659 Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#72500}
This commit is contained in:
parent
cffd8bc86a
commit
91ea05911e
@ -113,7 +113,7 @@ inline bool EnsureJSArrayWithWritableFastElements(Isolate* isolate,
|
||||
|
||||
// Adding elements to the array prototype would break code that makes sure
|
||||
// it has no elements. Handle that elsewhere.
|
||||
if (isolate->IsAnyInitialArrayPrototype(array)) return false;
|
||||
if (isolate->IsAnyInitialArrayPrototype(*array)) return false;
|
||||
|
||||
// Need to ensure that the arguments passed in args can be contained in
|
||||
// the array.
|
||||
@ -609,7 +609,7 @@ BUILTIN(ArrayUnshift) {
|
||||
DCHECK(array->map().is_extensible());
|
||||
DCHECK(!IsDictionaryElementsKind(array->GetElementsKind()));
|
||||
DCHECK(IsJSArrayFastElementMovingAllowed(isolate, *array));
|
||||
DCHECK(!isolate->IsAnyInitialArrayPrototype(array));
|
||||
DCHECK(!isolate->IsAnyInitialArrayPrototype(*array));
|
||||
|
||||
MatchArrayElementsKindToArguments(isolate, array, &args, 1,
|
||||
args.length() - 1);
|
||||
|
@ -1226,8 +1226,7 @@ bool SupportsFastArrayIteration(Isolate* isolate, Handle<Map> map) {
|
||||
return map->instance_type() == JS_ARRAY_TYPE &&
|
||||
IsFastElementsKind(map->elements_kind()) &&
|
||||
map->prototype().IsJSArray() &&
|
||||
isolate->IsAnyInitialArrayPrototype(
|
||||
handle(JSArray::cast(map->prototype()), isolate)) &&
|
||||
isolate->IsAnyInitialArrayPrototype(JSArray::cast(map->prototype())) &&
|
||||
Protectors::IsNoElementsIntact(isolate);
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,11 @@ Isolate::ExceptionScope::~ExceptionScope() {
|
||||
isolate_->set_pending_exception(*pending_exception_);
|
||||
}
|
||||
|
||||
bool Isolate::IsAnyInitialArrayPrototype(JSArray array) {
|
||||
DisallowGarbageCollection no_gc;
|
||||
return IsInAnyContext(array, Context::INITIAL_ARRAY_PROTOTYPE_INDEX);
|
||||
}
|
||||
|
||||
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \
|
||||
Handle<type> Isolate::name() { \
|
||||
return Handle<type>(raw_native_context().name(), this); \
|
||||
|
@ -3979,11 +3979,6 @@ void Isolate::UpdateNoElementsProtectorOnSetElement(Handle<JSObject> object) {
|
||||
Protectors::InvalidateNoElements(this);
|
||||
}
|
||||
|
||||
bool Isolate::IsAnyInitialArrayPrototype(Handle<JSArray> array) {
|
||||
DisallowGarbageCollection no_gc;
|
||||
return IsInAnyContext(*array, Context::INITIAL_ARRAY_PROTOTYPE_INDEX);
|
||||
}
|
||||
|
||||
static base::RandomNumberGenerator* ensure_rng_exists(
|
||||
base::RandomNumberGenerator** rng, int seed) {
|
||||
if (*rng == nullptr) {
|
||||
|
@ -1304,7 +1304,7 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
|
||||
}
|
||||
|
||||
// Returns true if array is the initial array prototype in any native context.
|
||||
bool IsAnyInitialArrayPrototype(Handle<JSArray> array);
|
||||
inline bool IsAnyInitialArrayPrototype(JSArray array);
|
||||
|
||||
std::unique_ptr<PersistentHandles> NewPersistentHandles();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user