1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4//
5// Flags: --allow-natives-syntax
6
7var s = %CreatePrivateOwnSymbol("s");
8var s1 = %CreatePrivateOwnSymbol("s1");
9
10function TestSimple() {
11  var p = {}
12  p[s] = "moo";
13
14  var o = Object.create(p);
15
16  assertEquals(undefined, o[s]);
17  assertEquals("moo", p[s]);
18
19  o[s] = "bow-wow";
20  assertEquals("bow-wow", o[s]);
21  assertEquals("moo", p[s]);
22}
23
24TestSimple();
25
26
27function TestICs() {
28  var p = {}
29  p[s] = "moo";
30
31
32  var o = Object.create(p);
33  o[s1] = "bow-wow";
34  function checkNonOwn(o) {
35    assertEquals(undefined, o[s]);
36    assertEquals("bow-wow", o[s1]);
37  }
38
39  checkNonOwn(o);
40
41  // Test monomorphic/optimized.
42  for (var i = 0; i < 1000; i++) {
43    checkNonOwn(o);
44  }
45
46  // Test non-monomorphic.
47  for (var i = 0; i < 1000; i++) {
48    var oNew = Object.create(p);
49    oNew["s" + i] = i;
50    oNew[s1] = "bow-wow";
51    checkNonOwn(oNew);
52  }
53}
54
55TestICs();
56