serializer-accessors.js 1.12 KB
Newer Older
1 2 3 4
// 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.

5
// Flags: --allow-natives-syntax --turbofan --no-always-turbofan
6 7

var expect_interpreted = true;
8 9 10 11 12 13

class C {
  get prop() {
    return 42;
  }
  set prop(v) {
14 15 16 17 18 19
    if (!%IsDictPropertyConstTrackingEnabled()) {
      // TODO(v8:11457) If v8_dict_property_const_tracking is enabled, then
      // C.prototype is a dictionary mode object and we cannot inline the call
      // to this setter, yet.
      assertEquals(expect_interpreted, %IsBeingInterpreted());
    }
20 21 22 23 24 25 26
    %TurbofanStaticAssert(v === 43);
  }
}

const c = new C();

function foo() {
27
  assertEquals(expect_interpreted, %IsBeingInterpreted());
28 29 30 31 32 33 34 35 36
  %TurbofanStaticAssert(c.prop === 42);
  c.prop = 43;
}

%PrepareFunctionForOptimization(
    Object.getOwnPropertyDescriptor(C.prototype, 'prop').get);
%PrepareFunctionForOptimization(
    Object.getOwnPropertyDescriptor(C.prototype, 'prop').set);
%PrepareFunctionForOptimization(foo);
37

38 39
foo();
foo();
40
expect_interpreted = false;
41
%OptimizeFunctionOnNextCall(foo);
42
foo();