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

Side by Side Diff: src/js/harmony-sharedarraybuffer.js

Issue 1500543002: [es6] Unify ArrayBuffer and SharedArrayBuffer constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Get the exceptions right. Other fixes. Created 4 years, 11 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
« no previous file with comments | « src/js/arraybuffer.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 var GlobalSharedArrayBuffer = global.SharedArrayBuffer; 11 var GlobalSharedArrayBuffer = global.SharedArrayBuffer;
12 var GlobalObject = global.Object;
13 var MakeTypeError; 12 var MakeTypeError;
14 var ToPositiveInteger;
15 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
16 13
17 utils.Import(function(from) { 14 utils.Import(function(from) {
18 MakeTypeError = from.MakeTypeError; 15 MakeTypeError = from.MakeTypeError;
19 ToPositiveInteger = from.ToPositiveInteger;
20 }) 16 })
21 17
22 // ------------------------------------------------------------------- 18 // -------------------------------------------------------------------
23 19
24 function SharedArrayBufferConstructor(length) { // length = 1
25 if (!IS_UNDEFINED(new.target)) {
26 var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength);
27 %ArrayBufferInitialize(this, byteLength, kShared);
28 } else {
29 throw MakeTypeError(kConstructorNotFunction, "SharedArrayBuffer");
30 }
31 }
32
33 function SharedArrayBufferGetByteLen() { 20 function SharedArrayBufferGetByteLen() {
34 if (!IS_SHAREDARRAYBUFFER(this)) { 21 if (!IS_SHAREDARRAYBUFFER(this)) {
35 throw MakeTypeError(kIncompatibleMethodReceiver, 22 throw MakeTypeError(kIncompatibleMethodReceiver,
36 'SharedArrayBuffer.prototype.byteLength', this); 23 'SharedArrayBuffer.prototype.byteLength', this);
37 } 24 }
38 return %_ArrayBufferGetByteLength(this); 25 return %_ArrayBufferGetByteLength(this);
39 } 26 }
40 27
41 function SharedArrayBufferIsViewJS(obj) {
42 return %ArrayBufferIsView(obj);
43 }
44
45
46 // Set up the SharedArrayBuffer constructor function.
47 %SetCode(GlobalSharedArrayBuffer, SharedArrayBufferConstructor);
48 %FunctionSetPrototype(GlobalSharedArrayBuffer, new GlobalObject());
49
50 // Set up the constructor property on the SharedArrayBuffer prototype object.
51 %AddNamedProperty(GlobalSharedArrayBuffer.prototype, "constructor",
52 GlobalSharedArrayBuffer, DONT_ENUM);
53
54 %AddNamedProperty(GlobalSharedArrayBuffer.prototype,
55 toStringTagSymbol, "SharedArrayBuffer", DONT_ENUM | READ_ONLY);
56
57 utils.InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength", 28 utils.InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength",
58 SharedArrayBufferGetByteLen); 29 SharedArrayBufferGetByteLen);
59 30
60 utils.InstallFunctions(GlobalSharedArrayBuffer, DONT_ENUM, [
61 "isView", SharedArrayBufferIsViewJS
62 ]);
63
64 }) 31 })
OLDNEW
« 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