Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: src/arraybuffer.js

Issue 1069883002: WIP SharedArrayBuffer implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arraybuffer.js
diff --git a/src/arraybuffer.js b/src/arraybuffer.js
index cbb51433bb68e7781aa98443019f88d64f8d9c49..3c5ccbddf7db2baedc128357ae78a4c0f04f73d2 100644
--- a/src/arraybuffer.js
+++ b/src/arraybuffer.js
@@ -11,7 +11,7 @@ var $ArrayBuffer = global.ArrayBuffer;
function ArrayBufferConstructor(length) { // length = 1
if (%_IsConstructCall()) {
var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length');
- %ArrayBufferInitialize(this, byteLength);
+ %ArrayBufferInitialize(this, byteLength, false);
} else {
throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]);
}
@@ -92,3 +92,52 @@ function SetUpArrayBuffer() {
}
SetUpArrayBuffer();
+
+// -------------------------------------------------------------------
+
+var $SharedArrayBuffer = global.SharedArrayBuffer;
+
+function SharedArrayBufferConstructor(length) { // length = 1
+ if (%_IsConstructCall()) {
+ var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length');
+ %ArrayBufferInitialize(this, byteLength, true);
+ } else {
+ throw MakeTypeError('constructor_not_function', ["SharedArrayBuffer"]);
+ }
+}
+
+function SharedArrayBufferGetByteLen() {
+ if (!IS_SHAREDARRAYBUFFER(this)) {
+ throw MakeTypeError('incompatible_method_receiver',
+ ['SharedArrayBuffer.prototype.byteLength', this]);
+ }
+ return %_ArrayBufferGetByteLength(this);
+}
+
+function SharedArrayBufferIsViewJS(obj) {
+ return %ArrayBufferIsView(obj);
+}
+
+function SetUpSharedArrayBuffer() {
+ %CheckIsBootstrapping();
+
+ // Set up the SharedArrayBuffer constructor function.
+ %SetCode($SharedArrayBuffer, SharedArrayBufferConstructor);
+ %FunctionSetPrototype($SharedArrayBuffer, new $Object());
+
+ // Set up the constructor property on the SharedArrayBuffer prototype object.
+ %AddNamedProperty($SharedArrayBuffer.prototype, "constructor",
+ $SharedArrayBuffer, DONT_ENUM);
+
+ %AddNamedProperty($SharedArrayBuffer.prototype,
+ symbolToStringTag, "SharedArrayBuffer", DONT_ENUM | READ_ONLY);
+
+ InstallGetter($SharedArrayBuffer.prototype, "byteLength",
+ SharedArrayBufferGetByteLen);
+
+ InstallFunctions($SharedArrayBuffer, DONT_ENUM, $Array(
+ "isView", SharedArrayBufferIsViewJS
+ ));
+}
+
+SetUpSharedArrayBuffer();
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698