<!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>[212196] trunk</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/212196">212196</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2017-02-11 14:12:36 -0800 (Sat, 11 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] Implement (Shared)ArrayBuffer.prototype.byteLength
https://bugs.webkit.org/show_bug.cgi?id=166476

Reviewed by Saam Barati.

JSTests:

* ChakraCore/test/typedarray/arraybufferType.baseline-jsc:
* stress/array-buffer-byte-length.js: Added.
(shouldBe):
(shouldThrow):
(Symbol):
* stress/reflect-set.js:

Source/JavaScriptCore:

`byteLength` becomes getter and is set in ArrayBuffer.prototype
and SharedArrayBuffer.prototype. This patch implements the
above getter in native function. We do not have any optimization
path for that for now since ArrayBuffer.prototype.byteLength is
not considered a hot function: while TypedArrays have [] accesses,
ArrayBuffer does not have that. Thus byteLength getter is not so
meaningful for a hot paths like iterations.

* runtime/JSArrayBuffer.cpp:
(JSC::JSArrayBuffer::getOwnPropertySlot): Deleted.
(JSC::JSArrayBuffer::put): Deleted.
(JSC::JSArrayBuffer::defineOwnProperty): Deleted.
(JSC::JSArrayBuffer::deleteProperty): Deleted.
(JSC::JSArrayBuffer::getOwnNonIndexPropertyNames): Deleted.
* runtime/JSArrayBuffer.h:
(JSC::JSArrayBuffer::impl): Deleted.
* runtime/JSArrayBufferPrototype.cpp:
(JSC::arrayBufferProtoGetterFuncByteLength):
(JSC::sharedArrayBufferProtoGetterFuncByteLength):
(JSC::JSArrayBufferPrototype::finishCreation):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChakraCoretesttypedarrayarraybufferTypebaselinejsc">trunk/JSTests/ChakraCore/test/typedarray/arraybufferType.baseline-jsc</a></li>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestsstressreflectsetjs">trunk/JSTests/stress/reflect-set.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSArrayBuffercpp">trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSArrayBufferh">trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSArrayBufferPrototypecpp">trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestsstressarraybufferbytelengthjs">trunk/JSTests/stress/array-buffer-byte-length.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChakraCoretesttypedarrayarraybufferTypebaselinejsc"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChakraCore/test/typedarray/arraybufferType.baseline-jsc (212195 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChakraCore/test/typedarray/arraybufferType.baseline-jsc        2017-02-11 22:12:09 UTC (rev 212195)
+++ trunk/JSTests/ChakraCore/test/typedarray/arraybufferType.baseline-jsc        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -7,6 +7,7 @@
</span><span class="cx"> bar = 42
</span><span class="cx"> 20
</span><span class="cx"> slice
</span><ins>+byteLength
</ins><span class="cx"> constructor
</span><span class="cx"> aaa
</span><span class="cx"> foo
</span><span class="lines">@@ -17,6 +18,7 @@
</span><span class="cx"> foo = 20
</span><span class="cx"> bar = 42
</span><span class="cx"> slice
</span><ins>+byteLength
</ins><span class="cx"> constructor
</span><span class="cx"> aaa
</span><span class="cx"> foo
</span></span></pre></div>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (212195 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2017-02-11 22:12:09 UTC (rev 212195)
+++ trunk/JSTests/ChangeLog        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-02-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        [JSC] Implement (Shared)ArrayBuffer.prototype.byteLength
+        https://bugs.webkit.org/show_bug.cgi?id=166476
+
+        Reviewed by Saam Barati.
+
+        * ChakraCore/test/typedarray/arraybufferType.baseline-jsc:
+        * stress/array-buffer-byte-length.js: Added.
+        (shouldBe):
+        (shouldThrow):
+        (Symbol):
+        * stress/reflect-set.js:
+
</ins><span class="cx"> 2017-02-10  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Object allocation sinking phase doesn't properly handle control flow when emitting a PutHint of a materialized object into a PromotedHeapLocation of a still sunken object
</span></span></pre></div>
<a id="trunkJSTestsstressarraybufferbytelengthjs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/array-buffer-byte-length.js (0 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/array-buffer-byte-length.js                                (rev 0)
+++ trunk/JSTests/stress/array-buffer-byte-length.js        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+function shouldBe(actual, expected)
+{
+    if (actual !== expected)
+        throw new Error(`bad value: ${String(actual)}`);
+}
+
+function shouldThrow(func, errorMessage)
+{
+    var errorThrown = false;
+    var error = null;
+    try {
+        func();
+    } catch (e) {
+        errorThrown = true;
+        error = e;
+    }
+    if (!errorThrown)
+        throw new Error('not thrown');
+    if (String(error) !== errorMessage)
+        throw new Error(`bad error: ${String(error)}`);
+}
+
+{
+    let arrayBuffer = new ArrayBuffer(42);
+    let sharedArrayBuffer = new SharedArrayBuffer(500);
+    shouldBe(arrayBuffer.byteLength, 42);
+    shouldBe(sharedArrayBuffer.byteLength, 500);
+    shouldBe(ArrayBuffer.prototype.hasOwnProperty('byteLength'), true);
+    shouldBe(SharedArrayBuffer.prototype.hasOwnProperty('byteLength'), true);
+
+    shouldBe(arrayBuffer.hasOwnProperty('byteLength'), false);
+    shouldBe(sharedArrayBuffer.hasOwnProperty('byteLength'), false);
+
+    shouldBe(!!Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get, true);
+    shouldBe(!!Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'byteLength').get, true);
+
+    shouldBe(!!Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').set, false);
+    shouldBe(!!Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'byteLength').set, false);
+
+    shouldBe(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get !== Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'byteLength').get, true);
+
+    shouldThrow(() =&gt; {
+        Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get.call(sharedArrayBuffer);
+    }, `TypeError: Receiver should not be a shared array buffer`);
+
+    shouldThrow(() =&gt; {
+        Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'byteLength').get.call(arrayBuffer);
+    }, `TypeError: Receiver should be a shared array buffer`);
+
+    for (let value of [ 0, true, &quot;Cocoa&quot;, null, undefined, Symbol(&quot;Cappuccino&quot;) ]) {
+        shouldThrow(() =&gt; {
+            Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get.call(value);
+        }, `TypeError: Receiver should be an array buffer but was not an object`);
+        shouldThrow(() =&gt; {
+            Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'byteLength').get.call(value);
+        }, `TypeError: Receiver should be an array buffer but was not an object`);
+    }
+
+    shouldThrow(() =&gt; {
+        Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get.call({});
+    }, `TypeError: Receiver should be an array buffer`);
+    shouldThrow(() =&gt; {
+        Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'byteLength').get.call({});
+    }, `TypeError: Receiver should be an array buffer`);
+}
</ins></span></pre></div>
<a id="trunkJSTestsstressreflectsetjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/reflect-set.js (212195 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/reflect-set.js        2017-02-11 22:12:09 UTC (rev 212195)
+++ trunk/JSTests/stress/reflect-set.js        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -490,10 +490,10 @@
</span><span class="cx">     var object = new ArrayBuffer(64);
</span><span class="cx">     shouldBe(Reflect.defineProperty(object, 'byteLength', {
</span><span class="cx">         writable: false
</span><del>-    }), false);
-    shouldBe(Reflect.get(object, 'byteLength'), 64);
</del><ins>+    }), true);
+    shouldBe(Reflect.get(object, 'byteLength'), undefined);
</ins><span class="cx">     shouldBe(Reflect.set(object, 'byteLength', 20), false);
</span><del>-    shouldBe(Reflect.get(object, 'byteLength'), 64);
</del><ins>+    shouldBe(Reflect.get(object, 'byteLength'), undefined);
</ins><span class="cx"> 
</span><span class="cx">     var object = new ArrayBuffer(64);
</span><span class="cx">     shouldBe(Reflect.defineProperty(object, 'hello', {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (212195 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-02-11 22:12:09 UTC (rev 212195)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2017-02-11  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        [JSC] Implement (Shared)ArrayBuffer.prototype.byteLength
+        https://bugs.webkit.org/show_bug.cgi?id=166476
+
+        Reviewed by Saam Barati.
+
+        `byteLength` becomes getter and is set in ArrayBuffer.prototype
+        and SharedArrayBuffer.prototype. This patch implements the
+        above getter in native function. We do not have any optimization
+        path for that for now since ArrayBuffer.prototype.byteLength is
+        not considered a hot function: while TypedArrays have [] accesses,
+        ArrayBuffer does not have that. Thus byteLength getter is not so
+        meaningful for a hot paths like iterations.
+
+        * runtime/JSArrayBuffer.cpp:
+        (JSC::JSArrayBuffer::getOwnPropertySlot): Deleted.
+        (JSC::JSArrayBuffer::put): Deleted.
+        (JSC::JSArrayBuffer::defineOwnProperty): Deleted.
+        (JSC::JSArrayBuffer::deleteProperty): Deleted.
+        (JSC::JSArrayBuffer::getOwnNonIndexPropertyNames): Deleted.
+        * runtime/JSArrayBuffer.h:
+        (JSC::JSArrayBuffer::impl): Deleted.
+        * runtime/JSArrayBufferPrototype.cpp:
+        (JSC::arrayBufferProtoGetterFuncByteLength):
+        (JSC::sharedArrayBufferProtoGetterFuncByteLength):
+        (JSC::JSArrayBufferPrototype::finishCreation):
+
</ins><span class="cx"> 2017-02-10  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Object allocation sinking phase doesn't properly handle control flow when emitting a PutHint of a materialized object into a PromotedHeapLocation of a still sunken object
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSArrayBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp (212195 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp        2017-02-11 22:12:09 UTC (rev 212195)
+++ trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -85,74 +85,5 @@
</span><span class="cx">     return Base::estimatedSize(cell) + bufferEstimatedSize;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool JSArrayBuffer::getOwnPropertySlot(
-    JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot&amp; slot)
-{
-    JSArrayBuffer* thisObject = jsCast&lt;JSArrayBuffer*&gt;(object);
-    
-    if (propertyName == exec-&gt;propertyNames().byteLength) {
-        slot.setValue(thisObject, DontDelete | ReadOnly, jsNumber(thisObject-&gt;impl()-&gt;byteLength()));
-        return true;
-    }
-    
-    return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
-}
-
-bool JSArrayBuffer::put(
-    JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value,
-    PutPropertySlot&amp; slot)
-{
-    VM&amp; vm = exec-&gt;vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    JSArrayBuffer* thisObject = jsCast&lt;JSArrayBuffer*&gt;(cell);
-
-    if (UNLIKELY(isThisValueAltered(slot, thisObject))) {
-        scope.release();
-        return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
-    }
-    
-    if (propertyName == vm.propertyNames-&gt;byteLength)
-        return typeError(exec, scope, slot.isStrictMode(), ASCIILiteral(&quot;Attempting to write to a read-only array buffer property.&quot;));
-
-    scope.release();
-    return Base::put(thisObject, exec, propertyName, value, slot);
-}
-
-bool JSArrayBuffer::defineOwnProperty(
-    JSObject* object, ExecState* exec, PropertyName propertyName,
-    const PropertyDescriptor&amp; descriptor, bool shouldThrow)
-{
-    VM&amp; vm = exec-&gt;vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    JSArrayBuffer* thisObject = jsCast&lt;JSArrayBuffer*&gt;(object);
-    
-    if (propertyName == vm.propertyNames-&gt;byteLength)
-        return typeError(exec, scope, shouldThrow, ASCIILiteral(&quot;Attempting to define read-only array buffer property.&quot;));
-
-    scope.release();
-    return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
-}
-
-bool JSArrayBuffer::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
-{
-    JSArrayBuffer* thisObject = jsCast&lt;JSArrayBuffer*&gt;(cell);
-    
-    if (propertyName == exec-&gt;propertyNames().byteLength)
-        return false;
-    
-    return Base::deleteProperty(thisObject, exec, propertyName);
-}
-
-void JSArrayBuffer::getOwnNonIndexPropertyNames(
-    JSObject* object, ExecState* exec, PropertyNameArray&amp; array, EnumerationMode mode)
-{
-    JSArrayBuffer* thisObject = jsCast&lt;JSArrayBuffer*&gt;(object);
-    
-    if (mode.includeDontEnumProperties())
-        array.add(exec-&gt;propertyNames().byteLength);
-    
-    Base::getOwnNonIndexPropertyNames(thisObject, exec, array, mode);
-}
-
</del><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSArrayBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.h (212195 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.h        2017-02-11 22:12:09 UTC (rev 212195)
+++ trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.h        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -30,10 +30,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-class JSArrayBuffer : public JSNonFinalObject {
</del><ins>+class JSArrayBuffer final : public JSNonFinalObject {
</ins><span class="cx"> public:
</span><del>-    typedef JSNonFinalObject Base;
-    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetPropertyNames | OverridesGetOwnPropertySlot;
</del><ins>+    using Base = JSNonFinalObject;
+    static const unsigned StructureFlags = Base::StructureFlags;
</ins><span class="cx">     
</span><span class="cx"> protected:
</span><span class="cx">     JSArrayBuffer(VM&amp;, Structure*, PassRefPtr&lt;ArrayBuffer&gt;);
</span><span class="lines">@@ -56,14 +56,7 @@
</span><span class="cx">     static ArrayBuffer* toWrapped(VM&amp;, JSValue);
</span><span class="cx">     
</span><span class="cx"> protected:
</span><del>-
</del><span class="cx">     static size_t estimatedSize(JSCell*);
</span><del>-    static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&amp;);
-    static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&amp;);
-    static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&amp;, bool shouldThrow);
-    static bool deleteProperty(JSCell*, ExecState*, PropertyName);
-    
-    static void getOwnNonIndexPropertyNames(JSObject*, ExecState*, PropertyNameArray&amp;, EnumerationMode);
</del><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     ArrayBuffer* m_impl;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSArrayBufferPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp (212195 => 212196)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp        2017-02-11 22:12:09 UTC (rev 212195)
+++ trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp        2017-02-11 22:12:36 UTC (rev 212196)
</span><span class="lines">@@ -70,6 +70,46 @@
</span><span class="cx">     return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// http://tc39.github.io/ecmascript_sharedmem/shmem.html#sec-get-arraybuffer.prototype.bytelength
+static EncodedJSValue JSC_HOST_CALL arrayBufferProtoGetterFuncByteLength(ExecState* exec)
+{
+    VM&amp; vm = exec-&gt;vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    JSValue thisValue = exec-&gt;thisValue();
+    if (!thisValue.isObject())
+        return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Receiver should be an array buffer but was not an object&quot;));
+
+    auto* thisObject = jsDynamicCast&lt;JSArrayBuffer*&gt;(vm, thisValue);
+    if (!thisObject)
+        return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Receiver should be an array buffer&quot;));
+    if (thisObject-&gt;isShared())
+        return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Receiver should not be a shared array buffer&quot;));
+
+    scope.release();
+
+    return JSValue::encode(jsNumber(thisObject-&gt;impl()-&gt;byteLength()));
+}
+
+// http://tc39.github.io/ecmascript_sharedmem/shmem.html#StructuredData.SharedArrayBuffer.prototype.get_byteLength
+static EncodedJSValue JSC_HOST_CALL sharedArrayBufferProtoGetterFuncByteLength(ExecState* exec)
+{
+    VM&amp; vm = exec-&gt;vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    JSValue thisValue = exec-&gt;thisValue();
+    if (!thisValue.isObject())
+        return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Receiver should be an array buffer but was not an object&quot;));
+
+    auto* thisObject = jsDynamicCast&lt;JSArrayBuffer*&gt;(vm, thisValue);
+    if (!thisObject)
+        return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Receiver should be an array buffer&quot;));
+    if (!thisObject-&gt;isShared())
+        return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Receiver should be a shared array buffer&quot;));
+
+    scope.release();
+
+    return JSValue::encode(jsNumber(thisObject-&gt;impl()-&gt;byteLength()));
+}
+
</ins><span class="cx"> const ClassInfo JSArrayBufferPrototype::s_info = {
</span><span class="cx">     &quot;ArrayBufferPrototype&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSArrayBufferPrototype)
</span><span class="cx"> };
</span><span class="lines">@@ -86,6 +126,10 @@
</span><span class="cx">     
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;slice, arrayBufferProtoFuncSlice, DontEnum, 2);
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;toStringTagSymbol, jsString(&amp;vm, arrayBufferSharingModeName(m_sharingMode)), DontEnum | ReadOnly);
</span><ins>+    if (m_sharingMode == ArrayBufferSharingMode::Default)
+        JSC_NATIVE_GETTER(vm.propertyNames-&gt;byteLength, arrayBufferProtoGetterFuncByteLength, DontEnum | ReadOnly);
+    else
+        JSC_NATIVE_GETTER(vm.propertyNames-&gt;byteLength, sharedArrayBufferProtoGetterFuncByteLength, DontEnum | ReadOnly);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSArrayBufferPrototype* JSArrayBufferPrototype::create(VM&amp; vm, JSGlobalObject* globalObject, Structure* structure, ArrayBufferSharingMode sharingMode)
</span></span></pre>
</div>
</div>

</body>
</html>