<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205535] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205535">205535</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-09-06 19:48:35 -0700 (Tue, 06 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>ProxyObject's structure should not have ObjectPrototype as its prototype and it should not have special behavior for intercepting &quot;__proto__&quot;
https://bugs.webkit.org/show_bug.cgi?id=161558

Reviewed by Benjamin Poulain.

JSTests:

* stress/proxy-get-prototype-of.js:
* stress/proxy-set-prototype-of.js:
(let.handler.setPrototypeOf): Deleted.
* stress/proxy-underscore-proto.js: Added.
(assert):

Source/JavaScriptCore:

ProxyObject had ObjectPrototype as its direct prototype.
This could lead to infinite loops when doing a getDirectPrototype()
loop.

Fixing this bug revealed another bug, which I made when implementing Proxy.
We should not special case &quot;__proto__&quot; in get and set for Proxy Object's
hooks. &quot;__proto__&quot; should just go through the normal set and get path.

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/ProxyObject.cpp:
(JSC::performProxyGet):
(JSC::ProxyObject::put):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestsstressproxygetprototypeofjs">trunk/JSTests/stress/proxy-get-prototype-of.js</a></li>
<li><a href="#trunkJSTestsstressproxysetprototypeofjs">trunk/JSTests/stress/proxy-set-prototype-of.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeProxyObjectcpp">trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestsstressproxydontinfiniteloopjs">trunk/JSTests/stress/proxy-dont-infinite-loop.js</a></li>
<li><a href="#trunkJSTestsstressproxyunderscoreprotojs">trunk/JSTests/stress/proxy-underscore-proto.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (205534 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-09-07 02:22:44 UTC (rev 205534)
+++ trunk/JSTests/ChangeLog        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2016-09-06  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        ProxyObject's structure should not have ObjectPrototype as its prototype and it should not have special behavior for intercepting &quot;__proto__&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=161558
+
+        Reviewed by Benjamin Poulain.
+
+        * stress/proxy-get-prototype-of.js:
+        * stress/proxy-set-prototype-of.js:
+        (let.handler.setPrototypeOf): Deleted.
+        * stress/proxy-underscore-proto.js: Added.
+        (assert):
+
+2016-09-06  Saam Barati  &lt;sbarati@apple.com&gt;
+
</ins><span class="cx">         Make JSMap and JSSet faster
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=160989
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkJSTestsstressproxydontinfiniteloopjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/proxy-dont-infinite-loop.js (0 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/proxy-dont-infinite-loop.js                                (rev 0)
+++ trunk/JSTests/stress/proxy-dont-infinite-loop.js        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+function foo() {
+    let target = {
+      __proto__: null
+    };
+    let proxy = new Proxy(target, {
+        get(...args) {
+            return Reflect.get(...args);
+        }
+    });
+    Object.prototype.__proto__ = {
+       __proto__: proxy,
+    };
+
+    let a = {};
+    a.test;
+}
+foo();
</ins></span></pre></div>
<a id="trunkJSTestsstressproxygetprototypeofjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/proxy-get-prototype-of.js (205534 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/proxy-get-prototype-of.js        2016-09-07 02:22:44 UTC (rev 205534)
+++ trunk/JSTests/stress/proxy-get-prototype-of.js        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -18,7 +18,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -48,7 +47,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -83,7 +81,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -109,7 +106,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -137,7 +133,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -165,7 +160,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -194,7 +188,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -224,7 +217,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -255,7 +247,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let result = get();
</span><span class="lines">@@ -285,7 +276,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             let result = get();
</span><span class="lines">@@ -308,7 +298,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             assert(get() === proto);
</span><span class="lines">@@ -333,7 +322,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             assert(get() === proto);
</span><span class="lines">@@ -360,7 +348,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             assert(get() === proto);
</span><span class="lines">@@ -387,7 +374,6 @@
</span><span class="cx">         let getters = [
</span><span class="cx">             () =&gt; Reflect.getPrototypeOf(proxy),
</span><span class="cx">             () =&gt; Object.getPrototypeOf(proxy),
</span><del>-            () =&gt; proxy.__proto__,
</del><span class="cx">         ];
</span><span class="cx">         for (let get of getters) {
</span><span class="cx">             assert(get() === proto);
</span></span></pre></div>
<a id="trunkJSTestsstressproxysetprototypeofjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/proxy-set-prototype-of.js (205534 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/proxy-set-prototype-of.js        2016-09-07 02:22:44 UTC (rev 205534)
+++ trunk/JSTests/stress/proxy-set-prototype-of.js        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -18,7 +18,6 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             () =&gt; Reflect.setPrototypeOf(proxy, {}),
</span><span class="cx">             () =&gt; Object.setPrototypeOf(proxy, {}),
</span><del>-            () =&gt; proxy.__proto__ = {},
</del><span class="cx">         ];
</span><span class="cx">         for (let set of setters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -48,7 +47,6 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             () =&gt; Reflect.setPrototypeOf(proxy, {}),
</span><span class="cx">             () =&gt; Object.setPrototypeOf(proxy, {}),
</span><del>-            () =&gt; proxy.__proto__ = {},
</del><span class="cx">         ];
</span><span class="cx">         for (let set of setters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -75,7 +73,6 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             () =&gt; Reflect.setPrototypeOf(proxy, {}),
</span><span class="cx">             () =&gt; Object.setPrototypeOf(proxy, {}),
</span><del>-            () =&gt; proxy.__proto__ = {},
</del><span class="cx">         ];
</span><span class="cx">         for (let set of setters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -104,15 +101,13 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             () =&gt; Reflect.setPrototypeOf(proxy, {}),
</span><span class="cx">             () =&gt; Object.setPrototypeOf(proxy, {}),
</span><del>-            () =&gt; proxy.__proto__ = {},
</del><span class="cx">         ];
</span><span class="cx">         for (let set of setters) {
</span><span class="cx">             let result = set();
</span><span class="cx">             assert(result);
</span><span class="cx">             assert(Reflect.getPrototypeOf(target) === null);
</span><del>-            // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-            //assert(Reflect.getPrototypeOf(proxy) === null);
-            //assert(proxy.__proto__ === null);
</del><ins>+            assert(Reflect.getPrototypeOf(proxy) === null);
+            assert(proxy.__proto__ === undefined);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -133,15 +128,13 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             () =&gt; Reflect.setPrototypeOf(proxy, obj),
</span><span class="cx">             () =&gt; Object.setPrototypeOf(proxy, obj),
</span><del>-            () =&gt; proxy.__proto__ = obj,
</del><span class="cx">         ];
</span><span class="cx">         for (let set of setters) {
</span><span class="cx">             let result = set();
</span><span class="cx">             assert(result);
</span><span class="cx">             assert(Reflect.getPrototypeOf(target) === obj);
</span><del>-            // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-            //assert(Reflect.getPrototypeOf(proxy) === obj);
-            //assert(proxy.__proto__ === obj);
</del><ins>+            assert(Reflect.getPrototypeOf(proxy) === obj);
+            assert(proxy.__proto__ === obj);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -167,7 +160,6 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             () =&gt; Reflect.setPrototypeOf(proxy, obj),
</span><span class="cx">             () =&gt; Object.setPrototypeOf(proxy, obj),
</span><del>-            () =&gt; proxy.__proto__ = obj,
</del><span class="cx">         ];
</span><span class="cx">         for (let set of setters) {
</span><span class="cx">             let threw = false;
</span><span class="lines">@@ -182,9 +174,8 @@
</span><span class="cx"> 
</span><span class="cx">             assert(threw);
</span><span class="cx">             assert(Reflect.getPrototypeOf(target) === null);
</span><del>-            // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-            //assert(Reflect.getPrototypeOf(proxy) === null);
-            //assert(proxy.__proto__ === null);
</del><ins>+            assert(Reflect.getPrototypeOf(proxy) === null);
+            assert(proxy.__proto__ === undefined);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -209,7 +200,6 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             [() =&gt; Reflect.setPrototypeOf(proxy, null), true],
</span><span class="cx">             [() =&gt; Object.setPrototypeOf(proxy, null), proxy],
</span><del>-            [() =&gt; proxy.__proto__ = null, null]
</del><span class="cx">         ];
</span><span class="cx">         for (let [set, expectedResult] of setters) {
</span><span class="cx">             let result = set();
</span><span class="lines">@@ -217,9 +207,8 @@
</span><span class="cx">             assert(called);
</span><span class="cx">             called = false;
</span><span class="cx">             assert(Reflect.getPrototypeOf(target) === null);
</span><del>-            // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-            //assert(Reflect.getPrototypeOf(proxy) === null);
-            //assert(proxy.__proto__ === null);
</del><ins>+            assert(Reflect.getPrototypeOf(proxy) === null);
+            assert(proxy.__proto__ === undefined);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -245,7 +234,6 @@
</span><span class="cx">         let setters = [
</span><span class="cx">             [() =&gt; Reflect.setPrototypeOf(proxy, obj), true],
</span><span class="cx">             [() =&gt; Object.setPrototypeOf(proxy, obj), proxy],
</span><del>-            [() =&gt; proxy.__proto__ = obj, obj]
</del><span class="cx">         ];
</span><span class="cx">         for (let [set, expectedResult] of setters) {
</span><span class="cx">             let result = set();
</span><span class="lines">@@ -253,9 +241,8 @@
</span><span class="cx">             assert(called);
</span><span class="cx">             called = false;
</span><span class="cx">             assert(Reflect.getPrototypeOf(target) === obj);
</span><del>-            // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-            //assert(Reflect.getPrototypeOf(proxy) === null);
-            //assert(proxy.__proto__ === null);
</del><ins>+            assert(Reflect.getPrototypeOf(proxy) === obj);
+            assert(proxy.__proto__ === obj);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -283,9 +270,8 @@
</span><span class="cx"> 
</span><span class="cx">         assert(threw);
</span><span class="cx">         assert(Reflect.getPrototypeOf(target) === null);
</span><del>-        // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-        //assert(Reflect.getPrototypeOf(proxy) === null);
-        //assert(proxy.__proto__ === null);
</del><ins>+        assert(Reflect.getPrototypeOf(proxy) === null);
+        assert(proxy.__proto__ === undefined);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -293,36 +279,7 @@
</span><span class="cx">     let target = {};
</span><span class="cx">     target.__proto__ = null;
</span><span class="cx">     Reflect.preventExtensions(target);
</span><del>-    let handler = {
-        setPrototypeOf: function(theTarget, value) {
-            return Reflect.setPrototypeOf(theTarget, value);
-        }
-    };
-    
-    let proxy = new Proxy(target, handler);
-    for (let i = 0; i &lt; 500; i++) {
-        let obj = {};
-        let threw = false;
-        try {
-            proxy.__proto__ = obj;
-        } catch(e) {
-            threw = true;
-            assert(e.toString() === &quot;TypeError: Proxy 'setPrototypeOf' returned false indicating it could not set the prototype value. The operation was expected to succeed&quot;);
-        }
</del><span class="cx"> 
</span><del>-        assert(threw);
-        assert(Reflect.getPrototypeOf(target) === null);
-        // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-        //assert(Reflect.getPrototypeOf(proxy) === null);
-        //assert(proxy.__proto__ === null);
-    }
-}
-
-{
-    let target = {};
-    target.__proto__ = null;
-    Reflect.preventExtensions(target);
-
</del><span class="cx">     let called = false;
</span><span class="cx">     let handler = {
</span><span class="cx">         setPrototypeOf: function(theTarget, value) {
</span><span class="lines">@@ -339,9 +296,8 @@
</span><span class="cx"> 
</span><span class="cx">         assert(called);
</span><span class="cx">         called = false;
</span><del>-        // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-        //assert(Reflect.getPrototypeOf(proxy) === null);
-        //assert(proxy.__proto__ === null);
</del><ins>+        assert(Reflect.getPrototypeOf(proxy) === null);
+        assert(proxy.__proto__ === undefined);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -366,9 +322,8 @@
</span><span class="cx">         assert(called);
</span><span class="cx">         called = false;
</span><span class="cx"> 
</span><del>-        // FIXME: when we implement Proxy.[[GetPrototypeOf]] this should work.
-        //assert(Reflect.getPrototypeOf(proxy) === null);
-        //assert(proxy.__proto__ === null);
</del><ins>+        assert(Reflect.getPrototypeOf(proxy) === null);
+        assert(proxy.__proto__ === undefined);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkJSTestsstressproxyunderscoreprotojs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/proxy-underscore-proto.js (0 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/proxy-underscore-proto.js                                (rev 0)
+++ trunk/JSTests/stress/proxy-underscore-proto.js        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -0,0 +1,110 @@
</span><ins>+function assert(b) {
+    if (!b)
+        throw new Error(&quot;Bad assertion!&quot;);
+}
+
+{
+    let p = {};
+    let target = {__proto__: p};
+    let called = false;
+    let handler = {
+        get(target, key, receiver) {
+            called = true;
+            assert(key === &quot;__proto__&quot;);
+            return target[key];
+        },
+
+        getPrototypeOf() {
+            assert(false);
+        }
+    };
+    
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        assert(proxy.__proto__ === p);
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let p = {};
+    let target = {__proto__: p};
+    let called1 = false;
+    let called2 = false;
+    let handler = {
+        get(target, key, receiver) {
+            called1 = true;
+            assert(key === &quot;__proto__&quot;);
+            return Reflect.get(target, key, receiver);
+        },
+
+        getPrototypeOf(...args) {
+            called2 = true;
+            return Reflect.getPrototypeOf(...args);
+        }
+    };
+    
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        assert(proxy.__proto__ === p);
+        assert(called1);
+        assert(called2);
+        called1 = false;
+        called2 = false;
+    }
+}
+
+{
+    let p = {};
+    let target = {__proto__: null};
+    let called = false;
+    let handler = {
+        set(target, key, value, receiver) {
+            called = true;
+            assert(key === &quot;__proto__&quot;);
+            return target[key] = value;
+        },
+
+        setPrototypeOf() {
+            assert(false);
+        }
+    };
+    
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        proxy.__proto__ = p;
+        assert(proxy.__proto__ === p);
+        assert(target.__proto__ === p);
+        target.__proto__ = null;
+        assert(called);
+        called = false;
+    }
+}
+
+{
+    let p = {};
+    let target = {__proto__: null};
+    let called = false;
+    let handler = {
+        set(target, key, value, receiver) {
+            called = true;
+            assert(key === &quot;__proto__&quot;);
+            return Reflect.set(target, key, value, receiver);
+        },
+
+        setPrototypeOf() {
+            assert(false);
+        }
+    };
+    
+    let proxy = new Proxy(target, handler);
+    for (let i = 0; i &lt; 500; i++) {
+        proxy.__proto__ = p;
+        assert(proxy.__proto__ === p);
+        assert(target.__proto__ === p);
+        target.__proto__ = null;
+        assert(called);
+        called = false;
+    }
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (205534 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-09-07 02:22:44 UTC (rev 205534)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-09-06  Saam Barati  &lt;sbarati@apple.com&gt;
+
+        ProxyObject's structure should not have ObjectPrototype as its prototype and it should not have special behavior for intercepting &quot;__proto__&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=161558
+
+        Reviewed by Benjamin Poulain.
+
+        ProxyObject had ObjectPrototype as its direct prototype.
+        This could lead to infinite loops when doing a getDirectPrototype()
+        loop.
+
+        Fixing this bug revealed another bug, which I made when implementing Proxy.
+        We should not special case &quot;__proto__&quot; in get and set for Proxy Object's
+        hooks. &quot;__proto__&quot; should just go through the normal set and get path.
+
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        * runtime/ProxyObject.cpp:
+        (JSC::performProxyGet):
+        (JSC::ProxyObject::put):
+
</ins><span class="cx"> 2016-09-06  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make JSC::PrivateName copyable
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (205534 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-09-07 02:22:44 UTC (rev 205534)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -508,9 +508,9 @@
</span><span class="cx">     m_moduleNamespaceObjectStructure.set(vm, this, JSModuleNamespaceObject::createStructure(vm, this, jsNull()));
</span><span class="cx">     {
</span><span class="cx">         bool isCallable = false;
</span><del>-        m_proxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, m_objectPrototype.get(), isCallable));
</del><ins>+        m_proxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable));
</ins><span class="cx">         isCallable = true;
</span><del>-        m_callableProxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, m_objectPrototype.get(), isCallable));
</del><ins>+        m_callableProxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable));
</ins><span class="cx">     }
</span><span class="cx">     m_proxyRevokeStructure.set(vm, this, ProxyRevoke::createStructure(vm, this, m_functionPrototype.get()));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeProxyObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp (205534 => 205535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp        2016-09-07 02:22:44 UTC (rev 205534)
+++ trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp        2016-09-07 02:48:35 UTC (rev 205535)
</span><span class="lines">@@ -125,9 +125,6 @@
</span><span class="cx"> 
</span><span class="cx">     JSObject* target = proxyObject-&gt;target();
</span><span class="cx"> 
</span><del>-    if (propertyName == vm.propertyNames-&gt;underscoreProto)
-        return proxyObject-&gt;performGetPrototype(exec);
-
</del><span class="cx">     auto performDefaultGet = [&amp;] {
</span><span class="cx">         return target-&gt;get(exec, propertyName);
</span><span class="cx">     };
</span><span class="lines">@@ -458,8 +455,6 @@
</span><span class="cx"> {
</span><span class="cx">     VM&amp; vm = exec-&gt;vm();
</span><span class="cx">     slot.disableCaching();
</span><del>-    if (propertyName == vm.propertyNames-&gt;underscoreProto)
-        return Base::put(cell, exec, propertyName, value, slot);
</del><span class="cx"> 
</span><span class="cx">     ProxyObject* thisObject = jsCast&lt;ProxyObject*&gt;(cell);
</span><span class="cx">     auto performDefaultPut = [&amp;] () {
</span></span></pre>
</div>
</div>

</body>
</html>