2015-04-21 15:13:13 +00:00
|
|
|
// 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.
|
|
|
|
|
2019-03-22 12:03:20 +00:00
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
|
2015-04-21 15:13:13 +00:00
|
|
|
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++) {
|
2019-06-12 14:00:50 +00:00
|
|
|
var f = new Foo(i + '', i + 2 + '');
|
|
|
|
assertEquals(i + '' + (i + 2 + ''), f.x);
|
2015-04-21 15:13:13 +00:00
|
|
|
}
|
2019-03-22 12:03:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
{
|
2019-06-12 14:00:50 +00:00
|
|
|
function Global(i) {
|
|
|
|
this.bla = i;
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(Global);
|
2019-03-22 12:03:20 +00:00
|
|
|
Global(0);
|
|
|
|
Global(1);
|
|
|
|
%OptimizeFunctionOnNextCall(Global);
|
|
|
|
Global(2);
|
|
|
|
assertEquals(bla, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
2019-06-12 14:00:50 +00:00
|
|
|
function access(obj) {
|
|
|
|
obj.bla = 42;
|
|
|
|
}
|
2019-03-22 12:03:20 +00:00
|
|
|
access({a: 0});
|
|
|
|
access({b: 0});
|
|
|
|
access({c: 0});
|
|
|
|
access({d: 0});
|
|
|
|
access({e: 0});
|
|
|
|
var global = this;
|
2019-06-12 14:00:50 +00:00
|
|
|
function foo() {
|
|
|
|
access(global);
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
|
|
;
|
2019-03-22 12:03:20 +00:00
|
|
|
foo();
|
|
|
|
foo();
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo();
|
|
|
|
}
|