MCPcopy Create free account
hub / github.com/nodejs/node / test

Function test

deps/v8/test/mjsunit/maglev/get-prototype.js:7–32  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

5// Flags: --allow-natives-syntax --maglev
6
7function test(obj) {
8 var funs = [function(x) {
9 // Force a map check on x.x
10 x.size;
11 // Will be constantfolded
12 return Object.getPrototypeOf(x);
13 }, function(x) {
14 x.size;
15 try {
16 return Reflect.getPrototypeOf(x);
17 } catch(e) {
18 return x.__proto__;
19 }
20 }, function(x) {
21 x.size;
22 return x.__proto__;
23 }];
24 funs.forEach((f) => {
25 %PrepareFunctionForOptimization(f);
26 f(obj);
27 %OptimizeMaglevOnNextCall(f);
28 assertTrue(f(obj) == Object.getPrototypeOf(obj));
29 assertTrue(f(obj) == obj.__proto__);
30 assertFalse(f(obj) == 1);
31 });
32}
33
34test({});
35test({x:1});

Callers 1

get-prototype.jsFile · 0.70

Calls 4

fFunction · 0.70
forEachMethod · 0.65
assertTrueFunction · 0.50
assertFalseFunction · 0.50

Tested by

no test coverage detected