<!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>[196785] trunk/Source/JavaScriptCore</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/196785">196785</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-02-18 16:27:15 -0800 (Thu, 18 Feb 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Proxy's don't properly handle Symbols as PropertyKeys.
https://bugs.webkit.org/show_bug.cgi?id=154385
Reviewed by Mark Lam and Yusuke Suzuki.
We were converting all PropertyKeys to strings, even when
the PropertyName was a Symbol. In the spec, PropertyKeys are
either a Symbol or a String. We now respect that in Proxy.[[Get]] and
Proxy.[[GetOwnProperty]].
* runtime/Completion.cpp:
(JSC::profiledEvaluate):
(JSC::createSymbolForEntryPointModule):
(JSC::identifierToJSValue): Deleted.
* runtime/Identifier.h:
(JSC::parseIndex):
* runtime/IdentifierInlines.h:
(JSC::Identifier::fromString):
(JSC::identifierToJSValue):
(JSC::identifierToSafePublicJSValue):
* runtime/ProxyObject.cpp:
(JSC::performProxyGet):
(JSC::ProxyObject::performInternalMethodGetOwnProperty):
* tests/es6.yaml:
* tests/stress/proxy-basic.js:
(let.handler.getOwnPropertyDescriptor):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCompletioncpp">trunk/Source/JavaScriptCore/runtime/Completion.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeIdentifierh">trunk/Source/JavaScriptCore/runtime/Identifier.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeIdentifierInlinesh">trunk/Source/JavaScriptCore/runtime/IdentifierInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeProxyObjectcpp">trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6yaml">trunk/Source/JavaScriptCore/tests/es6.yaml</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressproxybasicjs">trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (196784 => 196785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-02-19 00:03:58 UTC (rev 196784)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-02-19 00:27:15 UTC (rev 196785)
</span><span class="lines">@@ -1,5 +1,34 @@
</span><span class="cx"> 2016-02-18 Saam Barati <sbarati@apple.com>
</span><span class="cx">
</span><ins>+ Proxy's don't properly handle Symbols as PropertyKeys.
+ https://bugs.webkit.org/show_bug.cgi?id=154385
+
+ Reviewed by Mark Lam and Yusuke Suzuki.
+
+ We were converting all PropertyKeys to strings, even when
+ the PropertyName was a Symbol. In the spec, PropertyKeys are
+ either a Symbol or a String. We now respect that in Proxy.[[Get]] and
+ Proxy.[[GetOwnProperty]].
+
+ * runtime/Completion.cpp:
+ (JSC::profiledEvaluate):
+ (JSC::createSymbolForEntryPointModule):
+ (JSC::identifierToJSValue): Deleted.
+ * runtime/Identifier.h:
+ (JSC::parseIndex):
+ * runtime/IdentifierInlines.h:
+ (JSC::Identifier::fromString):
+ (JSC::identifierToJSValue):
+ (JSC::identifierToSafePublicJSValue):
+ * runtime/ProxyObject.cpp:
+ (JSC::performProxyGet):
+ (JSC::ProxyObject::performInternalMethodGetOwnProperty):
+ * tests/es6.yaml:
+ * tests/stress/proxy-basic.js:
+ (let.handler.getOwnPropertyDescriptor):
+
+2016-02-18 Saam Barati <sbarati@apple.com>
+
</ins><span class="cx"> Follow up fix to Implement Proxy.[[GetOwnProperty]]
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=154314
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCompletioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Completion.cpp (196784 => 196785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Completion.cpp        2016-02-19 00:03:58 UTC (rev 196784)
+++ trunk/Source/JavaScriptCore/runtime/Completion.cpp        2016-02-19 00:27:15 UTC (rev 196785)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include "CodeProfiling.h"
</span><span class="cx"> #include "Debugger.h"
</span><span class="cx"> #include "Exception.h"
</span><ins>+#include "IdentifierInlines.h"
</ins><span class="cx"> #include "Interpreter.h"
</span><span class="cx"> #include "JSCInlines.h"
</span><span class="cx"> #include "JSGlobalObject.h"
</span><span class="lines">@@ -120,13 +121,6 @@
</span><span class="cx"> return evaluate(exec, source, thisValue, returnedException);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static JSValue identifierToJSValue(VM& vm, const Identifier& identifier)
-{
- if (identifier.isSymbol())
- return Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl()));
- return jsString(&vm, identifier.impl());
-}
-
</del><span class="cx"> static Symbol* createSymbolForEntryPointModule(VM& vm)
</span><span class="cx"> {
</span><span class="cx"> // Generate the unique key for the source-provided module.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeIdentifierh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Identifier.h (196784 => 196785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Identifier.h        2016-02-19 00:03:58 UTC (rev 196784)
+++ trunk/Source/JavaScriptCore/runtime/Identifier.h        2016-02-19 00:27:15 UTC (rev 196785)
</span><span class="lines">@@ -282,6 +282,11 @@
</span><span class="cx"> return parseIndex(*uid);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+JSValue identifierToJSValue(VM&, const Identifier&);
+// This will stringify private symbols. When leaking JSValues to
+// non-internal code, make sure to use this function and not the above one.
+JSValue identifierToSafePublicJSValue(VM&, const Identifier&);
+
</ins><span class="cx"> // FIXME: It may be better for this to just be a typedef for PtrHash, since PtrHash may be cheaper to
</span><span class="cx"> // compute than loading the StringImpl's hash from memory. That change would also reduce the likelihood of
</span><span class="cx"> // crashes in code that somehow dangled a StringImpl.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeIdentifierInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/IdentifierInlines.h (196784 => 196785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/IdentifierInlines.h        2016-02-19 00:03:58 UTC (rev 196784)
+++ trunk/Source/JavaScriptCore/runtime/IdentifierInlines.h        2016-02-19 00:27:15 UTC (rev 196785)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #include "CallFrame.h"
</span><span class="cx"> #include "Identifier.h"
</span><ins>+#include "Symbol.h"
</ins><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><span class="lines">@@ -134,6 +135,20 @@
</span><span class="cx"> return Identifier(exec, AtomicString(s));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline JSValue identifierToJSValue(VM& vm, const Identifier& identifier)
+{
+ if (identifier.isSymbol())
+ return Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl()));
+ return jsString(&vm, identifier.impl());
+}
+
+inline JSValue identifierToSafePublicJSValue(VM& vm, const Identifier& identifier)
+{
+ if (identifier.isSymbol() && !vm.propertyNames->isPrivateName(identifier))
+ return Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl()));
+ return jsString(&vm, identifier.impl());
+}
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx">
</span><span class="cx"> #endif // IdentifierInlines_h
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeProxyObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp (196784 => 196785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp        2016-02-19 00:03:58 UTC (rev 196784)
+++ trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp        2016-02-19 00:27:15 UTC (rev 196785)
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx">
</span><span class="cx"> MarkedArgumentBuffer arguments;
</span><span class="cx"> arguments.append(target);
</span><del>- arguments.append(jsString(exec, propertyName.uid()));
</del><ins>+ arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
</ins><span class="cx"> if (exec->hadException())
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx"> arguments.append(thisObject);
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx">
</span><span class="cx"> MarkedArgumentBuffer arguments;
</span><span class="cx"> arguments.append(target);
</span><del>- arguments.append(jsString(exec, propertyName.uid()));
</del><ins>+ arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
</ins><span class="cx"> if (exec->hadException())
</span><span class="cx"> return false;
</span><span class="cx"> JSValue trapResult = call(exec, getOwnPropertyDescriptorMethod, callType, callData, handler, arguments);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6yaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6.yaml (196784 => 196785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6.yaml        2016-02-19 00:03:58 UTC (rev 196784)
+++ trunk/Source/JavaScriptCore/tests/es6.yaml        2016-02-19 00:27:15 UTC (rev 196785)
</span><span class="lines">@@ -949,7 +949,7 @@
</span><span class="cx"> - path: es6/Proxy_internal_deleteProperty_calls_Array.prototype.unshift.js
</span><span class="cx"> cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_Array.from.js
</span><del>- cmd: runES6 :fail
</del><ins>+ cmd: runES6 :normal
</ins><span class="cx"> - path: es6/Proxy_internal_get_calls_Array.prototype.concat.js
</span><span class="cx"> cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_Array.prototype.pop.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressproxybasicjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js (196784 => 196785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js        2016-02-19 00:03:58 UTC (rev 196784)
+++ trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js        2016-02-19 00:27:15 UTC (rev 196785)
</span><span class="lines">@@ -209,3 +209,76 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+
+{
+ let field = Symbol();
+ let theTarget = {
+ [field]: 40
+ };
+ let handler = {
+ get: function(target, propName, proxyArg) {
+ assert(propName === field);
+ return target[field];
+ }
+ };
+
+ let proxy = new Proxy(theTarget, handler);
+ for (let i = 0; i < 500; i++) {
+ assert(proxy[field] === 40);
+ }
+}
+
+{
+ let theTarget = [];
+ let sawPrivateSymbolAsString = false;
+ let handler = {
+ get: function(target, propName, proxyArg) {
+ if (typeof propName === "string")
+ sawPrivateSymbolAsString = propName === "PrivateSymbol.arrayIterationKind";
+ return target[propName];
+ }
+ };
+
+ let proxy = new Proxy(theTarget, handler);
+ for (let i = 0; i < 100; i++) {
+ let threw = false;
+ try {
+ proxy[Symbol.iterator]().next.call(proxy);
+ } catch(e) {
+ // this will throw because we conver private symbols to strings.
+ threw = true;
+ }
+ assert(threw);
+ assert(sawPrivateSymbolAsString);
+ sawPrivateSymbolAsString = false;
+ }
+}
+
+{
+ let prop = Symbol();
+ let theTarget = { };
+ Object.defineProperty(theTarget, prop, {
+ enumerable: true,
+ configurable: true
+ });
+ let called = false;
+ let handler = {
+ getOwnPropertyDescriptor: function(target, propName) {
+ assert(prop === propName);
+ called = true;
+ return {
+ enumerable: true,
+ configurable: true
+ };
+ }
+ };
+
+ let proxy = new Proxy(theTarget, handler);
+ for (let i = 0; i < 100; i++) {
+ let pDesc = Object.getOwnPropertyDescriptor(proxy, prop);
+ assert(pDesc.configurable);
+ assert(pDesc.enumerable);
+ assert(called);
+ called = false;
+ }
+}
</ins></span></pre>
</div>
</div>
</body>
</html>