Changeset 244067 in webkit
- Timestamp:
- Apr 8, 2019, 8:23:15 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/put-by-val-direct-should-respect-strict-mode-of-inlining-codeblock.js (added)
-
JSTests/stress/put-dynamic-var-strict-and-sloppy.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGOperations.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGOperations.h (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r244058 r244067 1 2019-04-08 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] DFG should respect node's strict flag 4 https://bugs.webkit.org/show_bug.cgi?id=196617 5 6 Reviewed by Saam Barati. 7 8 * stress/put-by-val-direct-should-respect-strict-mode-of-inlining-codeblock.js: Added. 9 (shouldEqual): 10 (makeUnwriteableUnconfigurableObject): 11 (runTest): 12 * stress/put-dynamic-var-strict-and-sloppy.js: Added. 13 (shouldBe): 14 (shouldThrow): 15 (with.result): 16 (with.putValueStrict): 17 (with.putValueSloppy): 18 1 19 2019-04-08 Yusuke Suzuki <ysuzuki@apple.com> 2 20 -
trunk/Source/JavaScriptCore/ChangeLog
r244065 r244067 1 2019-04-08 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] DFG should respect node's strict flag 4 https://bugs.webkit.org/show_bug.cgi?id=196617 5 6 Reviewed by Saam Barati. 7 8 We accidentally use codeBlock->isStrictMode() directly in DFG and FTL. But this is wrong since this CodeBlock is the top level DFG/FTL CodeBlock, 9 and this code does not respect the isStrictMode flag for the inlined CodeBlocks. In this patch, we start using isStrictModeFor(CodeOrigin) consistently 10 in DFG and FTL to get the right isStrictMode flag for the DFG node. 11 And we also split compilePutDynamicVar into compilePutDynamicVarStrict and compilePutDynamicVarNonStrict since (1) it is cleaner than accessing inlined 12 callframe in the operation function, and (2) it is aligned to the other functions like operationPutByValDirectNonStrict etc. 13 This bug is discovered by RandomizingFuzzerAgent by expanding the DFG coverage. 14 15 * dfg/DFGAbstractInterpreterInlines.h: 16 (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): 17 * dfg/DFGConstantFoldingPhase.cpp: 18 (JSC::DFG::ConstantFoldingPhase::foldConstants): 19 * dfg/DFGFixupPhase.cpp: 20 (JSC::DFG::FixupPhase::fixupToThis): 21 * dfg/DFGOperations.cpp: 22 * dfg/DFGOperations.h: 23 * dfg/DFGPredictionPropagationPhase.cpp: 24 * dfg/DFGSpeculativeJIT.cpp: 25 (JSC::DFG::SpeculativeJIT::compileDoublePutByVal): 26 (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): 27 (JSC::DFG::SpeculativeJIT::compilePutDynamicVar): 28 (JSC::DFG::SpeculativeJIT::compileToThis): 29 * dfg/DFGSpeculativeJIT32_64.cpp: 30 (JSC::DFG::SpeculativeJIT::compileContiguousPutByVal): 31 (JSC::DFG::SpeculativeJIT::compile): 32 * dfg/DFGSpeculativeJIT64.cpp: 33 (JSC::DFG::SpeculativeJIT::compile): 34 * ftl/FTLLowerDFGToB3.cpp: 35 (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): 36 (JSC::FTL::DFG::LowerDFGToB3::compilePutDynamicVar): 37 1 38 2019-04-08 Don Olmstead <don.olmstead@sony.com> 2 39 -
trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
r243418 r244067 2532 2532 AbstractValue& source = forNode(node->child1()); 2533 2533 AbstractValue& destination = forNode(node); 2534 bool strictMode = m_graph. executableFor(node->origin.semantic)->isStrictMode();2534 bool strictMode = m_graph.isStrictModeFor(node->origin.semantic); 2535 2535 2536 2536 ToThisResult result = isToThisAnIdentity(m_vm, strictMode, source); -
trunk/Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp
r243232 r244067 696 696 697 697 case ToThis: { 698 ToThisResult result = isToThisAnIdentity(m_graph.m_vm, m_graph. executableFor(node->origin.semantic)->isStrictMode(), m_state.forNode(node->child1()));698 ToThisResult result = isToThisAnIdentity(m_graph.m_vm, m_graph.isStrictModeFor(node->origin.semantic), m_state.forNode(node->child1())); 699 699 if (result == ToThisResult::Identity) { 700 700 node->convertToIdentity(); -
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r243232 r244067 2656 2656 void fixupToThis(Node* node) 2657 2657 { 2658 ECMAMode ecmaMode = m_graph.executableFor(node->origin.semantic)->isStrictMode() ? StrictMode : NotStrictMode;2659 2660 if ( ecmaMode ==StrictMode) {2658 bool isStrictMode = m_graph.isStrictModeFor(node->origin.semantic); 2659 2660 if (isStrictMode) { 2661 2661 if (node->child1()->shouldSpeculateBoolean()) { 2662 2662 fixEdge<BooleanUse>(node->child1()); … … 2711 2711 2712 2712 if (node->child1()->shouldSpeculateOther()) { 2713 if ( ecmaMode ==StrictMode) {2713 if (isStrictMode) { 2714 2714 fixEdge<OtherUse>(node->child1()); 2715 2715 node->convertToIdentity(); -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r243835 r244067 2876 2876 } 2877 2877 2878 void JIT_OPERATION operationPutDynamicVar(ExecState* exec, JSObject* scope, EncodedJSValue value, UniquedStringImpl* impl, unsigned getPutInfoBits) 2879 { 2880 VM& vm = exec->vm(); 2881 NativeCallFrameTracer tracer(&vm, exec); 2878 ALWAYS_INLINE static void putDynamicVar(ExecState* exec, VM& vm, JSObject* scope, EncodedJSValue value, UniquedStringImpl* impl, unsigned getPutInfoBits, bool isStrictMode) 2879 { 2882 2880 auto throwScope = DECLARE_THROW_SCOPE(vm); 2883 2881 … … 2903 2901 } 2904 2902 2905 CodeOrigin origin = exec->codeOrigin(); 2906 auto* inlineCallFrame = origin.inlineCallFrame(); 2907 bool strictMode; 2908 if (inlineCallFrame) 2909 strictMode = inlineCallFrame->baselineCodeBlock->isStrictMode(); 2910 else 2911 strictMode = exec->codeBlock()->isStrictMode(); 2912 PutPropertySlot slot(scope, strictMode, PutPropertySlot::UnknownContext, isInitialization(getPutInfo.initializationMode())); 2903 PutPropertySlot slot(scope, isStrictMode, PutPropertySlot::UnknownContext, isInitialization(getPutInfo.initializationMode())); 2913 2904 throwScope.release(); 2914 2905 scope->methodTable(vm)->put(scope, exec, ident, JSValue::decode(value), slot); 2906 } 2907 2908 void JIT_OPERATION operationPutDynamicVarStrict(ExecState* exec, JSObject* scope, EncodedJSValue value, UniquedStringImpl* impl, unsigned getPutInfoBits) 2909 { 2910 VM& vm = exec->vm(); 2911 NativeCallFrameTracer tracer(&vm, exec); 2912 constexpr bool isStrictMode = true; 2913 return putDynamicVar(exec, vm, scope, value, impl, getPutInfoBits, isStrictMode); 2914 } 2915 2916 void JIT_OPERATION operationPutDynamicVarNonStrict(ExecState* exec, JSObject* scope, EncodedJSValue value, UniquedStringImpl* impl, unsigned getPutInfoBits) 2917 { 2918 VM& vm = exec->vm(); 2919 NativeCallFrameTracer tracer(&vm, exec); 2920 constexpr bool isStrictMode = false; 2921 return putDynamicVar(exec, vm, scope, value, impl, getPutInfoBits, isStrictMode); 2915 2922 } 2916 2923 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.h
r242715 r244067 269 269 EncodedJSValue JIT_OPERATION operationResolveScopeForHoistingFuncDeclInEval(ExecState*, JSScope*, UniquedStringImpl*); 270 270 EncodedJSValue JIT_OPERATION operationGetDynamicVar(ExecState*, JSObject* scope, UniquedStringImpl*, unsigned); 271 void JIT_OPERATION operationPutDynamicVar(ExecState*, JSObject* scope, EncodedJSValue, UniquedStringImpl*, unsigned); 271 void JIT_OPERATION operationPutDynamicVarStrict(ExecState*, JSObject* scope, EncodedJSValue, UniquedStringImpl*, unsigned); 272 void JIT_OPERATION operationPutDynamicVarNonStrict(ExecState*, JSObject* scope, EncodedJSValue, UniquedStringImpl*, unsigned); 272 273 273 274 int64_t JIT_OPERATION operationConvertBoxedDoubleToInt52(EncodedJSValue); -
trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
r242715 r244067 448 448 case ToThis: { 449 449 // ToThis in methods for primitive types should speculate primitive types in strict mode. 450 ECMAMode ecmaMode = m_graph.executableFor(node->origin.semantic)->isStrictMode() ? StrictMode : NotStrictMode;451 if ( ecmaMode ==StrictMode) {450 bool isStrictMode = m_graph.isStrictModeFor(node->origin.semantic); 451 if (isStrictMode) { 452 452 if (node->child1()->shouldSpeculateBoolean()) { 453 453 changed |= mergePrediction(SpecBoolean); … … 497 497 498 498 SpeculatedType prediction = node->child1()->prediction(); 499 if ( ecmaMode ==StrictMode)499 if (isStrictMode) 500 500 changed |= mergePrediction(node->getHeapPrediction()); 501 501 else if (prediction) { -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r244058 r244067 2123 2123 slowPathCall( 2124 2124 slowCase, this, 2125 m_jit. codeBlock()->isStrictMode()2125 m_jit.isStrictModeFor(node->origin.semantic) 2126 2126 ? (node->op() == PutByValDirect ? operationPutDoubleByValDirectBeyondArrayBoundsStrict : operationPutDoubleByValBeyondArrayBoundsStrict) 2127 2127 : (node->op() == PutByValDirect ? operationPutDoubleByValDirectBeyondArrayBoundsNonStrict : operationPutDoubleByValBeyondArrayBoundsNonStrict), … … 3154 3154 addSlowPathGenerator(slowPathCall( 3155 3155 slowPathCases, this, 3156 m_jit. codeBlock()->isStrictMode() ? operationPutByValDirectCellStrict : operationPutByValDirectCellNonStrict,3156 m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValDirectCellStrict : operationPutByValDirectCellNonStrict, 3157 3157 NoResult, base, JSValueRegs(propertyTagGPR, property), JSValueRegs(valueTagGPR, valueGPR))); 3158 3158 } else { 3159 3159 addSlowPathGenerator(slowPathCall( 3160 3160 slowPathCases, this, 3161 m_jit. codeBlock()->isStrictMode() ? operationPutByValCellStrict : operationPutByValCellNonStrict,3161 m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValCellStrict : operationPutByValCellNonStrict, 3162 3162 NoResult, base, JSValueRegs(propertyTagGPR, property), JSValueRegs(valueTagGPR, valueGPR))); 3163 3163 } … … 11061 11061 11062 11062 flushRegisters(); 11063 callOperation( operationPutDynamicVar, NoResult, scopeGPR, valueRegs, identifierUID(node->identifierNumber()), node->getPutInfo());11063 callOperation(m_jit.isStrictModeFor(node->origin.semantic) ? operationPutDynamicVarStrict : operationPutDynamicVarNonStrict, NoResult, scopeGPR, valueRegs, identifierUID(node->identifierNumber()), node->getPutInfo()); 11064 11064 m_jit.exceptionCheck(); 11065 11065 noResult(node); … … 12330 12330 12331 12331 J_JITOperation_EJ function; 12332 if (m_jit. graph().executableFor(node->origin.semantic)->isStrictMode())12332 if (m_jit.isStrictModeFor(node->origin.semantic)) 12333 12333 function = operationToThisStrict; 12334 12334 else -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
r243232 r244067 1786 1786 addSlowPathGenerator(slowPathCall( 1787 1787 slowCase, this, 1788 m_jit. codeBlock()->isStrictMode() ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValDirectBeyondArrayBoundsNonStrict,1788 m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValDirectBeyondArrayBoundsNonStrict, 1789 1789 NoResult, baseReg, propertyReg, JSValueRegs(valueTag, valuePayloadReg))); 1790 1790 } else { 1791 1791 addSlowPathGenerator(slowPathCall( 1792 1792 slowCase, this, 1793 m_jit. codeBlock()->isStrictMode() ? operationPutByValBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsNonStrict,1793 m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsNonStrict, 1794 1794 NoResult, baseReg, propertyReg, JSValueRegs(valueTag, valuePayloadReg))); 1795 1795 } … … 2555 2555 flushRegisters(); 2556 2556 if (node->op() == PutByValDirect) 2557 callOperation(m_jit. codeBlock()->isStrictMode() ? operationPutByValDirectCellStrict : operationPutByValDirectCellNonStrict, baseGPR, propertyRegs, valueRegs);2557 callOperation(m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValDirectCellStrict : operationPutByValDirectCellNonStrict, baseGPR, propertyRegs, valueRegs); 2558 2558 else 2559 callOperation(m_jit. codeBlock()->isStrictMode() ? operationPutByValCellStrict : operationPutByValCellNonStrict, baseGPR, propertyRegs, valueRegs);2559 callOperation(m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValCellStrict : operationPutByValCellNonStrict, baseGPR, propertyRegs, valueRegs); 2560 2560 m_jit.exceptionCheck(); 2561 2561 … … 2668 2668 addSlowPathGenerator(slowPathCall( 2669 2669 slowCases, this, 2670 m_jit. codeBlock()->isStrictMode() ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValDirectBeyondArrayBoundsNonStrict,2670 m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValDirectBeyondArrayBoundsNonStrict, 2671 2671 NoResult, baseReg, propertyReg, JSValueRegs(valueTagReg, valuePayloadReg))); 2672 2672 } else { 2673 2673 addSlowPathGenerator(slowPathCall( 2674 2674 slowCases, this, 2675 m_jit. codeBlock()->isStrictMode() ? operationPutByValBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsNonStrict,2675 m_jit.isStrictModeFor(node->origin.semantic) ? operationPutByValBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsNonStrict, 2676 2676 NoResult, baseReg, propertyReg, JSValueRegs(valueTagReg, valuePayloadReg))); 2677 2677 } -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
r243344 r244067 2727 2727 addSlowPathGenerator(slowPathCall( 2728 2728 slowCase, this, 2729 m_jit. codeBlock()->isStrictMode()2729 m_jit.isStrictModeFor(node->origin.semantic) 2730 2730 ? (node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsStrict) 2731 2731 : (node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsNonStrict : operationPutByValBeyondArrayBoundsNonStrict), … … 2811 2811 addSlowPathGenerator(slowPathCall( 2812 2812 slowCases, this, 2813 m_jit. codeBlock()->isStrictMode()2813 m_jit.isStrictModeFor(node->origin.semantic) 2814 2814 ? (node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsStrict) 2815 2815 : (node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsNonStrict : operationPutByValBeyondArrayBoundsNonStrict), -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r243959 r244067 4566 4566 4567 4567 contiguousPutByValOutOfBounds( 4568 codeBlock()->isStrictMode()4568 m_graph.isStrictModeFor(m_node->origin.semantic) 4569 4569 ? (m_node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsStrict) 4570 4570 : (m_node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsNonStrict : operationPutByValBeyondArrayBoundsNonStrict), … … 4592 4592 4593 4593 contiguousPutByValOutOfBounds( 4594 codeBlock()->isStrictMode()4594 m_graph.isStrictModeFor(m_node->origin.semantic) 4595 4595 ? (m_node->op() == PutByValDirect ? operationPutDoubleByValDirectBeyondArrayBoundsStrict : operationPutDoubleByValBeyondArrayBoundsStrict) 4596 4596 : (m_node->op() == PutByValDirect ? operationPutDoubleByValDirectBeyondArrayBoundsNonStrict : operationPutDoubleByValBeyondArrayBoundsNonStrict), … … 4632 4632 index, m_out.load32NonNegative(storage, m_heaps.ArrayStorage_vectorLength)); 4633 4633 4634 auto slowPathFunction = codeBlock()->isStrictMode()4634 auto slowPathFunction = m_graph.isStrictModeFor(m_node->origin.semantic) 4635 4635 ? (m_node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsStrict : operationPutByValBeyondArrayBoundsStrict) 4636 4636 : (m_node->op() == PutByValDirect ? operationPutByValDirectBeyondArrayBoundsNonStrict : operationPutByValBeyondArrayBoundsNonStrict); … … 12356 12356 { 12357 12357 UniquedStringImpl* uid = m_graph.identifiers()[m_node->identifierNumber()]; 12358 setJSValue(vmCall(Void, m_out.operation( operationPutDynamicVar),12358 setJSValue(vmCall(Void, m_out.operation(m_graph.isStrictModeFor(m_node->origin.semantic) ? operationPutDynamicVarStrict : operationPutDynamicVarNonStrict), 12359 12359 m_callFrame, lowCell(m_node->child1()), lowJSValue(m_node->child2()), m_out.constIntPtr(uid), m_out.constInt32(m_node->getPutInfo()))); 12360 12360 }
Note:
See TracChangeset
for help on using the changeset viewer.