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

Unified Diff: src/harmony-sharedarraybuffer.js

Issue 1069883002: WIP SharedArrayBuffer implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update MakeTypeError calls 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
Index: src/harmony-sharedarraybuffer.js
diff --git a/src/harmony-sharedarraybuffer.js b/src/harmony-sharedarraybuffer.js
new file mode 100644
index 0000000000000000000000000000000000000000..915e2b41460a98573c36624058f01225add76e81
--- /dev/null
+++ b/src/harmony-sharedarraybuffer.js
@@ -0,0 +1,54 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function() {
+
+"use strict";
+
+%CheckIsBootstrapping();
+
+// -------------------------------------------------------------------
+
+var GlobalSharedArrayBuffer = global.SharedArrayBuffer;
+
+function SharedArrayBufferConstructor(length) { // length = 1
+ if (%_IsConstructCall()) {
+ var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length');
+ %ArrayBufferInitialize(this, byteLength);
+ } 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);
+}
+
+// Set up the SharedArrayBuffer constructor function.
+%SetCode(GlobalSharedArrayBuffer, SharedArrayBufferConstructor);
+%FunctionSetPrototype(GlobalSharedArrayBuffer, new $Object());
+
+// Set up the constructor property on the SharedArrayBuffer prototype object.
+%AddNamedProperty(GlobalSharedArrayBuffer.prototype, "constructor",
+ GlobalSharedArrayBuffer, DONT_ENUM);
+
+%AddNamedProperty(GlobalSharedArrayBuffer.prototype,
+ symbolToStringTag, "SharedArrayBuffer", DONT_ENUM | READ_ONLY);
+
+InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength",
+ SharedArrayBufferGetByteLen);
+
+InstallFunctions(GlobalSharedArrayBuffer, DONT_ENUM, $Array(
+ "isView", SharedArrayBufferIsViewJS
+));
+
+})();

Powered by Google App Engine
This is Rietveld 408576698