node/deps/v8/test/mjsunit/cross-realm-builtin-call.js
Matheus Marchini 2883c855e0
deps: update V8 to 8.1.307.20
PR-URL: https://github.com/nodejs/node/pull/32116
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-03-18 16:23:22 -07:00

30 lines
896 B
JavaScript

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --allow-natives-syntax
function check(x) { assertEquals(x, "foo"); }
var r = Realm.createAllowCrossRealmAccess();
var f = Realm.eval(r, `
function f(func) {
// The call to Function.prototype.apply is across native contexts so
// cannot be elided. However the compiler should be able to call the
// builtin directly rather than via the trampoline Code object. This isn't
// easy to test, but here we at least check that it doesn't crash due to
// calling a builtin Code object incorrectly (Function.Prototype.apply).
return func.apply(undefined, ["foo"]);
}
f;`);
%PrepareFunctionForOptimization(f);
f(check);
f(check);
%OptimizeFunctionOnNextCall(f);
f(check);