| OLD | NEW |
| (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(global, utils) { | |
| 6 | |
| 7 "use strict"; | |
| 8 | |
| 9 %CheckIsBootstrapping(); | |
| 10 | |
| 11 var GlobalSharedArrayBuffer = global.SharedArrayBuffer; | |
| 12 var GlobalObject = global.Object; | |
| 13 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | |
| 14 | |
| 15 // ------------------------------------------------------------------- | |
| 16 | |
| 17 function SharedArrayBufferConstructor(length) { // length = 1 | |
| 18 if (%_IsConstructCall()) { | |
| 19 var byteLength = $toPositiveInteger(length, kInvalidArrayBufferLength); | |
| 20 %ArrayBufferInitialize(this, byteLength, kShared); | |
| 21 } else { | |
| 22 throw MakeTypeError(kConstructorNotFunction, "SharedArrayBuffer"); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 function SharedArrayBufferGetByteLen() { | |
| 27 if (!IS_SHAREDARRAYBUFFER(this)) { | |
| 28 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 29 'SharedArrayBuffer.prototype.byteLength', this); | |
| 30 } | |
| 31 return %_ArrayBufferGetByteLength(this); | |
| 32 } | |
| 33 | |
| 34 function SharedArrayBufferIsViewJS(obj) { | |
| 35 return %ArrayBufferIsView(obj); | |
| 36 } | |
| 37 | |
| 38 | |
| 39 // Set up the SharedArrayBuffer constructor function. | |
| 40 %SetCode(GlobalSharedArrayBuffer, SharedArrayBufferConstructor); | |
| 41 %FunctionSetPrototype(GlobalSharedArrayBuffer, new GlobalObject()); | |
| 42 | |
| 43 // Set up the constructor property on the SharedArrayBuffer prototype object. | |
| 44 %AddNamedProperty(GlobalSharedArrayBuffer.prototype, "constructor", | |
| 45 GlobalSharedArrayBuffer, DONT_ENUM); | |
| 46 | |
| 47 %AddNamedProperty(GlobalSharedArrayBuffer.prototype, | |
| 48 toStringTagSymbol, "SharedArrayBuffer", DONT_ENUM | READ_ONLY); | |
| 49 | |
| 50 utils.InstallGetter(GlobalSharedArrayBuffer.prototype, "byteLength", | |
| 51 SharedArrayBufferGetByteLen); | |
| 52 | |
| 53 utils.InstallFunctions(GlobalSharedArrayBuffer, DONT_ENUM, [ | |
| 54 "isView", SharedArrayBufferIsViewJS | |
| 55 ]); | |
| 56 | |
| 57 }) | |
| OLD | NEW |