OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 var $ArrayBuffer = global.ArrayBuffer; | 7 var $ArrayBuffer = global.ArrayBuffer; |
8 | 8 |
9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
10 | 10 |
11 function ArrayBufferConstructor(length) { // length = 1 | 11 function ArrayBufferConstructor(length) { // length = 1 |
12 if (%_IsConstructCall()) { | 12 if (%_IsConstructCall()) { |
13 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); | 13 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); |
14 %ArrayBufferInitialize(this, byteLength); | 14 %ArrayBufferInitialize(this, byteLength, false); |
15 } else { | 15 } else { |
16 throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]); | 16 throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]); |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 function ArrayBufferGetByteLen() { | 20 function ArrayBufferGetByteLen() { |
21 if (!IS_ARRAYBUFFER(this)) { | 21 if (!IS_ARRAYBUFFER(this)) { |
22 throw MakeTypeError('incompatible_method_receiver', | 22 throw MakeTypeError('incompatible_method_receiver', |
23 ['ArrayBuffer.prototype.byteLength', this]); | 23 ['ArrayBuffer.prototype.byteLength', this]); |
24 } | 24 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array( | 85 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array( |
86 "isView", ArrayBufferIsViewJS | 86 "isView", ArrayBufferIsViewJS |
87 )); | 87 )); |
88 | 88 |
89 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( | 89 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( |
90 "slice", ArrayBufferSlice | 90 "slice", ArrayBufferSlice |
91 )); | 91 )); |
92 } | 92 } |
93 | 93 |
94 SetUpArrayBuffer(); | 94 SetUpArrayBuffer(); |
| 95 |
| 96 // ------------------------------------------------------------------- |
| 97 |
| 98 var $SharedArrayBuffer = global.SharedArrayBuffer; |
| 99 |
| 100 function SharedArrayBufferConstructor(length) { // length = 1 |
| 101 if (%_IsConstructCall()) { |
| 102 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); |
| 103 %ArrayBufferInitialize(this, byteLength, true); |
| 104 } else { |
| 105 throw MakeTypeError('constructor_not_function', ["SharedArrayBuffer"]); |
| 106 } |
| 107 } |
| 108 |
| 109 function SharedArrayBufferGetByteLen() { |
| 110 if (!IS_SHAREDARRAYBUFFER(this)) { |
| 111 throw MakeTypeError('incompatible_method_receiver', |
| 112 ['SharedArrayBuffer.prototype.byteLength', this]); |
| 113 } |
| 114 return %_ArrayBufferGetByteLength(this); |
| 115 } |
| 116 |
| 117 function SharedArrayBufferIsViewJS(obj) { |
| 118 return %ArrayBufferIsView(obj); |
| 119 } |
| 120 |
| 121 function SetUpSharedArrayBuffer() { |
| 122 %CheckIsBootstrapping(); |
| 123 |
| 124 // Set up the SharedArrayBuffer constructor function. |
| 125 %SetCode($SharedArrayBuffer, SharedArrayBufferConstructor); |
| 126 %FunctionSetPrototype($SharedArrayBuffer, new $Object()); |
| 127 |
| 128 // Set up the constructor property on the SharedArrayBuffer prototype object. |
| 129 %AddNamedProperty($SharedArrayBuffer.prototype, "constructor", |
| 130 $SharedArrayBuffer, DONT_ENUM); |
| 131 |
| 132 %AddNamedProperty($SharedArrayBuffer.prototype, |
| 133 symbolToStringTag, "SharedArrayBuffer", DONT_ENUM | READ_ONLY); |
| 134 |
| 135 InstallGetter($SharedArrayBuffer.prototype, "byteLength", |
| 136 SharedArrayBufferGetByteLen); |
| 137 |
| 138 InstallFunctions($SharedArrayBuffer, DONT_ENUM, $Array( |
| 139 "isView", SharedArrayBufferIsViewJS |
| 140 )); |
| 141 } |
| 142 |
| 143 SetUpSharedArrayBuffer(); |
OLD | NEW |