test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

52 lines
1.3 KiB
JavaScript

function makePolyProtoInstanceWithNullPrototype() {
function foo() {
class C {
constructor() { this.x = 20; }
};
C.prototype.y = 42;
let result = new C;
return result;
}
for (let i = 0; i < 5; ++i)
foo();
let result = foo();
result.__proto__ = null;
return result;
}
function assert(b) {
if (!b)
throw new Error("Bad asssertion")
}
let instances = [
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
makePolyProtoInstanceWithNullPrototype(),
];
let p = undefined;
function validate(x) {
assert(x.x === 20);
assert(x.p === undefined);
}
noInline(validate);
let start = Date.now();
for (let i = 0; i < 100000; ++i) {
for (let i = 0; i < instances.length; ++i)
validate(instances[i]);
}
if (false)
print(Date.now() - start);