Bug 1328076 - Attach primitive IC for more properties. r=jandem

This commit is contained in:
Tom Schuster 2017-01-04 12:07:58 +01:00
Родитель ee102bc0e9
Коммит e5006909b7
2 изменённых файлов: 61 добавлений и 10 удалений

Просмотреть файл

@ -0,0 +1,47 @@
function shadowing() {
Object.prototype.x = 1;
for (var i = 0; i < 20; i++) {
var x = "a".x;
assertEq(x, i <= 15 ? 1 : "hello");
if (i == 15) {
String.prototype.x = "hello";
}
}
delete Object.prototype.x;
}
function deleted() {
String.prototype.y = 1;
for (var i = 0; i < 20; i++) {
var y = "a".y;
assertEq(y, i <= 15 ? 1 : undefined);
if (i == 15) {
delete String.prototype.y;
}
}
delete String.prototype.y;
}
function notdefined() {
for (var i = 0; i < 20; i++) {
var z = "a".z;
assertEq(z, i <= 15 ? undefined : "test");
if (i == 15) {
String.prototype.z = "test";
}
}
delete String.prototype.z;
}
shadowing();
deleted();
notdefined();

Просмотреть файл

@ -854,22 +854,26 @@ GetPropIRGenerator::tryAttachPrimitive(ValOperandId valId, HandleId id)
if (!proto)
return false;
// Instantiate this property, for use during Ion compilation.
if (IsIonEnabled(cx_))
EnsureTrackPropertyTypes(cx_, proto, id);
// For now, only look for properties directly set on the prototype.
Shape* shape = proto->lookup(cx_, id);
if (!shape || !shape->hasSlot() || !shape->hasDefaultGetter())
RootedShape shape(cx_);
RootedNativeObject holder(cx_);
NativeGetPropCacheability type = CanAttachNativeGetProp(cx_, proto, id, &holder, &shape, pc_,
engine_, canAttachGetter_,
isTemporarilyUnoptimizable_);
if (type != CanAttachReadSlot)
return false;
if (holder) {
// Instantiate this property, for use during Ion compilation.
if (IsIonEnabled(cx_))
EnsureTrackPropertyTypes(cx_, holder, id);
}
writer.guardType(valId, primitiveType);
maybeEmitIdGuard(id);
ObjOperandId protoId = writer.loadObject(proto);
writer.guardShape(protoId, proto->lastProperty());
EmitLoadSlotResult(writer, protoId, proto, shape);
writer.typeMonitorResult();
EmitReadSlotResult(writer, proto, holder, shape, protoId);
EmitReadSlotReturn(writer, proto, holder, shape);
return true;
}