1function foo(o, prototype) { 2 return o instanceof prototype; 3} 4 5noInline(foo); 6 7function test(o, prototype, expected) { 8 var actual = foo(o, prototype); 9 if (actual != expected) 10 throw new Error("bad result: " + actual); 11} 12 13function Foo() { } 14 15function Bar() { } 16Bar.prototype = new Foo(); 17 18for (var i = 0; i < 10000; ++i) { 19 test({}, Object, true); 20 test({}, Array, false); 21 test({}, String, false); 22 test({}, Foo, false); 23 test({}, Bar, false); 24 test([], Object, true); 25 test([], Array, true); 26 test([], String, false); 27 test([], Foo, false); 28 test([], Bar, false); 29 test(new Foo(), Object, true); 30 test(new Foo(), Array, false); 31 test(new Foo(), String, false); 32 test(new Foo(), Foo, true); 33 test(new Foo(), Bar, false); 34 test(new Bar(), Object, true); 35 test(new Bar(), Array, false); 36 test(new Bar(), String, false); 37 test(new Bar(), Foo, true); 38 test(new Bar(), Bar, true); 39} 40