<!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>[196179] 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/196179">196179</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2016-02-05 11:52:19 -0800 (Fri, 05 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Arrayify for a typed array shouldn't create a monster
https://bugs.webkit.org/show_bug.cgi?id=153908
rdar://problem/24290639

Reviewed by Mark Lam.

Previously if you convinced the DFG to emit an Arrayify to ArrayStorage and then gave it a
typed array, you'd corrupt the object.

* runtime/JSArrayBufferView.cpp:
(WTF::printInternal):
* runtime/JSArrayBufferView.h:
* runtime/JSGenericTypedArrayViewInlines.h:
(JSC::JSGenericTypedArrayView&lt;Adaptor&gt;::visitChildren):
(JSC::JSGenericTypedArrayView&lt;Adaptor&gt;::slowDownAndWasteMemory):
* runtime/JSObject.cpp:
(JSC::JSObject::copyButterfly):
(JSC::JSObject::enterDictionaryIndexingMode):
(JSC::JSObject::ensureInt32Slow):
(JSC::JSObject::ensureDoubleSlow):
(JSC::JSObject::ensureContiguousSlow):
(JSC::JSObject::ensureArrayStorageSlow):
(JSC::JSObject::growOutOfLineStorage):
(JSC::getBoundSlotBaseFunctionForGetterSetter):
* runtime/Structure.h:
* tests/stress/arrayify-array-storage-typed-array.js: Added. This test failed.
* tests/stress/arrayify-int32-typed-array.js: Added. This test case already had other protections, but we beefed them up.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSArrayBufferViewcpp">trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSArrayBufferViewh">trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGenericTypedArrayViewInlinesh">trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSObjectcpp">trunk/Source/JavaScriptCore/runtime/JSObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeStructureh">trunk/Source/JavaScriptCore/runtime/Structure.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressarrayifyarraystoragetypedarrayjs">trunk/Source/JavaScriptCore/tests/stress/arrayify-array-storage-typed-array.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressarrayifyint32typedarrayjs">trunk/Source/JavaScriptCore/tests/stress/arrayify-int32-typed-array.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (196178 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-02-05 19:51:54 UTC (rev 196178)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-02-05 19:52:19 UTC (rev 196179)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-02-05  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        Arrayify for a typed array shouldn't create a monster
+        https://bugs.webkit.org/show_bug.cgi?id=153908
+        rdar://problem/24290639
+
+        Reviewed by Mark Lam.
+
+        Previously if you convinced the DFG to emit an Arrayify to ArrayStorage and then gave it a
+        typed array, you'd corrupt the object.
+
+        * runtime/JSArrayBufferView.cpp:
+        (WTF::printInternal):
+        * runtime/JSArrayBufferView.h:
+        * runtime/JSGenericTypedArrayViewInlines.h:
+        (JSC::JSGenericTypedArrayView&lt;Adaptor&gt;::visitChildren):
+        (JSC::JSGenericTypedArrayView&lt;Adaptor&gt;::slowDownAndWasteMemory):
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::copyButterfly):
+        (JSC::JSObject::enterDictionaryIndexingMode):
+        (JSC::JSObject::ensureInt32Slow):
+        (JSC::JSObject::ensureDoubleSlow):
+        (JSC::JSObject::ensureContiguousSlow):
+        (JSC::JSObject::ensureArrayStorageSlow):
+        (JSC::JSObject::growOutOfLineStorage):
+        (JSC::getBoundSlotBaseFunctionForGetterSetter):
+        * runtime/Structure.h:
+        * tests/stress/arrayify-array-storage-typed-array.js: Added. This test failed.
+        * tests/stress/arrayify-int32-typed-array.js: Added. This test case already had other protections, but we beefed them up.
+
</ins><span class="cx"> 2016-02-04  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: InspectorTimelineAgent doesn't need to recompile functions because it now uses the sampling profiler
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSArrayBufferViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp (196178 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp        2016-02-05 19:51:54 UTC (rev 196178)
+++ trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp        2016-02-05 19:52:19 UTC (rev 196179)
</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, 2016 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">@@ -207,3 +207,28 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><ins>+namespace WTF {
+
+using namespace JSC;
+
+void printInternal(PrintStream&amp; out, TypedArrayMode mode)
+{
+    switch (mode) {
+    case FastTypedArray:
+        out.print(&quot;FastTypedArray&quot;);
+        return;
+    case OversizeTypedArray:
+        out.print(&quot;OversizeTypedArray&quot;);
+        return;
+    case WastefulTypedArray:
+        out.print(&quot;WastefulTypedArray&quot;);
+        return;
+    case DataViewMode:
+        out.print(&quot;DataViewMode&quot;);
+        return;
+    }
+    RELEASE_ASSERT_NOT_REACHED();
+}
+
+} // namespace WTF
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSArrayBufferViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h (196178 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h        2016-02-05 19:51:54 UTC (rev 196178)
+++ trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h        2016-02-05 19:52:19 UTC (rev 196179)
</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, 2016 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">@@ -193,5 +193,11 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><ins>+namespace WTF {
+
+void printInternal(PrintStream&amp;, JSC::TypedArrayMode);
+
+} // namespace WTF
+
</ins><span class="cx"> #endif // JSArrayBufferView_h
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGenericTypedArrayViewInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h (196178 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h        2016-02-05 19:51:54 UTC (rev 196178)
+++ trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h        2016-02-05 19:52:19 UTC (rev 196179)
</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, 2016 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">@@ -424,6 +424,7 @@
</span><span class="cx">     }
</span><span class="cx">         
</span><span class="cx">     case WastefulTypedArray:
</span><ins>+        RELEASE_ASSERT(thisObject-&gt;existingBufferInButterfly());
</ins><span class="cx">         break;
</span><span class="cx">         
</span><span class="cx">     case DataViewMode:
</span><span class="lines">@@ -484,6 +485,7 @@
</span><span class="cx">         thisObject-&gt;m_butterfly.setWithoutBarrier(
</span><span class="cx">             bitwise_cast&lt;IndexingHeader*&gt;(thisObject-&gt;vector())-&gt;butterfly());
</span><span class="cx">     } else {
</span><ins>+        RELEASE_ASSERT(!thisObject-&gt;hasIndexingHeader());
</ins><span class="cx">         VM&amp; vm = *heap-&gt;vm();
</span><span class="cx">         thisObject-&gt;m_butterfly.set(vm, thisObject, Butterfly::createOrGrowArrayRight(
</span><span class="cx">             thisObject-&gt;butterfly(), vm, thisObject, thisObject-&gt;structure(),
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSObject.cpp (196178 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSObject.cpp        2016-02-05 19:51:54 UTC (rev 196178)
+++ trunk/Source/JavaScriptCore/runtime/JSObject.cpp        2016-02-05 19:52:19 UTC (rev 196179)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx">  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
</span><span class="cx">  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
</span><del>- *  Copyright (C) 2003-2006, 2008, 2009, 2012-2015 Apple Inc. All rights reserved.
</del><ins>+ *  Copyright (C) 2003-2006, 2008, 2009, 2012-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *  Copyright (C) 2007 Eric Seidel (eric@webkit.org)
</span><span class="cx">  *
</span><span class="cx">  *  This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">     size_t capacityInBytes = Butterfly::totalSize(preCapacity, propertyCapacity, hasIndexingHeader, indexingPayloadSizeInBytes);
</span><span class="cx">     if (visitor.checkIfShouldCopy(butterfly-&gt;base(preCapacity, propertyCapacity))) {
</span><span class="cx">         Butterfly* newButterfly = Butterfly::createUninitializedDuringCollection(visitor, preCapacity, propertyCapacity, hasIndexingHeader, indexingPayloadSizeInBytes);
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Copy the properties.
</span><span class="cx">         PropertyStorage currentTarget = newButterfly-&gt;propertyStorage();
</span><span class="cx">         PropertyStorage currentSource = butterfly-&gt;propertyStorage();
</span><span class="lines">@@ -590,8 +590,11 @@
</span><span class="cx">     case ALL_DOUBLE_INDEXING_TYPES:
</span><span class="cx">     case ALL_CONTIGUOUS_INDEXING_TYPES:
</span><span class="cx">         // NOTE: this is horribly inefficient, as it will perform two conversions. We could optimize
</span><del>-        // this case if we ever cared.
-        enterDictionaryIndexingModeWhenArrayStorageAlreadyExists(vm, ensureArrayStorageSlow(vm));
</del><ins>+        // this case if we ever cared. Note that ensureArrayStorage() can return null if the object
+        // doesn't support traditional indexed properties. At the time of writing, this just affects
+        // typed arrays.
+        if (ArrayStorage* storage = ensureArrayStorageSlow(vm))
+            enterDictionaryIndexingModeWhenArrayStorageAlreadyExists(vm, storage);
</ins><span class="cx">         break;
</span><span class="cx">     case ALL_ARRAY_STORAGE_INDEXING_TYPES:
</span><span class="cx">         enterDictionaryIndexingModeWhenArrayStorageAlreadyExists(vm, m_butterfly.get(this)-&gt;arrayStorage());
</span><span class="lines">@@ -968,6 +971,9 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(inherits(info()));
</span><span class="cx">     
</span><ins>+    if (structure(vm)-&gt;hijacksIndexingHeader())
+        return ContiguousJSValues();
+    
</ins><span class="cx">     switch (indexingType()) {
</span><span class="cx">     case ALL_BLANK_INDEXING_TYPES:
</span><span class="cx">         if (UNLIKELY(indexingShouldBeSparse() || structure(vm)-&gt;needsSlowPutIndexing()))
</span><span class="lines">@@ -992,6 +998,9 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(inherits(info()));
</span><span class="cx">     
</span><ins>+    if (structure(vm)-&gt;hijacksIndexingHeader())
+        return ContiguousDoubles();
+    
</ins><span class="cx">     switch (indexingType()) {
</span><span class="cx">     case ALL_BLANK_INDEXING_TYPES:
</span><span class="cx">         if (UNLIKELY(indexingShouldBeSparse() || structure(vm)-&gt;needsSlowPutIndexing()))
</span><span class="lines">@@ -1018,6 +1027,9 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(inherits(info()));
</span><span class="cx">     
</span><ins>+    if (structure(vm)-&gt;hijacksIndexingHeader())
+        return ContiguousJSValues();
+    
</ins><span class="cx">     switch (indexingType()) {
</span><span class="cx">     case ALL_BLANK_INDEXING_TYPES:
</span><span class="cx">         if (UNLIKELY(indexingShouldBeSparse() || structure(vm)-&gt;needsSlowPutIndexing()))
</span><span class="lines">@@ -1045,6 +1057,9 @@
</span><span class="cx"> ArrayStorage* JSObject::ensureArrayStorageSlow(VM&amp; vm)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(inherits(info()));
</span><ins>+
+    if (structure(vm)-&gt;hijacksIndexingHeader())
+        return nullptr;
</ins><span class="cx">     
</span><span class="cx">     switch (indexingType()) {
</span><span class="cx">     case ALL_BLANK_INDEXING_TYPES:
</span><span class="lines">@@ -2547,7 +2562,7 @@
</span><span class="cx"> 
</span><span class="cx">     // It's important that this function not rely on structure(), for the property
</span><span class="cx">     // capacity, since we might have already mutated the structure in-place.
</span><del>-    
</del><ins>+
</ins><span class="cx">     return Butterfly::createOrGrowPropertyStorage(m_butterfly.get(this), vm, this, structure(vm), oldSize, newSize);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeStructureh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Structure.h (196178 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Structure.h        2016-02-05 19:51:54 UTC (rev 196178)
+++ trunk/Source/JavaScriptCore/runtime/Structure.h        2016-02-05 19:52:19 UTC (rev 196179)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2009, 2012-2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2008, 2009, 2012-2016 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">@@ -320,11 +320,16 @@
</span><span class="cx">             &amp;&amp; offset &lt;= m_offset
</span><span class="cx">             &amp;&amp; (offset &lt; m_inlineCapacity || offset &gt;= firstOutOfLineOffset);
</span><span class="cx">     }
</span><ins>+
+    bool hijacksIndexingHeader() const
+    {
+        return isTypedView(m_classInfo-&gt;typedArrayStorageType);
+    }
</ins><span class="cx">     
</span><span class="cx">     bool couldHaveIndexingHeader() const
</span><span class="cx">     {
</span><span class="cx">         return hasIndexedProperties(indexingType())
</span><del>-            || isTypedView(m_classInfo-&gt;typedArrayStorageType);
</del><ins>+            || hijacksIndexingHeader();
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     bool hasIndexingHeader(const JSCell*) const;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressarrayifyarraystoragetypedarrayjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/arrayify-array-storage-typed-array.js (0 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/arrayify-array-storage-typed-array.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/arrayify-array-storage-typed-array.js        2016-02-05 19:52:19 UTC (rev 196179)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+function make1() {
+    var a = [];
+    a.__defineGetter__(42, function() { return 42; });
+    return a;
+}
+
+noInline(make1);
+
+function make2() {
+    return [42];
+}
+
+noInline(make2);
+
+for (var i = 0; i &lt; 10000; ++i) {
+    make1();
+    make2();
+}
+
+function foo(o) {
+    o[0] = 0;
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 10000; ++i) {
+    foo(make1());
+    foo(make2());
+}
+
+var o = new Int8Array(100);
+var b = o.buffer;
+foo(o);
+if (o.buffer != b)
+    throw &quot;Error: buffer changed.&quot;;
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressarrayifyint32typedarrayjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/arrayify-int32-typed-array.js (0 => 196179)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/arrayify-int32-typed-array.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/arrayify-int32-typed-array.js        2016-02-05 19:52:19 UTC (rev 196179)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+function make1() {
+    return [];
+}
+
+noInline(make1);
+
+function make2() {
+    return [42];
+}
+
+noInline(make2);
+
+for (var i = 0; i &lt; 10000; ++i) {
+    make1();
+    make2();
+}
+
+function foo(o) {
+    o[0] = 0;
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 10000; ++i) {
+    foo(make1());
+    foo(make2());
+}
+
+var o = new Int8Array(100);
+var b = o.buffer;
+foo(o);
+if (o.buffer != b)
+    throw &quot;Error: buffer changed.&quot;;
+
</ins></span></pre>
</div>
</div>

</body>
</html>