haikuwebkit/JSTests/microbenchmarks/property-replace-and-setter...

33 lines
704 B
JavaScript
Raw Permalink Normal View History

Inline cache Replace and Setters on PureForwardingProxy https://bugs.webkit.org/show_bug.cgi?id=215250 Reviewed by Yusuke Suzuki. JSTests: * microbenchmarks/property-replace-and-setter-on-js-proxy.js: Added. (assert): (foo): Source/JavaScriptCore: We didn't used to cache any Puts on PureForwardingProxy. This patch implements Replace and JS/Custom Setters on PureForwardingProxy. We don't support Transition puts because in our current implementation different global objects will never share the same structure. This patch also aligns how our runtime and the ICs invoke Customs when the passed in |this| value is a JSProxy. For custom accessors, our runtime passes in the JSProxy, where our ICs used to pass in the target of the JSProxy, for the receiver value. For custom values, the IC behavior and the runtime were already aligned in passing in the property owner, which is the JSProxy's target. This patch aligns our IC behavior to match our runtime behavior. This patch also renames some of the registers in the IC code to clear up what they're used for. This is a 2.5x speedup on the microbenchmark I've added, and a 15-20% speedup on JetStream2's 3d-cube-SP. * bytecode/AccessCase.cpp: (JSC::AccessCase::generateWithGuard): (JSC::AccessCase::generateImpl): * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::create): * bytecode/GetterSetterAccessCase.h: * jit/JITOperations.cpp: * jit/Repatch.cpp: (JSC::tryCachePutByID): * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::originalStructureBeforePut): (JSC::CommonSlowPaths::putDirectWithReify): Canonical link: https://commits.webkit.org/228218@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265600 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-13 04:50:12 +00:00
//@ requireOptions("--exposeCustomSettersOnGlobalObjectForTesting=true")
function assert(b) {
if (!b)
throw new Error;
}
let global = this;
Object.defineProperty(global, "Y", {
set: function(v) {
assert(this === global);
assert(v === i + 1);
this._Y = v;
}
});
function foo(x, y, z, a) {
this.X = x;
this.Y = y;
this.testCustomAccessorSetter = z;
this.testCustomValueSetter = a;
}
noInline(foo);
let i;
for (i = 0; i < 1000000; ++i) {
foo(i, i + 1, i + 2, i + 3);
assert(global.X === i);
assert(global._Y === i + 1);
assert(global._testCustomAccessorSetter === i + 2);
assert(global._testCustomValueSetter === i + 3);
}