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

Side by Side Diff: src/arraybuffer.js

Issue 149053009: V8 JavaScript shared memory prototype. Base URL: https://chromium.googlesource.com/external/v8.git@master
Patch Set: Tweaks Created 6 years, 6 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/api.cc ('k') | src/objects.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 "use strict"; 28 "use strict";
29 29
30 var $ArrayBuffer = global.ArrayBuffer; 30 var $ArrayBuffer = global.ArrayBuffer;
31 31
32 // ------------------------------------------------------------------- 32 // -------------------------------------------------------------------
33 33
34 function ArrayBufferConstructor(length) { // length = 1 34 function ArrayBufferConstructor(length, shared) { // length = 1
35 if (%_IsConstructCall()) { 35 if (%_IsConstructCall()) {
36 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); 36 var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length');
37 %ArrayBufferInitialize(this, byteLength); 37 var is_shared = !!shared;
38 %ArrayBufferInitialize(this, byteLength, is_shared);
38 } else { 39 } else {
39 throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]); 40 throw MakeTypeError('constructor_not_function', ["ArrayBuffer"]);
40 } 41 }
41 } 42 }
42 43
43 function ArrayBufferGetByteLength() { 44 function ArrayBufferGetByteLength() {
44 if (!IS_ARRAYBUFFER(this)) { 45 if (!IS_ARRAYBUFFER(this)) {
45 throw MakeTypeError('incompatible_method_receiver', 46 throw MakeTypeError('incompatible_method_receiver',
46 ['ArrayBuffer.prototype.byteLength', this]); 47 ['ArrayBuffer.prototype.byteLength', this]);
47 } 48 }
48 return %_ArrayBufferGetByteLength(this); 49 return %_ArrayBufferGetByteLength(this);
49 } 50 }
50 51
52 function ArrayBufferGetShared() {
53 if (!IS_ARRAYBUFFER(this)) {
54 throw MakeTypeError('incompatible_method_receiver',
55 ['ArrayBuffer.prototype.shared', this]);
56 }
57 return %ArrayBufferGetShared(this);
58 }
59
51 // ES6 Draft 15.13.5.5.3 60 // ES6 Draft 15.13.5.5.3
52 function ArrayBufferSlice(start, end) { 61 function ArrayBufferSlice(start, end) {
53 if (!IS_ARRAYBUFFER(this)) { 62 if (!IS_ARRAYBUFFER(this)) {
54 throw MakeTypeError('incompatible_method_receiver', 63 throw MakeTypeError('incompatible_method_receiver',
55 ['ArrayBuffer.prototype.slice', this]); 64 ['ArrayBuffer.prototype.slice', this]);
56 } 65 }
57 66
58 var relativeStart = TO_INTEGER(start); 67 var relativeStart = TO_INTEGER(start);
59 if (!IS_UNDEFINED(end)) { 68 if (!IS_UNDEFINED(end)) {
60 end = TO_INTEGER(end); 69 end = TO_INTEGER(end);
(...skipping 21 matching lines...) Expand all
82 var result = new $ArrayBuffer(newLen); 91 var result = new $ArrayBuffer(newLen);
83 92
84 %ArrayBufferSliceImpl(this, result, first); 93 %ArrayBufferSliceImpl(this, result, first);
85 return result; 94 return result;
86 } 95 }
87 96
88 function ArrayBufferIsView(obj) { 97 function ArrayBufferIsView(obj) {
89 return %ArrayBufferIsView(obj); 98 return %ArrayBufferIsView(obj);
90 } 99 }
91 100
101 function ArrayBufferMutexInit(addr) {
102 var a = TO_INTEGER(addr);
103 return %ArrayBufferMutexInit(this, a);
104 }
105
106 function ArrayBufferMutexDestroy(addr) {
107 var a = TO_INTEGER(addr);
108 return %ArrayBufferMutexDestroy(this, a);
109 }
110
111 function ArrayBufferMutexLock(addr) {
112 var a = TO_INTEGER(addr);
113 return %ArrayBufferMutexLock(this, a);
114 }
115
116 function ArrayBufferMutexUnlock(addr) {
117 var a = TO_INTEGER(addr);
118 return %ArrayBufferMutexUnlock(this, a);
119 }
120
121 function ArrayBufferMutexSize(obj) {
122 return %ArrayBufferMutexSize(obj);
123 }
124
125 function ArrayBufferCondInit(addr) {
126 var a = TO_INTEGER(addr);
127 return %ArrayBufferCondInit(this, a);
128 }
129
130 function ArrayBufferCondDestroy(addr) {
131 var a = TO_INTEGER(addr);
132 return %ArrayBufferCondDestroy(this, a);
133 }
134
135 function ArrayBufferCondWait(caddr, maddr) {
136 var ca = TO_INTEGER(caddr);
137 var ma = TO_INTEGER(maddr);
138 return %ArrayBufferCondWait(this, ca, ma);
139 }
140
141 function ArrayBufferCondSignal(addr) {
142 var a = TO_INTEGER(addr);
143 return %ArrayBufferCondSignal(this, a);
144 }
145
146 function ArrayBufferCondBroadcast(addr) {
147 var a = TO_INTEGER(addr);
148 return %ArrayBufferCondBroadcast(this, a);
149 }
150
151 function ArrayBufferCondSize(obj) {
152 return %ArrayBufferCondSize(obj);
153 }
154
155 function ArrayBufferBarrierInit(addr, count) {
156 var a = TO_INTEGER(addr);
157 var c = TO_INTEGER(count);
158 return %ArrayBufferBarrierInit(this, a, c);
159 }
160
161 function ArrayBufferBarrierDestroy(addr) {
162 var a = TO_INTEGER(addr);
163 return %ArrayBufferBarrierDestroy(this, a);
164 }
165
166 function ArrayBufferBarrierWait(addr) {
167 var a = TO_INTEGER(addr);
168 return %ArrayBufferBarrierWait(this, a);
169 }
170
171 function ArrayBufferBarrierSize(obj) {
172 return %ArrayBufferBarrierSize(obj);
173 }
174
92 function SetUpArrayBuffer() { 175 function SetUpArrayBuffer() {
93 %CheckIsBootstrapping(); 176 %CheckIsBootstrapping();
94 177
95 // Set up the ArrayBuffer constructor function. 178 // Set up the ArrayBuffer constructor function.
96 %SetCode($ArrayBuffer, ArrayBufferConstructor); 179 %SetCode($ArrayBuffer, ArrayBufferConstructor);
97 %FunctionSetPrototype($ArrayBuffer, new $Object()); 180 %FunctionSetPrototype($ArrayBuffer, new $Object());
98 181
99 // Set up the constructor property on the ArrayBuffer prototype object. 182 // Set up the constructor property on the ArrayBuffer prototype object.
100 %SetProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM); 183 %SetProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
101 184
102 InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength); 185 InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength);
103 186
187 InstallGetter($ArrayBuffer.prototype, "shared", ArrayBufferGetShared);
188
104 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array( 189 InstallFunctions($ArrayBuffer, DONT_ENUM, $Array(
105 "isView", ArrayBufferIsView 190 "isView", ArrayBufferIsView
106 )); 191 ));
107 192
108 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array( 193 InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array(
194 "mutexInit", ArrayBufferMutexInit,
195 "mutexDestroy", ArrayBufferMutexDestroy,
196 "mutexLock", ArrayBufferMutexLock,
197 "mutexUnlock", ArrayBufferMutexUnlock,
198 "mutexSize", ArrayBufferMutexSize,
199 "condInit", ArrayBufferCondInit,
200 "condDestroy", ArrayBufferCondDestroy,
201 "condWait", ArrayBufferCondWait,
202 "condSignal", ArrayBufferCondSignal,
203 "condBroadcast", ArrayBufferCondBroadcast,
204 "condSize", ArrayBufferCondSize,
205 "barrierInit", ArrayBufferBarrierInit,
206 "barrierDestroy", ArrayBufferBarrierDestroy,
207 "barrierWait", ArrayBufferBarrierWait,
208 "barrierSize", ArrayBufferBarrierSize,
109 "slice", ArrayBufferSlice 209 "slice", ArrayBufferSlice
110 )); 210 ));
111 } 211 }
112 212
113 SetUpArrayBuffer(); 213 SetUpArrayBuffer();
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698