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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function() {
6
7 "use strict";
8
9 %CheckIsBootstrapping();
10
11 // -------------------------------------------------------------------
12
13 var GlobalSharedArrayBuffer = global.SharedArrayBuffer;
14
15 function SharedArrayBufferConstructor(length) { // length = 1
16 if (%_IsConstructCall()) {
17 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length');
18 %ArrayBufferInitialize(this, byteLength);
19 } else {
20 throw MakeTypeError('constructor_not_function', ["SharedArrayBuffer"]);
21 }
22 }
23
24 function SharedArrayBufferGetByteLen() {
25 if (!IS_SHAREDARRAYBUFFER(this)) {
26 throw MakeTypeError('incompatible_method_receiver',
27 ['SharedArrayBuffer.prototype.byteLength', this]);
28 }
29 return %_ArrayBufferGetByteLength(this);
30 }
31
32 function SharedArrayBufferIsViewJS(obj) {
33 return %ArrayBufferIsView(obj);
34 }
35
36 // Set up the SharedArrayBuffer constructor function.
37 %SetCode(GlobalSharedArrayBuffer, SharedArrayBufferConstructor);
38 %FunctionSetPrototype(GlobalSharedArrayBuffer, new $Object());
39
40 // Set up the constructor property on the SharedArrayBuffer prototype object.
41 %AddNamedProperty(GlobalSharedArrayBuffer.prototype, "constructor",
42 GlobalSharedArrayBuffer, DONT_ENUM);
43
44 %AddNamedProperty(GlobalSharedArrayBuffer.prototype,
45 symbolToStringTag, "SharedArrayBuffer", DONT_ENUM | READ_ONLY);
46
47 InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength",
48 SharedArrayBufferGetByteLen);
49
50 InstallFunctions(GlobalSharedArrayBuffer, DONT_ENUM, $Array(
51 "isView", SharedArrayBufferIsViewJS
52 ));
53
54 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698