зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1655465 - Part 5: Support ObjectHasPrototype in CacheIR. r=jandem
Inling `ObjectHasPrototype()` using the `GuardProto` CacheIR op for the normal case when the prototype chain wasn't modified. Also change `intrinsic_ObjectHasPrototype()` to expect that both objects are `NativeObject`, because then we don't need to handle proxies in CacheIR. Drive-by change: - Use `staticPrototype()` in ObjectOperations-inl.h instead of effectively inlining it. Differential Revision: https://phabricator.services.mozilla.com/D84984
This commit is contained in:
Родитель
6a4b86eac3
Коммит
ee9dcbcd12
|
@ -5999,6 +5999,40 @@ AttachDecision CallIRGenerator::tryAttachSubstringKernel(
|
|||
return AttachDecision::Attach;
|
||||
}
|
||||
|
||||
AttachDecision CallIRGenerator::tryAttachObjectHasPrototype(
|
||||
HandleFunction callee) {
|
||||
// Self-hosted code calls this with (object, object) arguments.
|
||||
MOZ_ASSERT(argc_ == 2);
|
||||
MOZ_ASSERT(args_[0].isObject());
|
||||
MOZ_ASSERT(args_[1].isObject());
|
||||
|
||||
auto* obj = &args_[0].toObject().as<NativeObject>();
|
||||
auto* proto = &args_[1].toObject().as<NativeObject>();
|
||||
|
||||
// Only attach when obj.__proto__ is proto.
|
||||
if (obj->staticPrototype() != proto) {
|
||||
return AttachDecision::NoAction;
|
||||
}
|
||||
|
||||
// Initialize the input operand.
|
||||
Int32OperandId argcId(writer.setInputOperandId(0));
|
||||
|
||||
// Note: we don't need to call emitNativeCalleeGuard for intrinsics.
|
||||
|
||||
ValOperandId arg0Id = writer.loadArgumentFixedSlot(ArgumentKind::Arg0, argc_);
|
||||
ObjOperandId objId = writer.guardToObject(arg0Id);
|
||||
|
||||
writer.guardProto(objId, proto);
|
||||
writer.loadBooleanResult(true);
|
||||
|
||||
// No type monitoring because this always returns a boolean.
|
||||
writer.returnFromIC();
|
||||
cacheIRStubKind_ = BaselineCacheIRStubKind::Regular;
|
||||
|
||||
trackAttached("ObjectHasPrototype");
|
||||
return AttachDecision::Attach;
|
||||
}
|
||||
|
||||
AttachDecision CallIRGenerator::tryAttachString(HandleFunction callee) {
|
||||
// Need a single string argument.
|
||||
// TODO(Warp): Support all or more conversions to strings.
|
||||
|
@ -7744,6 +7778,8 @@ AttachDecision CallIRGenerator::tryAttachInlinableNative(
|
|||
return tryAttachNewRegExpStringIterator(callee);
|
||||
case InlinableNative::IntrinsicArrayIteratorPrototypeOptimizable:
|
||||
return tryAttachArrayIteratorPrototypeOptimizable(callee);
|
||||
case InlinableNative::IntrinsicObjectHasPrototype:
|
||||
return tryAttachObjectHasPrototype(callee);
|
||||
|
||||
// RegExp natives.
|
||||
case InlinableNative::IsRegExpObject:
|
||||
|
|
|
@ -1641,6 +1641,7 @@ class MOZ_RAII CallIRGenerator : public IRGenerator {
|
|||
AttachDecision tryAttachRegExpInstanceOptimizable(HandleFunction callee);
|
||||
AttachDecision tryAttachGetFirstDollarIndex(HandleFunction callee);
|
||||
AttachDecision tryAttachSubstringKernel(HandleFunction callee);
|
||||
AttachDecision tryAttachObjectHasPrototype(HandleFunction callee);
|
||||
AttachDecision tryAttachString(HandleFunction callee);
|
||||
AttachDecision tryAttachStringChar(HandleFunction callee, StringChar kind);
|
||||
AttachDecision tryAttachStringCharCodeAt(HandleFunction callee);
|
||||
|
|
|
@ -53,7 +53,7 @@ inline bool GetPrototype(JSContext* cx, JS::Handle<JSObject*> obj,
|
|||
return Proxy::getPrototype(cx, obj, protop);
|
||||
}
|
||||
|
||||
protop.set(obj->taggedProto().toObjectOrNull());
|
||||
protop.set(obj->staticPrototype());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -730,14 +730,13 @@ static bool intrinsic_ObjectHasPrototype(JSContext* cx, unsigned argc,
|
|||
Value* vp) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 2);
|
||||
RootedObject obj(cx, &args[0].toObject());
|
||||
RootedObject proto(cx, &args[1].toObject());
|
||||
|
||||
RootedObject actualProto(cx);
|
||||
if (!GetPrototype(cx, obj, &actualProto)) {
|
||||
return false;
|
||||
}
|
||||
// Self-hosted code calls this intrinsic with builtin prototypes. These are
|
||||
// always native objects.
|
||||
auto* obj = &args[0].toObject().as<NativeObject>();
|
||||
auto* proto = &args[1].toObject().as<NativeObject>();
|
||||
|
||||
JSObject* actualProto = obj->staticPrototype();
|
||||
args.rval().setBoolean(actualProto == proto);
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче