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

Side by Side Diff: src/typedarray.js

Issue 150813004: In-heap small typed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 6 years, 9 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 | Annotate | Revision Log
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); 93 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength);
94 } 94 }
95 95
96 function NAMEConstructByLength(obj, length) { 96 function NAMEConstructByLength(obj, length) {
97 var l = IS_UNDEFINED(length) ? 97 var l = IS_UNDEFINED(length) ?
98 0 : ToPositiveInteger(length, "invalid_typed_array_length"); 98 0 : ToPositiveInteger(length, "invalid_typed_array_length");
99 if (l > %MaxSmi()) { 99 if (l > %MaxSmi()) {
100 throw MakeRangeError("invalid_typed_array_length"); 100 throw MakeRangeError("invalid_typed_array_length");
101 } 101 }
102 var byteLength = l * ELEMENT_SIZE; 102 var byteLength = l * ELEMENT_SIZE;
103 var buffer = new $ArrayBuffer(byteLength); 103 if (byteLength > %TypedArrayMaxSizeInHeap()) {
104 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); 104 var buffer = new $ArrayBuffer(byteLength);
105 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
106 } else {
107 %TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength);
108 }
105 } 109 }
106 110
107 function NAMEConstructByArrayLike(obj, arrayLike) { 111 function NAMEConstructByArrayLike(obj, arrayLike) {
108 var length = arrayLike.length; 112 var length = arrayLike.length;
109 var l = ToPositiveInteger(length, "invalid_typed_array_length"); 113 var l = ToPositiveInteger(length, "invalid_typed_array_length");
110 114
111 if (l > %MaxSmi()) { 115 if (l > %MaxSmi()) {
112 throw MakeRangeError("invalid_typed_array_length"); 116 throw MakeRangeError("invalid_typed_array_length");
113 } 117 }
114 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { 118 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (endInt < 0) { 177 if (endInt < 0) {
174 endInt = MathMax(0, srcLength + endInt); 178 endInt = MathMax(0, srcLength + endInt);
175 } else { 179 } else {
176 endInt = MathMin(endInt, srcLength); 180 endInt = MathMin(endInt, srcLength);
177 } 181 }
178 if (endInt < beginInt) { 182 if (endInt < beginInt) {
179 endInt = beginInt; 183 endInt = beginInt;
180 } 184 }
181 var newLength = endInt - beginInt; 185 var newLength = endInt - beginInt;
182 var beginByteOffset = 186 var beginByteOffset =
183 %TypedArrayGetByteOffset(this) + beginInt * elementSize; 187 this.byteOffset + beginInt * elementSize;
184 return new constructor(%TypedArrayGetBuffer(this), 188 return new constructor(this.buffer,
185 beginByteOffset, newLength); 189 beginByteOffset, newLength);
186 } 190 }
187 } 191 }
188 192
189 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { 193 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) {
190 if (offset > 0) { 194 if (offset > 0) {
191 for (var i = 0; i < sourceLength; i++) { 195 for (var i = 0; i < sourceLength; i++) {
192 target[offset + i] = source[i]; 196 target[offset + i] = source[i];
193 } 197 }
194 } 198 }
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 466
463 "getFloat32", DataViewGetFloat32, 467 "getFloat32", DataViewGetFloat32,
464 "setFloat32", DataViewSetFloat32, 468 "setFloat32", DataViewSetFloat32,
465 469
466 "getFloat64", DataViewGetFloat64, 470 "getFloat64", DataViewGetFloat64,
467 "setFloat64", DataViewSetFloat64 471 "setFloat64", DataViewSetFloat64
468 )); 472 ));
469 } 473 }
470 474
471 SetupDataView(); 475 SetupDataView();
OLDNEW
« src/hydrogen.cc ('K') | « src/runtime.cc ('k') | test/mjsunit/elements-kind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698