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

Side by Side Diff: src/typedarray.js

Issue 21369002: Speed-up 'new TypedArray(arrayLike)'. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: References -> pointers (argh!) Created 7 years, 4 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
« no previous file with comments | « src/runtime.cc ('k') | no next file » | 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 function ConstructByLength(obj, length) { 70 function ConstructByLength(obj, length) {
71 var l = ToPositiveInteger(length, "invalid_typed_array_length"); 71 var l = ToPositiveInteger(length, "invalid_typed_array_length");
72 var byteLength = l * elementSize; 72 var byteLength = l * elementSize;
73 var buffer = new global.ArrayBuffer(byteLength); 73 var buffer = new global.ArrayBuffer(byteLength);
74 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); 74 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength);
75 } 75 }
76 76
77 function ConstructByArrayLike(obj, arrayLike) { 77 function ConstructByArrayLike(obj, arrayLike) {
78 var length = arrayLike.length; 78 var length = arrayLike.length;
79 var l = ToPositiveInteger(length, "invalid_typed_array_length"); 79 var l = ToPositiveInteger(length, "invalid_typed_array_length");
80 var byteLength = l * elementSize; 80 if(!%TypedArrayInitializeFromArrayLike(obj, arrayId, arrayLike, l)) {
81 var buffer = new $ArrayBuffer(byteLength); 81 for (var i = 0; i < l; i++) {
82 %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); 82 obj[i] = arrayLike[i];
83 for (var i = 0; i < l; i++) { 83 }
84 obj[i] = arrayLike[i];
85 } 84 }
86 } 85 }
87 86
88 return function (arg1, arg2, arg3) { 87 return function (arg1, arg2, arg3) {
89 if (%_IsConstructCall()) { 88 if (%_IsConstructCall()) {
90 if (IS_ARRAYBUFFER(arg1)) { 89 if (IS_ARRAYBUFFER(arg1)) {
91 ConstructByArrayBuffer(this, arg1, arg2, arg3); 90 ConstructByArrayBuffer(this, arg1, arg2, arg3);
92 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) || 91 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
93 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) { 92 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
94 ConstructByLength(this, arg1); 93 ConstructByLength(this, arg1);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 586
588 "getFloat32", DataViewGetFloat32, 587 "getFloat32", DataViewGetFloat32,
589 "setFloat32", DataViewSetFloat32, 588 "setFloat32", DataViewSetFloat32,
590 589
591 "getFloat64", DataViewGetFloat64, 590 "getFloat64", DataViewGetFloat64,
592 "setFloat64", DataViewSetFloat64 591 "setFloat64", DataViewSetFloat64
593 )); 592 ));
594 } 593 }
595 594
596 SetupDataView(); 595 SetupDataView();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698