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

Unified Diff: src/js/harmony-sharedarraybuffer.js

Issue 1501673002: Revert of [es6] Correctify and unify ArrayBuffer and SharedArrayBuffer constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/js/arraybuffer.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/harmony-sharedarraybuffer.js
diff --git a/src/js/harmony-sharedarraybuffer.js b/src/js/harmony-sharedarraybuffer.js
index 10ceb70d27b739d434eb3dc1c5f88755a81ddfbb..37480617b51c7bea70c14e3f3ea1140e0f9cc51b 100644
--- a/src/js/harmony-sharedarraybuffer.js
+++ b/src/js/harmony-sharedarraybuffer.js
@@ -9,13 +9,26 @@
%CheckIsBootstrapping();
var GlobalSharedArrayBuffer = global.SharedArrayBuffer;
+var GlobalObject = global.Object;
var MakeTypeError;
+var ToPositiveInteger;
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
+ ToPositiveInteger = from.ToPositiveInteger;
})
// -------------------------------------------------------------------
+
+function SharedArrayBufferConstructor(length) { // length = 1
+ if (!IS_UNDEFINED(new.target)) {
+ var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
+ %ArrayBufferInitialize(this, byteLength, kShared);
+ } else {
+ throw MakeTypeError(kConstructorNotFunction, "SharedArrayBuffer");
+ }
+}
function SharedArrayBufferGetByteLen() {
if (!IS_SHAREDARRAYBUFFER(this)) {
@@ -25,7 +38,27 @@
return %_ArrayBufferGetByteLength(this);
}
+function SharedArrayBufferIsViewJS(obj) {
+ return %ArrayBufferIsView(obj);
+}
+
+
+// Set up the SharedArrayBuffer constructor function.
+%SetCode(GlobalSharedArrayBuffer, SharedArrayBufferConstructor);
+%FunctionSetPrototype(GlobalSharedArrayBuffer, new GlobalObject());
+
+// Set up the constructor property on the SharedArrayBuffer prototype object.
+%AddNamedProperty(GlobalSharedArrayBuffer.prototype, "constructor",
+ GlobalSharedArrayBuffer, DONT_ENUM);
+
+%AddNamedProperty(GlobalSharedArrayBuffer.prototype,
+ toStringTagSymbol, "SharedArrayBuffer", DONT_ENUM | READ_ONLY);
+
utils.InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength",
SharedArrayBufferGetByteLen);
+utils.InstallFunctions(GlobalSharedArrayBuffer, DONT_ENUM, [
+ "isView", SharedArrayBufferIsViewJS
+]);
+
})
« no previous file with comments | « src/js/arraybuffer.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698