2021-02-12 08:41:14 +00:00
|
|
|
// Copyright 2021 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.
|
|
|
|
|
2021-03-18 15:34:40 +00:00
|
|
|
// Flags: --allow-natives-syntax --sparkplug --no-always-sparkplug
|
2021-02-12 08:41:14 +00:00
|
|
|
|
|
|
|
// Tier-up across Realms
|
|
|
|
|
|
|
|
// Ensure a feedback vector is created when sharing baseline code.
|
|
|
|
(function() {
|
|
|
|
function factory1() {
|
|
|
|
return function(a) {
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var realm1 = Realm.createAllowCrossRealmAccess();
|
|
|
|
var realm2 = Realm.createAllowCrossRealmAccess();
|
|
|
|
|
|
|
|
let f1 = Realm.eval(realm1, "(" + factory1.toString() + ")")();
|
|
|
|
let f2 = Realm.eval(realm2, "(" + factory1.toString() + ")")();
|
2021-02-17 13:41:35 +00:00
|
|
|
%NeverOptimizeFunction(f1);
|
|
|
|
%NeverOptimizeFunction(f2);
|
2021-02-12 08:41:14 +00:00
|
|
|
|
|
|
|
%CompileBaseline(f1);
|
|
|
|
assertEquals(0, f1(0));
|
2021-02-12 11:41:57 +00:00
|
|
|
assertTrue(isBaseline(f1));
|
|
|
|
assertFalse(isBaseline(f2));
|
2021-02-12 08:41:14 +00:00
|
|
|
|
|
|
|
assertEquals(0, f2(0));
|
2021-02-12 11:41:57 +00:00
|
|
|
assertTrue(isBaseline(f1));
|
|
|
|
assertTrue(isBaseline(f2));
|
2021-02-12 08:41:14 +00:00
|
|
|
})();
|
|
|
|
|
|
|
|
// Ensure a feedback vector is created when sharing baseline code and a closure
|
|
|
|
// feedback cell array already exists.
|
|
|
|
(function() {
|
|
|
|
function factory2() {
|
|
|
|
return function(a) {
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var realm1 = Realm.createAllowCrossRealmAccess();
|
|
|
|
var realm2 = Realm.createAllowCrossRealmAccess();
|
|
|
|
|
|
|
|
let f1 = Realm.eval(realm1, "(" + factory2.toString() + ")")();
|
|
|
|
let realmFactory = Realm.eval(realm2, "(" + factory2.toString() + ")");
|
|
|
|
let f2 = realmFactory();
|
|
|
|
let f3 = realmFactory();
|
2021-02-17 13:41:35 +00:00
|
|
|
%NeverOptimizeFunction(f1);
|
|
|
|
%NeverOptimizeFunction(f2);
|
|
|
|
%NeverOptimizeFunction(f3);
|
2021-02-12 08:41:14 +00:00
|
|
|
|
|
|
|
assertEquals(0, f2(0));
|
|
|
|
%CompileBaseline(f1);
|
|
|
|
assertEquals(0, f1(0));
|
2021-02-12 11:41:57 +00:00
|
|
|
assertTrue(isBaseline(f1));
|
|
|
|
assertFalse(isBaseline(f2));
|
|
|
|
assertFalse(isBaseline(f3));
|
2021-02-12 08:41:14 +00:00
|
|
|
|
|
|
|
assertEquals(0, f3(0));
|
2021-02-12 11:41:57 +00:00
|
|
|
assertTrue(isBaseline(f3));
|
|
|
|
assertFalse(isBaseline(f2));
|
2021-02-12 08:41:14 +00:00
|
|
|
|
|
|
|
assertEquals(0, f2(0));
|
2021-02-12 11:41:57 +00:00
|
|
|
assertTrue(isBaseline(f2));
|
2021-02-12 08:41:14 +00:00
|
|
|
})();
|