Skip to content
Permalink
Browse files

JSC: BindingNode::bindValue doesn't increase the scope's reference co…

…unt.

https://bugs.webkit.org/show_bug.cgi?id=168546
<rdar://problem/30589551>

Reviewed by Saam Barati.

JSTests:

* stress/regress-168546.js: Added.

Source/JavaScriptCore:

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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@213742 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information...
mark.lam@apple.com
mark.lam@apple.com committed Mar 11, 2017
1 parent 4ba5a9e commit 4a23c92e6883b230a437bcc09f94422d7df8756c
@@ -1,3 +1,13 @@
2017-03-10 Mark Lam <mark.lam@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 <ticaiolima@gmail.com>

[ESnext] Implement Object Rest - Implementing Object Rest Destructuring
@@ -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) {
}
@@ -1,3 +1,18 @@
2017-03-10 Mark Lam <mark.lam@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 <achristensen@webkit.org>

Fix CMake build.
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@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 (cwzwarich@uwaterloo.ca)
* Copyright (C) 2007 Maks Orlovich
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
@@ -2716,9 +2716,9 @@ void ForInNode::emitLoopHeader(BytecodeGenerator& generator, RegisterID* propert
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 @@ void ForOfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
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 @@ void BindingNode::bindValue(BytecodeGenerator& generator, RegisterID* value) con
}
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);

0 comments on commit 4a23c92

Please sign in to comment.
You can’t perform that action at this time.