v8/test/mjsunit/regress/regress-3969.js
Ross McIlroy ac7c82f905 [cleanup] Add %PrepareForOptimization to some more mjsunit tests.
Bug: v8:8801,v8:8394,v8:9183
Change-Id: If6a4f39991f222337f1c49bd0439e9669d89b030
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660486
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62181}
2019-06-14 13:55:11 +00:00

38 lines
977 B
JavaScript

// Copyright 2015 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 Inner() {
this.property = "OK";
this.o2 = 1;
}
function Outer(inner) {
this.inner = inner;
}
var inner = new Inner();
var outer = new Outer(inner);
Outer.prototype.boom = function() {
return this.inner.property;
};
%PrepareFunctionForOptimization(Outer.prototype.boom);
assertEquals("OK", outer.boom());
assertEquals("OK", outer.boom());
%OptimizeFunctionOnNextCall(Outer.prototype.boom);
assertEquals("OK", outer.boom());
inner = undefined;
%SetAllocationTimeout(0 /*interval*/, 2 /*timeout*/);
// Call something that will do GC while holding a handle to outer's map.
// The key is that this lets inner's map die while keeping outer's map alive.
delete outer.inner;
outer = new Outer({field: 1.51, property: "OK"});
assertEquals("OK", outer.boom());