summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/regress/regress-store-transition-dict.js
blob: 8199a1d812500cf5d56c7ecae0d6750449269b13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2018 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() {
  function SetX(o, v) {
    o.x = v;
  }

  function SetY(o, v) {
    o.y = v;
  }

  var p = {};

  function Create() {
    var o = {__proto__:p, b:1, a:2};
    delete o.b;
    assertFalse(%HasFastProperties(o));
    return o;
  }

  for (var i = 0; i < 10; i++) {
    var o = Create();
    SetX(o, 13);
    SetY(o, 13);
  }

  Object.defineProperty(p, "x", {value:42, configurable: true, writable: false});

  for (var i = 0; i < 10; i++) {
    var o = Create();
    SetY(o, 13);
  }

  var o = Create();
  assertEquals(42, o.x);
  SetX(o, 13);
  assertEquals(42, o.x);
})();


(function() {
  var p1 = {a:10};
  Object.defineProperty(p1, "x", {value:42, configurable: true, writable: false});

  var p2 = {__proto__: p1, x:153};
  for (var i = 0; i < 2000; i++) {
    p1["p" + i] = 0;
    p2["p" + i] = 0;
  }
  assertFalse(%HasFastProperties(p1));
  assertFalse(%HasFastProperties(p2));

  function GetX(o) {
    return o.x;
  }
  function SetX(o, v) {
    o.x = v;
  }

  function Create() {
    var o = {__proto__:p2, b:1, a:2};
    return o;
  }

  for (var i = 0; i < 10; i++) {
    var o = Create();
    assertEquals(153, GetX(o));
    SetX(o, 13);
    assertEquals(13, GetX(o));
  }

  delete p2.x;
  assertFalse(%HasFastProperties(p1));
  assertFalse(%HasFastProperties(p2));

  var o = Create();
  assertEquals(42, GetX(o));
  SetX(o, 13);
  assertEquals(42, GetX(o));
})();