d7a8170d2d
Bug: v8:8801,v8:8394,v8:9183 Change-Id: If482c6a14f389d54c6ca3891aa7b8475f7a1fce1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660617 Commit-Queue: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Mythri Alle <mythria@chromium.org> Auto-Submit: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#62192}
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
// Copyright 2016 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 --gc-global
|
|
|
|
(function TestGCDuringToObjectForWith() {
|
|
function f(o) {
|
|
if (o == 'warmup') { return g() }
|
|
with (o) { return x }
|
|
}
|
|
%PrepareFunctionForOptimization(f);
|
|
function g() {
|
|
// Only a marker function serving as weak embedded object.
|
|
}
|
|
|
|
// Warm up 'f' so that weak embedded object 'g' will be used.
|
|
f('warmup');
|
|
f('warmup');
|
|
g = null;
|
|
|
|
// Test that 'f' behaves correctly unoptimized.
|
|
assertEquals(23, f({ x:23 }));
|
|
assertEquals(42, f({ x:42 }));
|
|
|
|
// Test that 'f' behaves correctly optimized.
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(65, f({ x:65 }));
|
|
|
|
// Test that 'f' behaves correctly on numbers.
|
|
Number.prototype.x = 99;
|
|
assertEquals(99, f(0));
|
|
|
|
// Make sure the next [[ToObject]] allocation triggers GC. This in turn will
|
|
// deoptimize 'f' because it has the weak embedded object 'g' in the code.
|
|
%SetAllocationTimeout(1000, 1, false);
|
|
assertEquals(99, f(0));
|
|
})();
|