v8/test/mjsunit/compiler/named-store.js
Georg Neis 95b09e3e98 [turbofan] Support named access on global proxy in serializer
Process feedback and hints for Lda/StaNamed bytecodes w.r.t. access on
the global proxy. This stores the property cells (or their absence) on
the JSGlobalProxyData.

Bug: v8:7790
Change-Id: Iadedea5494611c1b2ed38b6ce75687e084cc27f9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1499499
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60411}
2019-03-22 14:23:53 +00:00

60 lines
1.1 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 }
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) };
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
}