<!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>[166013] 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/166013">166013</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-03-20 16:08:30 -0700 (Thu, 20 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement stackmap header version check and support new stackmap formats
https://bugs.webkit.org/show_bug.cgi?id=130535
<rdar://problem/16164284>
Reviewed by Geoffrey Garen.
Add the notion of versioning so that LLVMers can happily implement new stackmap formats
without worrying about WebKit getting version-locked to LLVM. In the future, we will have
to implement parsing for a new LLVM stackmap format before it lands in LLVM, or we'll have
to have a "max usable LLVM revision" limit. But, thanks to versioning, we'll always be
happy to move backward in time to older versions of LLVM.
* ftl/FTLStackMaps.cpp:
(JSC::FTL::readObject):
(JSC::FTL::StackMaps::Constant::parse):
(JSC::FTL::StackMaps::StackSize::parse):
(JSC::FTL::StackMaps::Location::parse):
(JSC::FTL::StackMaps::Record::parse):
(JSC::FTL::StackMaps::parse):
(JSC::FTL::StackMaps::dump):
(JSC::FTL::StackMaps::dumpMultiline):
* ftl/FTLStackMaps.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLStackMapscpp">trunk/Source/JavaScriptCore/ftl/FTLStackMaps.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLStackMapsh">trunk/Source/JavaScriptCore/ftl/FTLStackMaps.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (166012 => 166013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-03-20 23:07:12 UTC (rev 166012)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-03-20 23:08:30 UTC (rev 166013)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2014-03-20 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><ins>+ Implement stackmap header version check and support new stackmap formats
+ https://bugs.webkit.org/show_bug.cgi?id=130535
+ <rdar://problem/16164284>
+
+ Reviewed by Geoffrey Garen.
+
+ Add the notion of versioning so that LLVMers can happily implement new stackmap formats
+ without worrying about WebKit getting version-locked to LLVM. In the future, we will have
+ to implement parsing for a new LLVM stackmap format before it lands in LLVM, or we'll have
+ to have a "max usable LLVM revision" limit. But, thanks to versioning, we'll always be
+ happy to move backward in time to older versions of LLVM.
+
+ * ftl/FTLStackMaps.cpp:
+ (JSC::FTL::readObject):
+ (JSC::FTL::StackMaps::Constant::parse):
+ (JSC::FTL::StackMaps::StackSize::parse):
+ (JSC::FTL::StackMaps::Location::parse):
+ (JSC::FTL::StackMaps::Record::parse):
+ (JSC::FTL::StackMaps::parse):
+ (JSC::FTL::StackMaps::dump):
+ (JSC::FTL::StackMaps::dumpMultiline):
+ * ftl/FTLStackMaps.h:
+
+2014-03-20 Filip Pizlo <fpizlo@apple.com>
+
</ins><span class="cx"> Crash beneath operationTearOffActivation running this JS compression demo
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=130295
</span><span class="cx"> <rdar://problem/16332337>
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLStackMapscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLStackMaps.cpp (166012 => 166013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLStackMaps.cpp        2014-03-20 23:07:12 UTC (rev 166012)
+++ trunk/Source/JavaScriptCore/ftl/FTLStackMaps.cpp        2014-03-20 23:08:30 UTC (rev 166013)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 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">@@ -36,16 +36,16 @@
</span><span class="cx"> namespace JSC { namespace FTL {
</span><span class="cx">
</span><span class="cx"> template<typename T>
</span><del>-T readObject(DataView* view, unsigned& offset)
</del><ins>+T readObject(StackMaps::ParseContext& context)
</ins><span class="cx"> {
</span><span class="cx"> T result;
</span><del>- result.parse(view, offset);
</del><ins>+ result.parse(context);
</ins><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void StackMaps::Constant::parse(DataView* view, unsigned& offset)
</del><ins>+void StackMaps::Constant::parse(StackMaps::ParseContext& context)
</ins><span class="cx"> {
</span><del>- integer = view->read<int64_t>(offset, true);
</del><ins>+ integer = context.view->read<int64_t>(context.offset, true);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void StackMaps::Constant::dump(PrintStream& out) const
</span><span class="lines">@@ -53,10 +53,19 @@
</span><span class="cx"> out.printf("0x%016llx", integer);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void StackMaps::StackSize::parse(DataView* view, unsigned& offset)
</del><ins>+void StackMaps::StackSize::parse(StackMaps::ParseContext& context)
</ins><span class="cx"> {
</span><del>- functionOffset = view->read<uint32_t>(offset, true);
- size = view->read<uint32_t>(offset, true);
</del><ins>+ switch (context.version) {
+ case 0:
+ functionOffset = context.view->read<uint32_t>(context.offset, true);
+ size = context.view->read<uint32_t>(context.offset, true);
+ break;
+
+ default:
+ functionOffset = context.view->read<uint64_t>(context.offset, true);
+ size = context.view->read<uint64_t>(context.offset, true);
+ break;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void StackMaps::StackSize::dump(PrintStream& out) const
</span><span class="lines">@@ -64,12 +73,12 @@
</span><span class="cx"> out.print("(off:", functionOffset, ", size:", size, ")");
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void StackMaps::Location::parse(DataView* view, unsigned& offset)
</del><ins>+void StackMaps::Location::parse(StackMaps::ParseContext& context)
</ins><span class="cx"> {
</span><del>- kind = static_cast<Kind>(view->read<uint8_t>(offset, true));
- size = view->read<uint8_t>(offset, true);
- dwarfRegNum = view->read<uint16_t>(offset, true);
- this->offset = view->read<int32_t>(offset, true);
</del><ins>+ kind = static_cast<Kind>(context.view->read<uint8_t>(context.offset, true));
+ size = context.view->read<uint8_t>(context.offset, true);
+ dwarfRegNum = context.view->read<uint16_t>(context.offset, true);
+ this->offset = context.view->read<int32_t>(context.offset, true);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void StackMaps::Location::dump(PrintStream& out) const
</span><span class="lines">@@ -88,27 +97,35 @@
</span><span class="cx"> FTL::Location::forStackmaps(&stackmaps, *this).restoreInto(jit, savedRegisters, result);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool StackMaps::Record::parse(DataView* view, unsigned& offset)
</del><ins>+bool StackMaps::Record::parse(StackMaps::ParseContext& context)
</ins><span class="cx"> {
</span><del>- int64_t id = view->read<int64_t>(offset, true);
</del><ins>+ int64_t id = context.view->read<int64_t>(context.offset, true);
</ins><span class="cx"> ASSERT(static_cast<int32_t>(id) == id);
</span><span class="cx"> patchpointID = static_cast<uint32_t>(id);
</span><span class="cx"> if (static_cast<int32_t>(patchpointID) < 0)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- instructionOffset = view->read<uint32_t>(offset, true);
- flags = view->read<uint16_t>(offset, true);
</del><ins>+ instructionOffset = context.view->read<uint32_t>(context.offset, true);
+ flags = context.view->read<uint16_t>(context.offset, true);
</ins><span class="cx">
</span><del>- unsigned length = view->read<uint16_t>(offset, true);
</del><ins>+ unsigned length = context.view->read<uint16_t>(context.offset, true);
</ins><span class="cx"> while (length--)
</span><del>- locations.append(readObject<Location>(view, offset));
</del><ins>+ locations.append(readObject<Location>(context));
</ins><span class="cx">
</span><del>- unsigned numLiveOuts = view->read<uint16_t>(offset, true);
</del><ins>+ if (context.version >= 1)
+ context.view->read<uint16_t>(context.offset, true); // padding
+ unsigned numLiveOuts = context.view->read<uint16_t>(context.offset, true);
</ins><span class="cx"> while (numLiveOuts--) {
</span><del>- view->read<uint16_t>(offset, true); // regnum
- view->read<uint8_t>(offset, true); // reserved
- view->read<uint8_t>(offset, true); // size in bytes
</del><ins>+ context.view->read<uint16_t>(context.offset, true); // regnum
+ context.view->read<uint8_t>(context.offset, true); // reserved
+ context.view->read<uint8_t>(context.offset, true); // size in bytes
</ins><span class="cx"> }
</span><ins>+ if (context.version >= 1) {
+ if (context.offset & 7) {
+ ASSERT(!(context.offset & 3));
+ context.view->read<uint32_t>(context.offset, true); // padding
+ }
+ }
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -122,24 +139,38 @@
</span><span class="cx">
</span><span class="cx"> bool StackMaps::parse(DataView* view)
</span><span class="cx"> {
</span><del>- unsigned offset = 0;
</del><ins>+ ParseContext context;
+ context.offset = 0;
+ context.view = view;
</ins><span class="cx">
</span><del>- view->read<uint32_t>(offset, true); // Reserved (header)
</del><ins>+ version = context.version = context.view->read<uint8_t>(context.offset, true);
+
+ context.view->read<uint8_t>(context.offset, true); // Reserved
+ context.view->read<uint8_t>(context.offset, true); // Reserved
+ context.view->read<uint8_t>(context.offset, true); // Reserved
+
+ uint32_t numFunctions;
+ uint32_t numConstants;
+ uint32_t numRecords;
</ins><span class="cx">
</span><del>- uint32_t numFunctions = view->read<uint32_t>(offset, true);
- ASSERT(numFunctions == 1); // There should only be one stack size record
- while (numFunctions--) {
- stackSizes.append(readObject<StackSize>(view, offset));
</del><ins>+ numFunctions = context.view->read<uint32_t>(context.offset, true);
+ if (context.version >= 1) {
+ numConstants = context.view->read<uint32_t>(context.offset, true);
+ numRecords = context.view->read<uint32_t>(context.offset, true);
</ins><span class="cx"> }
</span><ins>+ while (numFunctions--)
+ stackSizes.append(readObject<StackSize>(context));
</ins><span class="cx">
</span><del>- uint32_t numConstants = view->read<uint32_t>(offset, true);
</del><ins>+ if (!context.version)
+ numConstants = context.view->read<uint32_t>(context.offset, true);
</ins><span class="cx"> while (numConstants--)
</span><del>- constants.append(readObject<Constant>(view, offset));
</del><ins>+ constants.append(readObject<Constant>(context));
</ins><span class="cx">
</span><del>- uint32_t numRecords = view->read<uint32_t>(offset, true);
</del><ins>+ if (!context.version)
+ numRecords = context.view->read<uint32_t>(context.offset, true);
</ins><span class="cx"> while (numRecords--) {
</span><span class="cx"> Record record;
</span><del>- if (!record.parse(view, offset))
</del><ins>+ if (!record.parse(context))
</ins><span class="cx"> return false;
</span><span class="cx"> records.append(record);
</span><span class="cx"> }
</span><span class="lines">@@ -149,11 +180,12 @@
</span><span class="cx">
</span><span class="cx"> void StackMaps::dump(PrintStream& out) const
</span><span class="cx"> {
</span><del>- out.print("StackSizes[", listDump(stackSizes), "], Constants:[", listDump(constants), "], Records:[", listDump(records), "]");
</del><ins>+ out.print("Version:", version, ", StackSizes[", listDump(stackSizes), "], Constants:[", listDump(constants), "], Records:[", listDump(records), "]");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void StackMaps::dumpMultiline(PrintStream& out, const char* prefix) const
</span><span class="cx"> {
</span><ins>+ out.print(prefix, "Version: ", version, "\n");
</ins><span class="cx"> out.print(prefix, "StackSizes:\n");
</span><span class="cx"> for (unsigned i = 0; i < stackSizes.size(); ++i)
</span><span class="cx"> out.print(prefix, " ", stackSizes[i], "\n");
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLStackMapsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLStackMaps.h (166012 => 166013)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLStackMaps.h        2014-03-20 23:07:12 UTC (rev 166012)
+++ trunk/Source/JavaScriptCore/ftl/FTLStackMaps.h        2014-03-20 23:08:30 UTC (rev 166013)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2014 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">@@ -39,18 +39,24 @@
</span><span class="cx"> namespace FTL {
</span><span class="cx">
</span><span class="cx"> struct StackMaps {
</span><ins>+ struct ParseContext {
+ unsigned version;
+ DataView* view;
+ unsigned offset;
+ };
+
</ins><span class="cx"> struct Constant {
</span><span class="cx"> int64_t integer;
</span><span class="cx">
</span><del>- void parse(DataView*, unsigned& offset);
</del><ins>+ void parse(ParseContext&);
</ins><span class="cx"> void dump(PrintStream& out) const;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct StackSize {
</span><del>- uint32_t functionOffset;
- uint32_t size;
</del><ins>+ uint64_t functionOffset;
+ uint64_t size;
</ins><span class="cx">
</span><del>- void parse(DataView*, unsigned& offset);
</del><ins>+ void parse(ParseContext&);
</ins><span class="cx"> void dump(PrintStream&) const;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -69,7 +75,7 @@
</span><span class="cx"> Kind kind;
</span><span class="cx"> int32_t offset;
</span><span class="cx">
</span><del>- void parse(DataView*, unsigned& offset);
</del><ins>+ void parse(ParseContext&);
</ins><span class="cx"> void dump(PrintStream& out) const;
</span><span class="cx">
</span><span class="cx"> GPRReg directGPR() const;
</span><span class="lines">@@ -83,10 +89,11 @@
</span><span class="cx">
</span><span class="cx"> Vector<Location> locations;
</span><span class="cx">
</span><del>- bool parse(DataView*, unsigned& offset);
</del><ins>+ bool parse(ParseContext&);
</ins><span class="cx"> void dump(PrintStream&) const;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+ unsigned version;
</ins><span class="cx"> Vector<StackSize> stackSizes;
</span><span class="cx"> Vector<Constant> constants;
</span><span class="cx"> Vector<Record> records;
</span></span></pre>
</div>
</div>
</body>
</html>