8309c3e6a5
This fixes a bug in the optimization concerning detached or re-attached global proxies. Bug: v8:7790 Change-Id: Ifd30b88361914430bb373d4b64a76e33ccde37e5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1809361 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#64035}
92 lines
2.4 KiB
JavaScript
92 lines
2.4 KiB
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
|
|
|
|
{
|
|
const realm = Realm.createAllowCrossRealmAccess();
|
|
const foo = Realm.eval(realm, "function foo() { return globalThis.foo }; foo");
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertSame(foo(), foo);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertSame(foo(), foo);
|
|
}
|
|
|
|
// detachGlobal, old map
|
|
{
|
|
const realm = Realm.createAllowCrossRealmAccess();
|
|
const foo = Realm.eval(realm, "function foo() { return globalThis.foo }; foo");
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertSame(foo(), foo);
|
|
Realm.detachGlobal(realm);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo);
|
|
}
|
|
|
|
// navigate, old map
|
|
{
|
|
const realm = Realm.createAllowCrossRealmAccess();
|
|
const foo = Realm.eval(realm, "function foo() { return globalThis.foo }; foo");
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertSame(foo(), foo);
|
|
Realm.navigate(realm);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo);
|
|
}
|
|
|
|
// detachGlobal, new map
|
|
{
|
|
const realm = Realm.createAllowCrossRealmAccess();
|
|
const foo = Realm.eval(realm, "function foo() { return globalThis.foo }; foo");
|
|
|
|
assertSame(foo(), foo);
|
|
Realm.detachGlobal(realm);
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertThrows(foo);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo);
|
|
}
|
|
|
|
// navigate, new map
|
|
{
|
|
const realm = Realm.createAllowCrossRealmAccess();
|
|
const foo = Realm.eval(realm, "function foo() { return globalThis.foo }; foo");
|
|
|
|
assertSame(foo(), foo);
|
|
Realm.navigate(realm);
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertThrows(foo);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo);
|
|
}
|
|
|
|
// detachGlobal, old and new map
|
|
{
|
|
const realm = Realm.createAllowCrossRealmAccess();
|
|
const foo = Realm.eval(realm, "function foo() { return globalThis.foo }; foo");
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertSame(foo(), foo);
|
|
Realm.detachGlobal(realm);
|
|
assertThrows(foo);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo);
|
|
}
|
|
|
|
// navigate, old and new map
|
|
{
|
|
const realm = Realm.createAllowCrossRealmAccess();
|
|
const foo = Realm.eval(realm, "function foo() { return globalThis.foo }; foo");
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertSame(foo(), foo);
|
|
Realm.navigate(realm);
|
|
assertThrows(foo);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertThrows(foo);
|
|
}
|