Changeset 212640 in webkit
- Timestamp:
- Feb 20, 2017, 9:18:27 AM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r212629 r212640 1 2017-02-19 Mark Lam <mark.lam@apple.com> 2 3 BytecodeGenerator should not iterate its m_controlFlowScopeStack using a pointer bump. 4 https://bugs.webkit.org/show_bug.cgi?id=168585 5 6 Reviewed by Yusuke Suzuki. 7 8 This is because m_controlFlowScopeStack is a SegmentedVector, and entries for 9 consecutive indices in the vector are not guaranteed to be consecutive in memory 10 layout. Instead, we should be using indexing instead. 11 12 This issue was detected by the marathon.js test from 13 https://bugs.webkit.org/show_bug.cgi?id=168580. 14 15 * bytecompiler/BytecodeGenerator.cpp: 16 (JSC::BytecodeGenerator::emitJumpViaFinallyIfNeeded): 17 (JSC::BytecodeGenerator::emitReturnViaFinallyIfNeeded): 18 1 19 2017-02-20 Manuel Rego Casasnovas <rego@igalia.com> 2 20 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r212425 r212640 1 1 /* 2 * Copyright (C) 2008-20 09, 2012-2016Apple Inc. All rights reserved.2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> 4 4 * Copyright (C) 2012 Igalia, S.L. … … 4823 4823 { 4824 4824 ASSERT(labelScopeDepth() - targetLabelScopeDepth >= 0); 4825 size_t scopeDelta = labelScopeDepth() - targetLabelScopeDepth; 4826 ASSERT(scopeDelta <= m_controlFlowScopeStack.size()); 4827 if (!scopeDelta) 4828 return false; // No finallys to thread through. 4829 4830 ControlFlowScope* topScope = &m_controlFlowScopeStack.last(); 4831 ControlFlowScope* bottomScope = &m_controlFlowScopeStack.last() - scopeDelta; 4825 size_t numberOfScopesToCheckForFinally = labelScopeDepth() - targetLabelScopeDepth; 4826 ASSERT(numberOfScopesToCheckForFinally <= m_controlFlowScopeStack.size()); 4827 if (!numberOfScopesToCheckForFinally) 4828 return false; 4832 4829 4833 4830 FinallyContext* innermostFinallyContext = nullptr; 4834 4831 FinallyContext* outermostFinallyContext = nullptr; 4835 while (topScope > bottomScope) { 4836 if (topScope->isFinallyScope()) { 4837 FinallyContext* finallyContext = &topScope->finallyContext; 4832 size_t scopeIndex = m_controlFlowScopeStack.size() - 1; 4833 while (numberOfScopesToCheckForFinally--) { 4834 ControlFlowScope* scope = &m_controlFlowScopeStack[scopeIndex--]; 4835 if (scope->isFinallyScope()) { 4836 FinallyContext* finallyContext = &scope->finallyContext; 4838 4837 if (!innermostFinallyContext) 4839 4838 innermostFinallyContext = finallyContext; … … 4841 4840 finallyContext->incNumberOfBreaksOrContinues(); 4842 4841 } 4843 --topScope;4844 4842 } 4845 4843 if (!outermostFinallyContext) … … 4857 4855 bool BytecodeGenerator::emitReturnViaFinallyIfNeeded(RegisterID* returnRegister) 4858 4856 { 4859 if (!m_controlFlowScopeStack.size()) 4860 return false; // No finallys to thread through. 4861 4862 ControlFlowScope* topScope = &m_controlFlowScopeStack.last(); 4863 ControlFlowScope* bottomScope = &m_controlFlowScopeStack.first(); 4857 size_t numberOfScopesToCheckForFinally = m_controlFlowScopeStack.size(); 4858 if (!numberOfScopesToCheckForFinally) 4859 return false; 4864 4860 4865 4861 FinallyContext* innermostFinallyContext = nullptr; 4866 while (topScope >= bottomScope) { 4867 if (topScope->isFinallyScope()) { 4868 FinallyContext* finallyContext = &topScope->finallyContext; 4862 while (numberOfScopesToCheckForFinally) { 4863 size_t scopeIndex = --numberOfScopesToCheckForFinally; 4864 ControlFlowScope* scope = &m_controlFlowScopeStack[scopeIndex]; 4865 if (scope->isFinallyScope()) { 4866 FinallyContext* finallyContext = &scope->finallyContext; 4869 4867 if (!innermostFinallyContext) 4870 4868 innermostFinallyContext = finallyContext; 4871 4869 finallyContext->setHandlesReturns(); 4872 4870 } 4873 --topScope;4874 4871 } 4875 4872 if (!innermostFinallyContext)
Note:
See TracChangeset
for help on using the changeset viewer.