Title: [213742] trunk
Revision
213742
Author
mark....@apple.com
Date
2017-03-10 17:38:22 -0800 (Fri, 10 Mar 2017)

Log Message

JSC: BindingNode::bindValue doesn't increase the scope's reference count.
https://bugs.webkit.org/show_bug.cgi?id=168546
<rdar://problem/30589551>

Reviewed by Saam Barati.

JSTests:

* stress/regress-168546.js: Added.

Source/_javascript_Core:

We should protect the scope RegisterID with a RefPtr while it is still needed.

* bytecompiler/NodesCodegen.cpp:
(JSC::ForInNode::emitLoopHeader):
(JSC::ForOfNode::emitBytecode):
(JSC::BindingNode::bindValue):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (213741 => 213742)


--- trunk/JSTests/ChangeLog	2017-03-11 01:13:46 UTC (rev 213741)
+++ trunk/JSTests/ChangeLog	2017-03-11 01:38:22 UTC (rev 213742)
@@ -1,3 +1,13 @@
+2017-03-10  Mark Lam  <mark....@apple.com>
+
+        JSC: BindingNode::bindValue doesn't increase the scope's reference count.
+        https://bugs.webkit.org/show_bug.cgi?id=168546
+        <rdar://problem/30589551>
+
+        Reviewed by Saam Barati.
+
+        * stress/regress-168546.js: Added.
+
 2017-03-09  Caio Lima  <ticaiol...@gmail.com>
 
         [ESnext] Implement Object Rest - Implementing Object Rest Destructuring

Added: trunk/JSTests/stress/regress-168546.js (0 => 213742)


--- trunk/JSTests/stress/regress-168546.js	                        (rev 0)
+++ trunk/JSTests/stress/regress-168546.js	2017-03-11 01:38:22 UTC (rev 213742)
@@ -0,0 +1,14 @@
+// This test passes if it does not crash.
+try {
+    (function () {
+        let a = {
+            get val() {
+                [...{a = 1.45}] = [];
+                a.val.x;
+            },
+        };
+
+        a.val;
+    })();
+} catch (e) {
+}

Modified: trunk/Source/_javascript_Core/ChangeLog (213741 => 213742)


--- trunk/Source/_javascript_Core/ChangeLog	2017-03-11 01:13:46 UTC (rev 213741)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-03-11 01:38:22 UTC (rev 213742)
@@ -1,3 +1,18 @@
+2017-03-10  Mark Lam  <mark....@apple.com>
+
+        JSC: BindingNode::bindValue doesn't increase the scope's reference count.
+        https://bugs.webkit.org/show_bug.cgi?id=168546
+        <rdar://problem/30589551>
+
+        Reviewed by Saam Barati.
+
+        We should protect the scope RegisterID with a RefPtr while it is still needed.
+
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::ForInNode::emitLoopHeader):
+        (JSC::ForOfNode::emitBytecode):
+        (JSC::BindingNode::bindValue):
+
 2017-03-10  Alex Christensen  <achristen...@webkit.org>
 
         Fix CMake build.

Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (213741 => 213742)


--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2017-03-11 01:13:46 UTC (rev 213741)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2017-03-11 01:38:22 UTC (rev 213742)
@@ -1,7 +1,7 @@
 /*
 *  Copyright (C) 1999-2002 Harri Porten (por...@kde.org)
 *  Copyright (C) 2001 Peter Kelly (p...@post.com)
-*  Copyright (C) 2003-2009, 2012-2013, 2015-2016 Apple Inc. All rights reserved.
+*  Copyright (C) 2003-2017 Apple Inc. All rights reserved.
 *  Copyright (C) 2007 Cameron Zwarich (cwzwar...@uwaterloo.ca)
 *  Copyright (C) 2007 Maks Orlovich
 *  Copyright (C) 2007 Eric Seidel <e...@webkit.org>
@@ -2716,9 +2716,9 @@
                 generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
             if (var.isReadOnly())
                 generator.emitReadOnlyExceptionIfNeeded(var);
-            RegisterID* scope = generator.emitResolveScope(nullptr, var);
+            RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
             generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
-            generator.emitPutToScope(scope, var, propertyName, generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound, InitializationMode::NotInitialization);
+            generator.emitPutToScope(scope.get(), var, propertyName, generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound, InitializationMode::NotInitialization);
         }
         generator.emitProfileType(propertyName, var, m_lexpr->position(), JSTextPosition(-1, m_lexpr->position().offset + ident.length(), -1));
     };
@@ -2962,9 +2962,9 @@
                     generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
                 if (var.isReadOnly())
                     generator.emitReadOnlyExceptionIfNeeded(var);
-                RegisterID* scope = generator.emitResolveScope(nullptr, var);
+                RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
                 generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
-                generator.emitPutToScope(scope, var, value, generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound, InitializationMode::NotInitialization);
+                generator.emitPutToScope(scope.get(), var, value, generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound, InitializationMode::NotInitialization);
             }
             generator.emitProfileType(value, var, m_lexpr->position(), JSTextPosition(-1, m_lexpr->position().offset + ident.length(), -1));
         } else if (m_lexpr->isDotAccessorNode()) {
@@ -4107,15 +4107,15 @@
     }
     if (generator.isStrictMode())
         generator.emitExpressionInfo(divotEnd(), divotStart(), divotEnd());
-    RegisterID* scope = generator.emitResolveScope(nullptr, var);
+    RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var);
     generator.emitExpressionInfo(divotEnd(), divotStart(), divotEnd());
     if (m_bindingContext == AssignmentContext::AssignmentExpression)
-        generator.emitTDZCheckIfNecessary(var, nullptr, scope);
+        generator.emitTDZCheckIfNecessary(var, nullptr, scope.get());
     if (isReadOnly) {
         generator.emitReadOnlyExceptionIfNeeded(var);
         return;
     }
-    generator.emitPutToScope(scope, var, value, generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound, initializationModeForAssignmentContext(m_bindingContext));
+    generator.emitPutToScope(scope.get(), var, value, generator.isStrictMode() ? ThrowIfNotFound : DoNotThrowIfNotFound, initializationModeForAssignmentContext(m_bindingContext));
     generator.emitProfileType(value, var, divotStart(), divotEnd());
     if (m_bindingContext == AssignmentContext::DeclarationStatement || m_bindingContext == AssignmentContext::ConstDeclarationStatement)
         generator.liftTDZCheckIfPossible(var);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to