d0136a5caa
Move the CompileWithBaseline interface to the Compiler class, as CompileBaseline, which will do the additional work of pre-compiling to bytecode, ensuring there is a feedback vector, and setting the code on the function closure. As a drive-by, fix v8_enable_trace_unoptimized to have a blank default value, so that v8_enable_trace_ignition/v8_enable_trace_baseline_exec can set it. Bug: v8:11420, v8:11429 Change-Id: If715161de71f7d9300f3fdcbb50cc678b1fcdfdf Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2697352 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#72819}
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
// 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.
|
|
|
|
// Flags: --allow-natives-syntax --sparkplug
|
|
|
|
// 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() + ")")();
|
|
%NeverOptimizeFunction(f1);
|
|
%NeverOptimizeFunction(f2);
|
|
|
|
%CompileBaseline(f1);
|
|
assertEquals(0, f1(0));
|
|
assertTrue(isBaseline(f1));
|
|
assertFalse(isBaseline(f2));
|
|
|
|
assertEquals(0, f2(0));
|
|
assertTrue(isBaseline(f1));
|
|
assertTrue(isBaseline(f2));
|
|
})();
|
|
|
|
// 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();
|
|
%NeverOptimizeFunction(f1);
|
|
%NeverOptimizeFunction(f2);
|
|
%NeverOptimizeFunction(f3);
|
|
|
|
assertEquals(0, f2(0));
|
|
%CompileBaseline(f1);
|
|
assertEquals(0, f1(0));
|
|
assertTrue(isBaseline(f1));
|
|
assertFalse(isBaseline(f2));
|
|
assertFalse(isBaseline(f3));
|
|
|
|
assertEquals(0, f3(0));
|
|
assertTrue(isBaseline(f3));
|
|
assertFalse(isBaseline(f2));
|
|
|
|
assertEquals(0, f2(0));
|
|
assertTrue(isBaseline(f2));
|
|
})();
|