[JSC] Avoid code bloating for iteration if block does not have "break"
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Aug 2017 12:15:48 +0000 (12:15 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Aug 2017 12:15:48 +0000 (12:15 +0000)
commit203b295156d22e781c286f8cf53f561aa9253319
tree00d266a1af65551726d4f62410c203500ac494f7
parent7b0b8594041649f81f3cad323383f4d827fe675a
[JSC] Avoid code bloating for iteration if block does not have "break"
https://bugs.webkit.org/show_bug.cgi?id=173228

Reviewed by Keith Miller.

Currently, we always emit code for breaked path when emitting for-of iteration.
But we can know that this breaked path can be used when emitting the bytecode.

This patch adds LabelScope::breakTargetMayBeBound(), which returns true if
the break label may be bound. We emit a breaked path only when it returns
true. This reduces bytecode bloating when using for-of iteration.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::Label::setLocation):
(JSC::BytecodeGenerator::newLabel):
(JSC::BytecodeGenerator::emitLabel):
(JSC::BytecodeGenerator::pushFinallyControlFlowScope):
(JSC::BytecodeGenerator::breakTarget):
(JSC::BytecodeGenerator::continueTarget):
(JSC::BytecodeGenerator::emitEnumeration):
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/Label.h:
(JSC::Label::bind const):
(JSC::Label::hasOneRef const):
(JSC::Label::isBound const):
(JSC::Label::Label): Deleted.
* bytecompiler/LabelScope.h:
(JSC::LabelScope::hasOneRef const):
(JSC::LabelScope::breakTargetMayBeBound const):
* bytecompiler/NodesCodegen.cpp:
(JSC::ContinueNode::trivialTarget):
(JSC::ContinueNode::emitBytecode):
(JSC::BreakNode::trivialTarget):
(JSC::BreakNode::emitBytecode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/bytecompiler/Label.h
Source/JavaScriptCore/bytecompiler/LabelScope.h
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp