v8/test/mjsunit/compiler/serializer-transition-propagation.js
Georg Neis 9ac62c4dcc Introduce %IsBeingInterpreted
A call to this intrinsic will produce true in the interpreter and false
in optimized code. This is useful for writing tests.

Change-Id: I64d06ed062027e723eca82d6f879202244f21fdf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1939750
Commit-Queue: Georg Neis <neis@chromium.org>
Auto-Submit: Georg Neis <neis@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65240}
2019-11-28 14:20:45 +00:00

55 lines
950 B
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 --opt --no-always-opt
var expect_interpreted = true;
function C() {
this.a = 1;
assertEquals(expect_interpreted, %IsBeingInterpreted());
%TurbofanStaticAssert(this.x == 42);
};
function D() {
this.x = 42;
C.call(this);
};
function E() {
D.call(this);
}
function F() {
E.call(this);
};
function G() {
F.call(this);
};
function foo() {
new D;
}
%PrepareFunctionForOptimization(C);
%PrepareFunctionForOptimization(D);
%PrepareFunctionForOptimization(E);
%PrepareFunctionForOptimization(F);
%PrepareFunctionForOptimization(G);
%PrepareFunctionForOptimization(foo);
// Make 'this.x' access in C megamorhpic.
new C;
new D;
new E;
new F;
new G;
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
expect_interpreted = false;
foo();