c6a16c10dd
With bytecode flushing and lazy feedback allocation, we need to call %PrepareForOptimization before we call %OptimizeFunctionOnNextCall, ideally after declaring the function. Bug: v8:8801, v8:8394, v8:9183 Change-Id: I3fb257282a30f6526a376a3afdedb44786320d34 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1648255 Commit-Queue: Mathias Bynens <mathias@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Reviewed-by: Mythri Alle <mythria@chromium.org> Cr-Commit-Position: refs/heads/master@{#62119}
69 lines
1.2 KiB
JavaScript
69 lines
1.2 KiB
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 Foo(a, b) {
|
|
var bname = "b";
|
|
this["a"] = a;
|
|
this[bname] = b;
|
|
this.x = this.a + this.b;
|
|
}
|
|
|
|
var f1 = new Foo(3, 4);
|
|
assertEquals(7, f1.x);
|
|
|
|
// SMIs
|
|
for (var i = 0; i < 6; i++) {
|
|
var f = new Foo(i, i + 2);
|
|
assertEquals(i + i + 2, f.x);
|
|
}
|
|
|
|
// derbles
|
|
for (var i = 0.25; i < 6.25; i++) {
|
|
var f = new Foo(i, i + 2);
|
|
assertEquals(i + i + 2, f.x);
|
|
}
|
|
|
|
// stirngs
|
|
for (var i = 0; i < 6; i++) {
|
|
var f = new Foo(i + '', i + 2 + '');
|
|
assertEquals(i + '' + (i + 2 + ''), f.x);
|
|
}
|
|
|
|
|
|
{
|
|
function Global(i) {
|
|
this.bla = i;
|
|
};
|
|
%PrepareFunctionForOptimization(Global);
|
|
Global(0);
|
|
Global(1);
|
|
%OptimizeFunctionOnNextCall(Global);
|
|
Global(2);
|
|
assertEquals(bla, 2);
|
|
}
|
|
|
|
|
|
{
|
|
function access(obj) {
|
|
obj.bla = 42;
|
|
}
|
|
access({a: 0});
|
|
access({b: 0});
|
|
access({c: 0});
|
|
access({d: 0});
|
|
access({e: 0});
|
|
var global = this;
|
|
function foo() {
|
|
access(global);
|
|
};
|
|
%PrepareFunctionForOptimization(foo);
|
|
;
|
|
foo();
|
|
foo();
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
foo();
|
|
}
|