<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[187214] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/187214">187214</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2015-07-22 21:58:34 -0700 (Wed, 22 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Simplify DFG::DesiredIdentifiers and make it possible to turn a UniquedStringImpl* into an identifierNumber at any time
https://bugs.webkit.org/show_bug.cgi?id=147218
Reviewed by Sam Weinig.
I want to be able to take a UniquedStringImpl* and turn it into an identifierNumber at
various points in my work on https://bugs.webkit.org/show_bug.cgi?id=146929. Currently,
most Nodes that deal with identifiers use identifierNumbers and you can only create an
identifierNumber in BytecodeGenerator. DFG::ByteCodeParser does sort of have the
ability to create new identifierNumbers when inlining - it takes the inlined code's
identifiers and either gives them new numbers or reuses numbers from the enclosing
code.
This patch takes that basic functionality and puts it in
DFG::DesiredIdentifiers::ensure(). Anyone can call this at any time to turn a
UniquedStringImpl* into an identifierNumber. This data structure is already used by
Plan to properly install any newly created identifier table entries into the CodeBlock.
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::ByteCodeParser):
(JSC::DFG::ByteCodeParser::noticeArgumentsUse):
(JSC::DFG::ByteCodeParser::linkBlocks):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
(JSC::DFG::ByteCodeParser::buildOperandMapsIfNecessary): Deleted.
* dfg/DFGDesiredIdentifiers.cpp:
(JSC::DFG::DesiredIdentifiers::DesiredIdentifiers):
(JSC::DFG::DesiredIdentifiers::numberOfIdentifiers):
(JSC::DFG::DesiredIdentifiers::ensure):
(JSC::DFG::DesiredIdentifiers::at):
(JSC::DFG::DesiredIdentifiers::addLazily): Deleted.
* dfg/DFGDesiredIdentifiers.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp">trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGDesiredIdentifierscpp">trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGDesiredIdentifiersh">trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (187213 => 187214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-07-23 04:51:48 UTC (rev 187213)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-07-23 04:58:34 UTC (rev 187214)
</span><span class="lines">@@ -1,5 +1,39 @@
</span><span class="cx"> 2015-07-22 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><ins>+ Simplify DFG::DesiredIdentifiers and make it possible to turn a UniquedStringImpl* into an identifierNumber at any time
+ https://bugs.webkit.org/show_bug.cgi?id=147218
+
+ Reviewed by Sam Weinig.
+
+ I want to be able to take a UniquedStringImpl* and turn it into an identifierNumber at
+ various points in my work on https://bugs.webkit.org/show_bug.cgi?id=146929. Currently,
+ most Nodes that deal with identifiers use identifierNumbers and you can only create an
+ identifierNumber in BytecodeGenerator. DFG::ByteCodeParser does sort of have the
+ ability to create new identifierNumbers when inlining - it takes the inlined code's
+ identifiers and either gives them new numbers or reuses numbers from the enclosing
+ code.
+
+ This patch takes that basic functionality and puts it in
+ DFG::DesiredIdentifiers::ensure(). Anyone can call this at any time to turn a
+ UniquedStringImpl* into an identifierNumber. This data structure is already used by
+ Plan to properly install any newly created identifier table entries into the CodeBlock.
+
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::ByteCodeParser):
+ (JSC::DFG::ByteCodeParser::noticeArgumentsUse):
+ (JSC::DFG::ByteCodeParser::linkBlocks):
+ (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
+ (JSC::DFG::ByteCodeParser::buildOperandMapsIfNecessary): Deleted.
+ * dfg/DFGDesiredIdentifiers.cpp:
+ (JSC::DFG::DesiredIdentifiers::DesiredIdentifiers):
+ (JSC::DFG::DesiredIdentifiers::numberOfIdentifiers):
+ (JSC::DFG::DesiredIdentifiers::ensure):
+ (JSC::DFG::DesiredIdentifiers::at):
+ (JSC::DFG::DesiredIdentifiers::addLazily): Deleted.
+ * dfg/DFGDesiredIdentifiers.h:
+
+2015-07-22 Filip Pizlo <fpizlo@apple.com>
+
</ins><span class="cx"> Simplify things like CompareEq(@x,@x)
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=145850
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (187213 => 187214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2015-07-23 04:51:48 UTC (rev 187213)
+++ trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2015-07-23 04:58:34 UTC (rev 187214)
</span><span class="lines">@@ -145,7 +145,6 @@
</span><span class="cx"> , m_parameterSlots(0)
</span><span class="cx"> , m_numPassedVarArgs(0)
</span><span class="cx"> , m_inlineStackTop(0)
</span><del>- , m_haveBuiltOperandMaps(false)
</del><span class="cx"> , m_currentInstruction(0)
</span><span class="cx"> , m_hasDebuggerEnabled(graph.hasDebuggerEnabled())
</span><span class="cx"> {
</span><span class="lines">@@ -838,8 +837,6 @@
</span><span class="cx"> argument->mergeShouldNeverUnbox(true);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void buildOperandMapsIfNecessary();
-
</del><span class="cx"> VM* m_vm;
</span><span class="cx"> CodeBlock* m_codeBlock;
</span><span class="cx"> CodeBlock* m_profiledBlock;
</span><span class="lines">@@ -989,12 +986,6 @@
</span><span class="cx">
</span><span class="cx"> Vector<DelayedSetLocal, 2> m_setLocalQueue;
</span><span class="cx">
</span><del>- // Have we built operand maps? We initialize them lazily, and only when doing
- // inlining.
- bool m_haveBuiltOperandMaps;
- // Mapping between identifier names and numbers.
- BorrowedIdentifierMap m_identifierMap;
-
</del><span class="cx"> CodeBlock* m_dfgCodeBlock;
</span><span class="cx"> CallLinkStatus::ContextMap m_callContextMap;
</span><span class="cx"> StubInfoMap m_dfgStubInfos;
</span><span class="lines">@@ -3961,17 +3952,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void ByteCodeParser::buildOperandMapsIfNecessary()
-{
- if (m_haveBuiltOperandMaps)
- return;
-
- for (size_t i = 0; i < m_codeBlock->numberOfIdentifiers(); ++i)
- m_identifierMap.add(m_codeBlock->identifier(i).impl(), i);
-
- m_haveBuiltOperandMaps = true;
-}
-
</del><span class="cx"> ByteCodeParser::InlineStackEntry::InlineStackEntry(
</span><span class="cx"> ByteCodeParser* byteCodeParser,
</span><span class="cx"> CodeBlock* codeBlock,
</span><span class="lines">@@ -4033,18 +4013,14 @@
</span><span class="cx"> m_inlineCallFrame->arguments.resizeToFit(argumentCountIncludingThis); // Set the number of arguments including this, but don't configure the value recoveries, yet.
</span><span class="cx"> m_inlineCallFrame->kind = kind;
</span><span class="cx">
</span><del>- byteCodeParser->buildOperandMapsIfNecessary();
-
</del><span class="cx"> m_identifierRemap.resize(codeBlock->numberOfIdentifiers());
</span><span class="cx"> m_constantBufferRemap.resize(codeBlock->numberOfConstantBuffers());
</span><span class="cx"> m_switchRemap.resize(codeBlock->numberOfSwitchJumpTables());
</span><span class="cx">
</span><span class="cx"> for (size_t i = 0; i < codeBlock->numberOfIdentifiers(); ++i) {
</span><span class="cx"> UniquedStringImpl* rep = codeBlock->identifier(i).impl();
</span><del>- BorrowedIdentifierMap::AddResult result = byteCodeParser->m_identifierMap.add(rep, byteCodeParser->m_graph.identifiers().numberOfIdentifiers());
- if (result.isNewEntry)
- byteCodeParser->m_graph.identifiers().addLazily(rep);
- m_identifierRemap[i] = result.iterator->value;
</del><ins>+ unsigned index = byteCodeParser->m_graph.identifiers().ensure(rep);
+ m_identifierRemap[i] = index;
</ins><span class="cx"> }
</span><span class="cx"> for (unsigned i = 0; i < codeBlock->numberOfConstantBuffers(); ++i) {
</span><span class="cx"> // If we inline the same code block multiple times, we don't want to needlessly
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGDesiredIdentifierscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp (187213 => 187214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp        2015-07-23 04:51:48 UTC (rev 187213)
+++ trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp        2015-07-23 04:58:34 UTC (rev 187214)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -35,11 +35,13 @@
</span><span class="cx">
</span><span class="cx"> DesiredIdentifiers::DesiredIdentifiers()
</span><span class="cx"> : m_codeBlock(nullptr)
</span><ins>+ , m_didProcessIdentifiers(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> DesiredIdentifiers::DesiredIdentifiers(CodeBlock* codeBlock)
</span><span class="cx"> : m_codeBlock(codeBlock)
</span><ins>+ , m_didProcessIdentifiers(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -52,9 +54,23 @@
</span><span class="cx"> return m_codeBlock->numberOfIdentifiers() + m_addedIdentifiers.size();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void DesiredIdentifiers::addLazily(UniquedStringImpl* rep)
</del><ins>+unsigned DesiredIdentifiers::ensure(UniquedStringImpl* rep)
</ins><span class="cx"> {
</span><del>- m_addedIdentifiers.append(rep);
</del><ins>+ if (!m_didProcessIdentifiers) {
+ // Do this now instead of the constructor so that we don't pay the price on the main
+ // thread. Also, not all compilations need to call ensure().
+ for (unsigned index = m_codeBlock->numberOfIdentifiers(); index--;)
+ m_identifierNumberForName.add(m_codeBlock->identifier(index).impl(), index);
+ m_didProcessIdentifiers = true;
+ }
+
+ auto addResult = m_identifierNumberForName.add(rep, numberOfIdentifiers());
+ unsigned result = addResult.iterator->value;
+ if (addResult.isNewEntry) {
+ m_addedIdentifiers.append(rep);
+ ASSERT(at(result) == rep);
+ }
+ return result;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> UniquedStringImpl* DesiredIdentifiers::at(unsigned index) const
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGDesiredIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.h (187213 => 187214)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.h        2015-07-23 04:51:48 UTC (rev 187213)
+++ trunk/Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.h        2015-07-23 04:58:34 UTC (rev 187214)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> ~DesiredIdentifiers();
</span><span class="cx">
</span><span class="cx"> unsigned numberOfIdentifiers();
</span><del>- void addLazily(UniquedStringImpl*);
</del><ins>+ unsigned ensure(UniquedStringImpl*);
</ins><span class="cx">
</span><span class="cx"> UniquedStringImpl* at(unsigned index) const;
</span><span class="cx">
</span><span class="lines">@@ -56,6 +56,8 @@
</span><span class="cx"> private:
</span><span class="cx"> CodeBlock* m_codeBlock;
</span><span class="cx"> Vector<UniquedStringImpl*> m_addedIdentifiers;
</span><ins>+ HashMap<UniquedStringImpl*, unsigned> m_identifierNumberForName;
+ bool m_didProcessIdentifiers;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } } // namespace JSC::DFG
</span></span></pre>
</div>
</div>
</body>
</html>