Changeset 243925 in webkit
- Timestamp:
- Apr 4, 2019 9:17:44 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r243920 r243925 1 2019-04-04 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] makeBoundFunction should not assume incoming "length" value is Int32 because it performs some calculation in bytecode 4 https://bugs.webkit.org/show_bug.cgi?id=196631 5 6 Reviewed by Saam Barati. 7 8 * stress/make-bound-function-should-not-assume-int32-length.js: Added. 9 (assert): 10 (test): 11 (foo): 12 1 13 2019-04-04 Saam Barati <sbarati@apple.com> 2 14 -
trunk/Source/JavaScriptCore/ChangeLog
r243918 r243925 1 2019-04-04 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] makeBoundFunction should not assume incoming "length" value is Int32 because it performs some calculation in bytecode 4 https://bugs.webkit.org/show_bug.cgi?id=196631 5 6 Reviewed by Saam Barati. 7 8 makeBoundFunction assumes that "length" argument is always Int32. But this should not be done since this "length" value is calculated in builtin JS code. 9 DFG may store this value in Double format so that we should not rely on that this value is Int32. This patch fixes makeBoundFunction function to perform 10 toInt32 operation. We also insert a missing exception check for `JSString::value(ExecState*)` in makeBoundFunction. 11 12 * JavaScriptCore.xcodeproj/project.pbxproj: 13 * Sources.txt: 14 * interpreter/CallFrameInlines.h: 15 * runtime/DoublePredictionFuzzerAgent.cpp: Copied from Source/JavaScriptCore/interpreter/CallFrameInlines.h. 16 (JSC::DoublePredictionFuzzerAgent::DoublePredictionFuzzerAgent): 17 (JSC::DoublePredictionFuzzerAgent::getPrediction): 18 * runtime/DoublePredictionFuzzerAgent.h: Copied from Source/JavaScriptCore/interpreter/CallFrameInlines.h. 19 * runtime/JSGlobalObject.cpp: 20 (JSC::makeBoundFunction): 21 * runtime/Options.h: 22 * runtime/VM.cpp: 23 (JSC::VM::VM): 24 1 25 2019-04-04 Robin Morisset <rmorisset@apple.com> 2 26 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r243886 r243925 4794 4794 E3F23A7D1ECF13E500978D99 /* SnippetReg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnippetReg.h; sourceTree = "<group>"; }; 4795 4795 E3F23A7E1ECF13E500978D99 /* SnippetSlowPathCalls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnippetSlowPathCalls.h; sourceTree = "<group>"; }; 4796 E3FC25102256ECF400583518 /* DoublePredictionFuzzerAgent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DoublePredictionFuzzerAgent.cpp; sourceTree = "<group>"; }; 4797 E3FC25112256ECF400583518 /* DoublePredictionFuzzerAgent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoublePredictionFuzzerAgent.h; sourceTree = "<group>"; }; 4796 4798 E3FF752F1D9CEA1200C7E16D /* DOMJITGetterSetter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITGetterSetter.h; sourceTree = "<group>"; }; 4797 4799 E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceProviderCacheItem.h; sourceTree = "<group>"; }; … … 6773 6775 E31618111EC5FE080006A218 /* DOMAttributeGetterSetter.cpp */, 6774 6776 E31618121EC5FE080006A218 /* DOMAttributeGetterSetter.h */, 6777 E3FC25102256ECF400583518 /* DoublePredictionFuzzerAgent.cpp */, 6778 E3FC25112256ECF400583518 /* DoublePredictionFuzzerAgent.h */, 6775 6779 A70447EB17A0BD7000F5898E /* DumpContext.cpp */, 6776 6780 A70447EC17A0BD7000F5898E /* DumpContext.h */, … … 8306 8310 AD4937C91DDD27340077C807 /* WebAssemblyFunction.cpp */, 8307 8311 AD4937CA1DDD27340077C807 /* WebAssemblyFunction.h */, 8312 521322431ECBCE8200F65615 /* WebAssemblyFunctionBase.cpp */, 8313 521322441ECBCE8200F65615 /* WebAssemblyFunctionBase.h */, 8308 8314 523FD88D225566C4003B3DCC /* WebAssemblyFunctionHeapCellType.cpp */, 8309 8315 523FD88C225566C3003B3DCC /* WebAssemblyFunctionHeapCellType.h */, 8310 521322431ECBCE8200F65615 /* WebAssemblyFunctionBase.cpp */,8311 521322441ECBCE8200F65615 /* WebAssemblyFunctionBase.h */,8312 8316 AD2FCBB41DB58DA400B3E736 /* WebAssemblyInstanceConstructor.cpp */, 8313 8317 AD2FCBB51DB58DA400B3E736 /* WebAssemblyInstanceConstructor.h */, … … 8612 8616 0FEC85C11BE167A00080FF74 /* B3Effects.h in Headers */, 8613 8617 0F725CA81C503DED00AD943A /* B3EliminateCommonSubexpressions.h in Headers */, 8618 3395C70722555F6D00BDBFAD /* B3EliminateDeadCode.h in Headers */, 8614 8619 0F5BF1711F23A5A10029D91D /* B3EnsureLoopPreHeaders.h in Headers */, 8615 8620 0F6971EA1D92F42400BA02A5 /* B3FenceValue.h in Headers */, … … 8625 8630 DC69B99D1D15F914002E3C00 /* B3InferSwitches.h in Headers */, 8626 8631 0FEC85BA1BE1462F0080FF74 /* B3InsertionSet.h in Headers */, 8627 523FD88E225566C9003B3DCC /* WebAssemblyFunctionHeapCellType.h in Headers */,8628 8632 0FEC85BB1BE1462F0080FF74 /* B3InsertionSetInlines.h in Headers */, 8629 8633 0FDF67D21D9C6D27001B9825 /* B3Kind.h in Headers */, … … 8818 8822 0FBB73BB1DEF8645002C009E /* DeleteAllCodeEffort.h in Headers */, 8819 8823 0F96303C1D4192CD005609D9 /* DestructionMode.h in Headers */, 8820 527CE35422555FE500C6F382 /* JSToWasmICCallee.h in Headers */,8821 8824 A77A423E17A0BBFD00A8DB81 /* DFGAbstractHeap.h in Headers */, 8822 8825 A704D90317A0BAA8006BA554 /* DFGAbstractInterpreter.h in Headers */, … … 9092 9095 0FCEFAAC1804C13E00472CE4 /* FTLSaveRestore.h in Headers */, 9093 9096 0F25F1B2181635F300522F39 /* FTLSlowPathCall.h in Headers */, 9094 3395C70722555F6D00BDBFAD /* B3EliminateDeadCode.h in Headers */,9095 9097 0F25F1B4181635F300522F39 /* FTLSlowPathCallKey.h in Headers */, 9096 9098 E322E5A71DA644A8006E7709 /* FTLSnippetParams.h in Headers */, … … 9461 9463 70ECA6061AFDBEA200449739 /* JSTemplateObjectDescriptor.h in Headers */, 9462 9464 AD5C36EA1F75AD6A000BCAAF /* JSToWasm.h in Headers */, 9465 527CE35422555FE500C6F382 /* JSToWasmICCallee.h in Headers */, 9463 9466 BC18C42A0E16F5CD00B34460 /* JSType.h in Headers */, 9464 9467 53486BB71C1795C300F6F3AF /* JSTypedArray.h in Headers */, … … 9937 9940 AD4937D41DDD27DE0077C807 /* WebAssemblyFunction.h in Headers */, 9938 9941 521322461ECBCE8200F65615 /* WebAssemblyFunctionBase.h in Headers */, 9942 523FD88E225566C9003B3DCC /* WebAssemblyFunctionHeapCellType.h in Headers */, 9939 9943 AD2FCBF11DB58DAD00B3E736 /* WebAssemblyInstanceConstructor.h in Headers */, 9940 9944 AD2FCC181DB59CB200B3E736 /* WebAssemblyInstanceConstructor.lut.h in Headers */, -
trunk/Source/JavaScriptCore/Sources.txt
r243886 r243925 746 746 runtime/DirectEvalExecutable.cpp 747 747 runtime/DisallowVMReentry.cpp 748 runtime/DoublePredictionFuzzerAgent.cpp 748 749 runtime/DumpContext.cpp 749 750 runtime/ECMAScriptSpecInternalFunctions.cpp -
trunk/Source/JavaScriptCore/interpreter/CallFrameInlines.h
r235419 r243925 27 27 28 28 #include "CallFrame.h" 29 #include "JSCallee.h" 30 #include "JSGlobalObject.h" 29 31 30 32 namespace JSC { -
trunk/Source/JavaScriptCore/runtime/DoublePredictionFuzzerAgent.cpp
r243924 r243925 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #pragma once 27 28 #include "CallFrame.h" 26 #include "config.h" 27 #include "DoublePredictionFuzzerAgent.h" 29 28 30 29 namespace JSC { 31 30 32 inline bool CallFrame::isStackOverflowFrame() const 31 DoublePredictionFuzzerAgent::DoublePredictionFuzzerAgent(VM&) 33 32 { 34 if (callee().isWasm())35 return false;36 return jsCallee() == jsCallee()->globalObject()->stackOverflowFrameCallee();37 33 } 38 34 39 inline bool CallFrame::isWasmFrame() const 35 SpeculatedType DoublePredictionFuzzerAgent::getPrediction(CodeBlock*, const CodeOrigin&, SpeculatedType original) 40 36 { 41 return callee().isWasm(); 37 if (original && mergeSpeculations(original, SpecBytecodeNumber) == SpecBytecodeNumber) 38 return SpecBytecodeDouble; 39 return original; 42 40 } 43 41 -
trunk/Source/JavaScriptCore/runtime/DoublePredictionFuzzerAgent.h
r243924 r243925 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include " CallFrame.h"28 #include "FuzzerAgent.h" 29 29 30 30 namespace JSC { 31 31 32 inline bool CallFrame::isStackOverflowFrame() const 33 { 34 if (callee().isWasm()) 35 return false; 36 return jsCallee() == jsCallee()->globalObject()->stackOverflowFrameCallee(); 37 } 32 class VM; 38 33 39 inline bool CallFrame::isWasmFrame() const 40 { 41 return callee().isWasm(); 42 } 34 class DoublePredictionFuzzerAgent final : public FuzzerAgent { 35 public: 36 DoublePredictionFuzzerAgent(VM&); 37 38 SpeculatedType getPrediction(CodeBlock*, const CodeOrigin&, SpeculatedType) override; 39 }; 43 40 44 41 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r243886 r243925 239 239 { 240 240 VM& vm = exec->vm(); 241 auto scope = DECLARE_THROW_SCOPE(vm); 242 241 243 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 242 244 … … 244 246 JSValue boundThis = exec->uncheckedArgument(1); 245 247 JSValue boundArgs = exec->uncheckedArgument(2); 246 JSValue length = exec->uncheckedArgument(3); 247 JSString* name = asString(exec->uncheckedArgument(4)); 248 249 return JSValue::encode(JSBoundFunction::create( 250 vm, exec, globalObject, target, boundThis, boundArgs.isCell() ? jsCast<JSArray*>(boundArgs) : nullptr, length.asInt32(), name->value(exec))); 248 JSValue lengthValue = exec->uncheckedArgument(3); 249 JSString* nameString = asString(exec->uncheckedArgument(4)); 250 251 ASSERT(lengthValue.isAnyInt()); 252 ASSERT(lengthValue.asAnyInt() <= INT32_MAX); 253 ASSERT(lengthValue.asAnyInt() >= INT32_MIN); 254 int32_t length = lengthValue.toInt32(exec); 255 scope.assertNoException(); 256 257 String name = nameString->value(exec); 258 RETURN_IF_EXCEPTION(scope, { }); 259 260 RELEASE_AND_RETURN(scope, JSValue::encode(JSBoundFunction::create(vm, exec, globalObject, target, boundThis, boundArgs.isCell() ? jsCast<JSArray*>(boundArgs) : nullptr, length, WTFMove(name)))); 251 261 } 252 262 -
trunk/Source/JavaScriptCore/runtime/Options.h
r243857 r243925 438 438 v(unsigned, seedOfRandomizingFuzzerAgent, 1, Normal, nullptr) \ 439 439 v(bool, dumpRandomizingFuzzerAgentPredictions, false, Normal, nullptr) \ 440 v(bool, useDoublePredictionFuzzerAgent, false, Normal, nullptr) \ 440 441 \ 441 442 v(bool, logPhaseTimes, false, Normal, nullptr) \ -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r243886 r243925 42 42 #include "DirectEvalExecutable.h" 43 43 #include "Disassembler.h" 44 #include "DoublePredictionFuzzerAgent.h" 44 45 #include "Error.h" 45 46 #include "ErrorConstructor.h" … … 460 461 } 461 462 #endif // ENABLE(SAMPLING_PROFILER) 463 462 464 if (Options::useRandomizingFuzzerAgent()) 463 465 setFuzzerAgent(std::make_unique<RandomizingFuzzerAgent>(*this)); 466 else if (Options::useDoublePredictionFuzzerAgent()) 467 setFuzzerAgent(std::make_unique<DoublePredictionFuzzerAgent>(*this)); 464 468 465 469 if (Options::alwaysGeneratePCToCodeOriginMap())
Note: See TracChangeset
for help on using the changeset viewer.