2019-03-15 18:35:06 +05:30
|
|
|
// 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.
|
|
|
|
|
2024-03-30 09:54:35 +01:00
|
|
|
// Flags: --allow-natives-syntax --
|
2019-03-15 18:35:06 +05:30
|
|
|
|
|
|
|
(function NonExtensibleBetweenSetterAndGetter() {
|
|
|
|
o = {};
|
|
|
|
o.x = 42;
|
2019-08-16 11:32:46 +02:00
|
|
|
o.__defineGetter__('y', function() {});
|
2019-03-15 18:35:06 +05:30
|
|
|
Object.preventExtensions(o);
|
2019-08-16 11:32:46 +02:00
|
|
|
o.__defineSetter__('y', function() {});
|
2019-03-15 18:35:06 +05:30
|
|
|
o.x = 0.1;
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function InterleavedIntegrityLevel() {
|
|
|
|
o = {};
|
|
|
|
o.x = 42;
|
2019-08-16 11:32:46 +02:00
|
|
|
o.__defineSetter__('y', function() {});
|
2019-03-15 18:35:06 +05:30
|
|
|
Object.preventExtensions(o);
|
2019-08-16 11:32:46 +02:00
|
|
|
o.__defineGetter__('y', function() {
|
|
|
|
return 44;
|
|
|
|
});
|
2019-03-15 18:35:06 +05:30
|
|
|
Object.seal(o);
|
|
|
|
o.x = 0.1;
|
|
|
|
assertEquals(44, o.y);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function TryUpdateRepeatedIntegrityLevel() {
|
|
|
|
function C() {
|
|
|
|
this.x = 0;
|
|
|
|
this.x = 1;
|
|
|
|
Object.preventExtensions(this);
|
|
|
|
Object.seal(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const o1 = new C();
|
|
|
|
const o2 = new C();
|
|
|
|
const o3 = new C();
|
|
|
|
|
|
|
|
function f(o) {
|
|
|
|
return o.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Warm up the IC.
|
2019-08-16 11:32:46 +02:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2019-03-15 18:35:06 +05:30
|
|
|
f(o1);
|
|
|
|
f(o1);
|
|
|
|
f(o1);
|
|
|
|
|
|
|
|
// Reconfigure to double field.
|
|
|
|
o3.x = 0.1;
|
|
|
|
|
2025-04-29 08:03:15 +02:00
|
|
|
// Migrate o2 to the new shape. (This won't mark the new map as a migration target.)
|
2024-03-30 09:54:35 +01:00
|
|
|
assertEquals(o2, %TryMigrateInstance(o2));
|
2019-03-15 18:35:06 +05:30
|
|
|
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
2024-03-30 09:54:35 +01:00
|
|
|
// Calling the function with the deprecated o1 should still be ok.
|
2019-03-15 18:35:06 +05:30
|
|
|
f(o1);
|
|
|
|
|
2024-03-30 09:54:35 +01:00
|
|
|
// Ensure o1 is migrated (e.g. in jitless mode, where the unoptimized f won't
|
|
|
|
// necessarily migrate it).
|
2025-04-29 08:03:15 +02:00
|
|
|
|
|
|
|
let migrated = %TryMigrateInstance(o1);
|
|
|
|
if (typeof migrated === 'number') {
|
|
|
|
// No migration happened (o1 was already migrated).
|
|
|
|
migrated = o1;
|
|
|
|
}
|
|
|
|
|
|
|
|
assertEquals(o1, migrated);
|
2024-03-30 09:54:35 +01:00
|
|
|
|
2019-03-15 18:35:06 +05:30
|
|
|
assertTrue(%HaveSameMap(o1, o2));
|
|
|
|
assertTrue(%HaveSameMap(o1, o3));
|
|
|
|
})();
|