https://bugs.webkit.org/show_bug.cgi?id=173510
Reviewed by Yusuke Suzuki.
JSTests:
* test262.yaml:
Source/JavaScriptCore:
* runtime/JSArrayBufferConstructor.cpp:
(JSC::constructArrayBuffer):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218452
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2017-06-17 Keith Miller <keith_miller@apple.com>
+ ArrayBuffer constructor needs to create subclass structures before its buffer
+ https://bugs.webkit.org/show_bug.cgi?id=173510
+
+ Reviewed by Yusuke Suzuki.
+
+ * test262.yaml:
+
+2017-06-17 Keith Miller <keith_miller@apple.com>
+
ArrayPrototype methods should use JSValue::toLength for non-Arrays.
https://bugs.webkit.org/show_bug.cgi?id=173506
- path: test262/test/built-ins/ArrayBuffer/allocation-limit.js
cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], [:strict]
- path: test262/test/built-ins/ArrayBuffer/data-allocation-after-object-creation.js
- cmd: runTest262 :fail, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], []
+ cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], []
- path: test262/test/built-ins/ArrayBuffer/data-allocation-after-object-creation.js
- cmd: runTest262 :fail, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], [:strict]
+ cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], [:strict]
- path: test262/test/built-ins/ArrayBuffer/init-zero.js
cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], []
- path: test262/test/built-ins/ArrayBuffer/init-zero.js
2017-06-17 Keith Miller <keith_miller@apple.com>
+ ArrayBuffer constructor needs to create subclass structures before its buffer
+ https://bugs.webkit.org/show_bug.cgi?id=173510
+
+ Reviewed by Yusuke Suzuki.
+
+ * runtime/JSArrayBufferConstructor.cpp:
+ (JSC::constructArrayBuffer):
+
+2017-06-17 Keith Miller <keith_miller@apple.com>
+
ArrayPrototype methods should use JSValue::toLength for non-Arrays.
https://bugs.webkit.org/show_bug.cgi?id=173506
JSArrayBufferConstructor* constructor =
jsCast<JSArrayBufferConstructor*>(exec->jsCallee());
-
+
+ Structure* arrayBufferStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), constructor->globalObject()->arrayBufferStructure(constructor->sharingMode()));
+ RETURN_IF_EXCEPTION(scope, { });
+
unsigned length;
if (exec->argumentCount()) {
length = exec->uncheckedArgument(0).toIndex(exec, "length");
// with a zero length.
length = 0;
}
-
+
auto buffer = ArrayBuffer::tryCreate(length, 1);
if (!buffer)
return JSValue::encode(throwOutOfMemoryError(exec, scope));
if (constructor->sharingMode() == ArrayBufferSharingMode::Shared)
buffer->makeShared();
-
ASSERT(constructor->sharingMode() == buffer->sharingMode());
-
- Structure* arrayBufferStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), constructor->globalObject()->arrayBufferStructure(constructor->sharingMode()));
- RETURN_IF_EXCEPTION(scope, encodedJSValue());
+
JSArrayBuffer* result = JSArrayBuffer::create(vm, arrayBufferStructure, WTFMove(buffer));
-
return JSValue::encode(result);
}