]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/proxy-inline-cache.js
3 // proxy -> target -> x
4 function cacheOnTarget() {
6 var proxy
= createProxy(target
);
8 var getX = function(o
) { return o
.x
; };
12 for (var i
= 0; i
< niters
; ++i
)
15 if (sum
!= 42 * niters
)
16 throw new Error("Incorrect result");
19 // proxy -> target -> proto -> x
20 function cacheOnPrototypeOfTarget() {
22 var target
= Object
.create(proto
);
23 var proxy
= createProxy(target
);
25 var getX = function(o
) { return o
.x
; };
29 for (var i
= 0; i
< niters
; ++i
)
32 if (sum
!= 42 * niters
)
33 throw new Error("Incorrect result");
36 // base -> proto (proxy) -> target -> x
37 function dontCacheOnProxyInPrototypeChain() {
39 var protoProxy
= createProxy(target
);
40 var base
= Object
.create(protoProxy
);
42 var getX = function(o
) { return o
.x
; };
46 for (var i
= 0; i
< niters
; ++i
)
49 if (sum
!= 42 * niters
)
50 throw new Error("Incorrect result");
53 // proxy -> target 1 -> proto (proxy) -> target 2 -> x
54 function dontCacheOnTargetOfProxyInPrototypeChainOfTarget() {
56 var protoProxy
= createProxy(target2
);
57 var target1
= Object
.create(protoProxy
);
58 var proxy
= createProxy(target1
);
60 var getX = function(o
) { return o
.x
; };
64 for (var i
= 0; i
< niters
; ++i
)
67 if (sum
!= 42 * niters
)
68 throw new Error("Incorrect result");
72 cacheOnPrototypeOfTarget();
73 dontCacheOnProxyInPrototypeChain();
74 dontCacheOnTargetOfProxyInPrototypeChainOfTarget();