-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scoped Arguements needs to alias between named and unnamed accesses a…
…nd across nested scopes https://bugs.webkit.org/show_bug.cgi?id=261934 rdar://114925088 Reviewed by Yusuke Suzuki. Fixed issue where an access to a named argument and a seperate access via its argument[i] counterpart weren't recognized throughout all JIT tiers as accesses to the same scoped value. The DFG bytecode parser can unknowingly constant fold the read access. Added aliasing via the SymbolTable and its ScopedArgumentsTable for both types of accesses of such values. related objects Added watchpoints for scoped arguments, and shared the watchpoint from the SymbolTableEntry for the named parameter with the ScopedArgument entry for the matching index. Tagged op_put_to_scope bytecodes with a new ScopedArgumentInitialization initialization type in GetPutInfo to signify this shared watchpoint case. Since currently all tiers write to scoped arguments via ScopedArguments::setIndexQuickly(), that is where we fire its watchpoint. Added a new test. * JSTests/stress/arrow-function-captured-arguments-aliased.js: New test. (createOptAll): (createOpt500): (createOpt2000): (createOpt5000): (main): * Source/JavaScriptCore/bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): * Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm: * Source/JavaScriptCore/llint/LowLevelInterpreter64.asm: * Source/JavaScriptCore/runtime/GetPutInfo.h: (JSC::initializationModeName): (JSC::isInitialization): * Source/JavaScriptCore/runtime/ScopedArguments.h: * Source/JavaScriptCore/runtime/ScopedArgumentsTable.cpp: (JSC::ScopedArgumentsTable::tryCreate): (JSC::ScopedArgumentsTable::tryClone): (JSC::ScopedArgumentsTable::trySetLength): (JSC::ScopedArgumentsTable::trySetWatchpointSet): * Source/JavaScriptCore/runtime/ScopedArgumentsTable.h: * Source/JavaScriptCore/runtime/SymbolTable.h: Originally-landed-as: 267815.345@safari-7617-branch (99b8814). rdar://119594814 Canonical link: https://commits.webkit.org/272253@main
- Loading branch information
1 parent
1f9ac8d
commit 0fa56ec
Showing
12 changed files
with
140 additions
and
23 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
JSTests/stress/arrow-function-captured-arguments-aliased.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
function createOptAll(count) { | ||
count = 0; | ||
|
||
return () => { | ||
arguments[0]++; | ||
|
||
return count; | ||
}; | ||
} | ||
|
||
function createOpt500(count) { | ||
count = 0; | ||
|
||
return () => { | ||
arguments[0]++; | ||
|
||
if (arguments[0] < 500) | ||
return arguments[0]; | ||
|
||
return count; | ||
}; | ||
} | ||
|
||
function createOpt2000(count) { | ||
count = 0; | ||
|
||
return () => { | ||
arguments[0]++; | ||
|
||
if (arguments[0] < 2000) | ||
return arguments[0]; | ||
|
||
return count; | ||
}; | ||
} | ||
|
||
function createOpt5000(count) { | ||
count = 0; | ||
|
||
return () => { | ||
arguments[0]++; | ||
|
||
if (arguments[0] < 5000) | ||
return arguments[0]; | ||
|
||
return count; | ||
}; | ||
} | ||
|
||
function main() { | ||
const testCount = 10000; | ||
const createOptFuncs = [createOptAll, createOpt500, createOpt2000, createOpt5000]; | ||
for (createOptFunc of createOptFuncs) { | ||
const opt = createOptFunc(0); | ||
for (let i = 0; i < testCount; i++) { | ||
opt(); | ||
} | ||
|
||
const expectedResult = testCount+1; | ||
let actualResult = opt(); | ||
if (actualResult != expectedResult) | ||
print("Expected " + expectedResult + ", got " + actualResult); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters