[JSC] Fix "name" and "length" of Proxy revoke function
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Sep 2017 06:40:55 +0000 (06:40 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Sep 2017 06:40:55 +0000 (06:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176155

Reviewed by Mark Lam.

JSTests:

* test262.yaml:

Source/JavaScriptCore:

ProxyRevoke's length should be configurable. And it does not have
its own name. We add NameVisibility enum to InternalFunction to
control visibility of the name.

* runtime/InternalFunction.cpp:
(JSC::InternalFunction::finishCreation):
* runtime/InternalFunction.h:
* runtime/ProxyRevoke.cpp:
(JSC::ProxyRevoke::finishCreation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221475 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JSTests/ChangeLog
JSTests/test262.yaml
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/InternalFunction.cpp
Source/JavaScriptCore/runtime/InternalFunction.h
Source/JavaScriptCore/runtime/ProxyRevoke.cpp

index 03a20f5..f143ea3 100644 (file)
@@ -1,3 +1,12 @@
+2017-08-31  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Fix "name" and "length" of Proxy revoke function
+        https://bugs.webkit.org/show_bug.cgi?id=176155
+
+        Reviewed by Mark Lam.
+
+        * test262.yaml:
+
 2017-08-31  Saam Barati  <sbarati@apple.com>
 
         Graph::methodOfGettingAValueProfileFor compares NodeOrigin instead of the semantic CodeOrigin
index 8e9d989..60773e6 100644 (file)
 - path: test262/test/built-ins/Proxy/revocable/revocation-function-extensible.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Proxy/revocable/revocation-function-length.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/propertyHelper.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/propertyHelper.js"], []
 - path: test262/test/built-ins/Proxy/revocable/revocation-function-length.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/propertyHelper.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/propertyHelper.js"], [:strict]
 - path: test262/test/built-ins/Proxy/revocable/revocation-function-name.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Proxy/revocable/revocation-function-name.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/built-ins/Proxy/revocable/revocation-function-nonconstructor.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/built-ins/Proxy/revocable/revocation-function-nonconstructor.js
index 754f1f3..9b939ba 100644 (file)
@@ -1,3 +1,20 @@
+2017-08-31  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Fix "name" and "length" of Proxy revoke function
+        https://bugs.webkit.org/show_bug.cgi?id=176155
+
+        Reviewed by Mark Lam.
+
+        ProxyRevoke's length should be configurable. And it does not have
+        its own name. We add NameVisibility enum to InternalFunction to
+        control visibility of the name.
+
+        * runtime/InternalFunction.cpp:
+        (JSC::InternalFunction::finishCreation):
+        * runtime/InternalFunction.h:
+        * runtime/ProxyRevoke.cpp:
+        (JSC::ProxyRevoke::finishCreation):
+
 2017-08-31  Saam Barati  <sbarati@apple.com>
 
         Throwing an exception in the DFG/FTL should not cause a jettison
index 07ae3a1..58f168e 100644 (file)
@@ -41,14 +41,15 @@ InternalFunction::InternalFunction(VM& vm, Structure* structure)
     RELEASE_ASSERT(!isLargeAllocation());
 }
 
-void InternalFunction::finishCreation(VM& vm, const String& name)
+void InternalFunction::finishCreation(VM& vm, const String& name, NameVisibility nameVisibility)
 {
     Base::finishCreation(vm);
     ASSERT(inherits(vm, info()));
     ASSERT(methodTable()->getCallData != InternalFunction::info()->methodTable.getCallData);
     JSString* nameString = jsString(&vm, name);
     m_originalName.set(vm, this, nameString);
-    putDirect(vm, vm.propertyNames->name, nameString, ReadOnly | DontEnum);
+    if (nameVisibility == NameVisibility::Visible)
+        putDirect(vm, vm.propertyNames->name, nameString, ReadOnly | DontEnum);
 }
 
 void InternalFunction::visitChildren(JSCell* cell, SlotVisitor& visitor)
index 140daab..3a8f22e 100644 (file)
@@ -52,7 +52,8 @@ public:
 protected:
     JS_EXPORT_PRIVATE InternalFunction(VM&, Structure*);
 
-    JS_EXPORT_PRIVATE void finishCreation(VM&, const String& name);
+    enum class NameVisibility { Visible, Anonymous };
+    JS_EXPORT_PRIVATE void finishCreation(VM&, const String& name, NameVisibility = NameVisibility::Visible);
 
     JS_EXPORT_PRIVATE static Structure* createSubclassStructureSlow(ExecState*, JSValue newTarget, Structure*);
 
index dc4ee9c..5241ef5 100644 (file)
@@ -49,10 +49,10 @@ ProxyRevoke::ProxyRevoke(VM& vm, Structure* structure)
 
 void ProxyRevoke::finishCreation(VM& vm, const char* name, ProxyObject* proxy)
 {
-    Base::finishCreation(vm, String(name));
+    Base::finishCreation(vm, String(name), NameVisibility::Anonymous);
     m_proxy.set(vm, this, proxy);
 
-    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
+    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
 }
 
 static EncodedJSValue JSC_HOST_CALL performProxyRevoke(ExecState* exec)