Changeset 244010 in webkit
- Timestamp:
- Apr 8, 2019, 5:39:23 AM (7 years ago)
- Location:
- releases/WebKitGTK/webkit-2.24
- Files:
-
- 1 added
- 8 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/new_array_with_spread-should-cap-array-size-to-MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/assembler/AbortReason.h (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGOperations.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ArrayConventions.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.24/JSTests/ChangeLog
r244007 r244010 1 2019-03-21 Mark Lam <mark.lam@apple.com> 2 3 Cap length of an array with spread to MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH. 4 https://bugs.webkit.org/show_bug.cgi?id=196055 5 <rdar://problem/49067448> 6 7 Reviewed by Yusuke Suzuki. 8 9 * stress/new_array_with_spread-should-cap-array-size-to-MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH.js: Added. 10 1 11 2019-03-18 Mark Lam <mark.lam@apple.com> 2 12 -
releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/ChangeLog
r244007 r244010 1 2019-03-21 Mark Lam <mark.lam@apple.com> 2 3 Cap length of an array with spread to MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH. 4 https://bugs.webkit.org/show_bug.cgi?id=196055 5 <rdar://problem/49067448> 6 7 Reviewed by Yusuke Suzuki. 8 9 We are doing this because: 10 1. We expect the array to be densely packed. 11 2. SpeculativeJIT::compileAllocateNewArrayWithSize() (and the FTL equivalent) 12 expects the array length to be less than MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH 13 if we don't want to use an ArrayStorage shape. 14 3. There's no reason why an array with spread needs to be that large anyway. 15 MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH is plenty. 16 17 In this patch, we also add a debug assert in compileAllocateNewArrayWithSize() and 18 emitAllocateButterfly() to check for overflows. 19 20 * assembler/AbortReason.h: 21 * dfg/DFGOperations.cpp: 22 * dfg/DFGSpeculativeJIT.cpp: 23 (JSC::DFG::SpeculativeJIT::compileCreateRest): 24 (JSC::DFG::SpeculativeJIT::compileNewArrayWithSpread): 25 (JSC::DFG::SpeculativeJIT::emitAllocateButterfly): 26 (JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize): 27 * ftl/FTLLowerDFGToB3.cpp: 28 (JSC::FTL::DFG::LowerDFGToB3::compileNewArrayWithSpread): 29 * runtime/ArrayConventions.h: 30 * runtime/CommonSlowPaths.cpp: 31 (JSC::SLOW_PATH_DECL): 32 1 33 2019-03-18 Mark Lam <mark.lam@apple.com> 2 34 -
releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/assembler/AbortReason.h
r219172 r244010 1 1 /* 2 * Copyright (C) 2014-201 6Apple Inc. All rights reserved.2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 74 74 TGInvalidPointer = 320, 75 75 TGNotSupported = 330, 76 UncheckedOverflow = 335, 76 77 YARRNoInputConsumed = 340, 77 78 }; -
releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/dfg/DFGOperations.cpp
r242484 r244010 1 1 /* 2 * Copyright (C) 2011-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2011-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 2710 2710 2711 2711 unsigned length = checkedLength.unsafeGet(); 2712 if (UNLIKELY(length >= MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH)) { 2713 throwOutOfMemoryError(exec, scope); 2714 return nullptr; 2715 } 2716 2712 2717 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 2713 2718 Structure* structure = globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous); -
releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r242488 r244010 7613 7613 GPRReg arrayResultGPR = arrayResult.gpr(); 7614 7614 7615 // We can tell compileAllocateNewArrayWithSize() that it does not need to check 7616 // for large arrays and use ArrayStorage structure because arrayLength here will 7617 // always be bounded by stack size. Realistically, we won't be able to push enough 7618 // arguments to have arrayLength exceed MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH. 7615 7619 bool shouldAllowForArrayStorageStructureForLargeArrays = false; 7616 7620 ASSERT(m_jit.graph().globalObjectFor(node->origin.semantic)->restParameterStructure()->indexingMode() == ArrayWithContiguous || m_jit.graph().globalObjectFor(node->origin.semantic)->isHavingABadTime()); … … 7966 7970 } 7967 7971 7968 7972 speculationCheck(Overflow, JSValueRegs(), nullptr, m_jit.branch32(MacroAssembler::AboveOrEqual, lengthGPR, TrustedImm32(MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH))); 7973 7974 // We can tell compileAllocateNewArrayWithSize() that it does not need to 7975 // check for large arrays and use ArrayStorage structure because we already 7976 // ensured above that the spread array length will definitely fit in a 7977 // non-ArrayStorage shaped array. 7969 7978 bool shouldAllowForArrayStorageStructureForLargeArrays = false; 7970 7979 ASSERT(m_jit.graph().globalObjectFor(node->origin.semantic)->restParameterStructure()->indexingType() == ArrayWithContiguous || m_jit.graph().globalObjectFor(node->origin.semantic)->isHavingABadTime()); … … 11625 11634 m_jit.lshift32(TrustedImm32(3), scratch1); 11626 11635 m_jit.add32(TrustedImm32(sizeof(IndexingHeader)), scratch1, scratch2); 11636 #if !ASSERT_DISABLED 11637 MacroAssembler::Jump didNotOverflow = m_jit.branch32(MacroAssembler::AboveOrEqual, scratch2, sizeGPR); 11638 m_jit.abortWithReason(UncheckedOverflow); 11639 didNotOverflow.link(&m_jit); 11640 #endif 11627 11641 m_jit.emitAllocateVariableSized( 11628 11642 storageResultGPR, m_jit.vm()->jsValueGigacageAuxiliarySpace, scratch2, scratch1, scratch3, slowCases); … … 12924 12938 if (shouldConvertLargeSizeToArrayStorage) 12925 12939 slowCases.append(m_jit.branch32(MacroAssembler::AboveOrEqual, sizeGPR, TrustedImm32(MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH))); 12940 #if !ASSERT_DISABLED 12941 else { 12942 MacroAssembler::Jump lengthIsWithinLimits; 12943 lengthIsWithinLimits = m_jit.branch32(MacroAssembler::Below, sizeGPR, TrustedImm32(MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH)); 12944 m_jit.abortWithReason(UncheckedOverflow); 12945 lengthIsWithinLimits.link(&m_jit); 12946 } 12947 #endif 12926 12948 12927 12949 // We can use resultGPR as a scratch right now. -
releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r242484 r244010 5825 5825 } 5826 5826 } 5827 5828 LValue exceedsMaxAllowedLength = m_out.aboveOrEqual(length, m_out.constInt32(MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH)); 5829 blessSpeculation(m_out.speculate(exceedsMaxAllowedLength), Overflow, noValue(), nullptr, m_origin); 5827 5830 5828 5831 RegisteredStructure structure = m_graph.registerStructure(m_graph.globalObjectFor(m_node->origin.semantic)->originalArrayStructureForIndexingType(ArrayWithContiguous)); -
releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/runtime/ArrayConventions.h
r228576 r244010 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2003-201 7Apple Inc. All rights reserved.3 * Copyright (C) 2003-2019 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 66 66 // If you try to allocate a contiguous array larger than this, then we will allocate an ArrayStorage 67 67 // array instead. We allow for an array that occupies 1GB of VM. 68 #define MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH 1024 * 1024 * 1024 / 868 #define MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH (1024 * 1024 * 1024 / 8) 69 69 #define MAX_STORAGE_VECTOR_INDEX (MAX_STORAGE_VECTOR_LENGTH - 1) 70 70 // 0xFFFFFFFF is a bit weird -- is not an array index even though it's an integer. -
releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
r241533 r244010 1250 1250 1251 1251 unsigned arraySize = checkedArraySize.unsafeGet(); 1252 if (UNLIKELY(arraySize >= MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH)) 1253 THROW(createOutOfMemoryError(exec)); 1254 1252 1255 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 1253 1256 Structure* structure = globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous);
Note:
See TracChangeset
for help on using the changeset viewer.