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

Side by Side Diff: src/js/typedarray.js

Issue 1448933002: Introduce a BuiltinsConstructStub that sets up new.target and does a [[call]] per ES6 9.3.2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/js/regexp.js ('k') | src/js/v8natives.js » ('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 // 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 "toString", TypedArrayToString, 758 "toString", TypedArrayToString,
759 "toLocaleString", TypedArrayToLocaleString 759 "toLocaleString", TypedArrayToLocaleString
760 ]); 760 ]);
761 endmacro 761 endmacro
762 762
763 TYPED_ARRAYS(SETUP_TYPED_ARRAY) 763 TYPED_ARRAYS(SETUP_TYPED_ARRAY)
764 764
765 // --------------------------- DataView ----------------------------- 765 // --------------------------- DataView -----------------------------
766 766
767 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 767 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
768 if (%_IsConstructCall()) { 768 if (IS_UNDEFINED(new.target)) {
769 // TODO(binji): support SharedArrayBuffers?
770 if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer);
771 if (!IS_UNDEFINED(byteOffset)) {
772 byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset);
773 }
774 if (!IS_UNDEFINED(byteLength)) {
775 byteLength = TO_INTEGER(byteLength);
776 }
777
778 var bufferByteLength = %_ArrayBufferGetByteLength(buffer);
779
780 var offset = IS_UNDEFINED(byteOffset) ? 0 : byteOffset;
781 if (offset > bufferByteLength) throw MakeRangeError(kInvalidDataViewOffset);
782
783 var length = IS_UNDEFINED(byteLength)
784 ? bufferByteLength - offset
785 : byteLength;
786 if (length < 0 || offset + length > bufferByteLength) {
787 throw new MakeRangeError(kInvalidDataViewLength);
788 }
789 %_DataViewInitialize(this, buffer, offset, length);
790 } else {
791 throw MakeTypeError(kConstructorNotFunction, "DataView"); 769 throw MakeTypeError(kConstructorNotFunction, "DataView");
792 } 770 }
771
772 // TODO(binji): support SharedArrayBuffers?
773 if (!IS_ARRAYBUFFER(buffer)) throw MakeTypeError(kDataViewNotArrayBuffer);
774 if (!IS_UNDEFINED(byteOffset)) {
775 byteOffset = ToPositiveInteger(byteOffset, kInvalidDataViewOffset);
776 }
777 if (!IS_UNDEFINED(byteLength)) {
778 byteLength = TO_INTEGER(byteLength);
779 }
780
781 var bufferByteLength = %_ArrayBufferGetByteLength(buffer);
782
783 var offset = IS_UNDEFINED(byteOffset) ? 0 : byteOffset;
784 if (offset > bufferByteLength) throw MakeRangeError(kInvalidDataViewOffset);
785
786 var length = IS_UNDEFINED(byteLength)
787 ? bufferByteLength - offset
788 : byteLength;
789 if (length < 0 || offset + length > bufferByteLength) {
790 throw new MakeRangeError(kInvalidDataViewLength);
791 }
792 var result = %NewObject(GlobalDataView, new.target);
793 %_DataViewInitialize(result, buffer, offset, length);
794 return result;
793 } 795 }
794 796
795 function DataViewGetBufferJS() { 797 function DataViewGetBufferJS() {
796 if (!IS_DATAVIEW(this)) { 798 if (!IS_DATAVIEW(this)) {
797 throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this); 799 throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this);
798 } 800 }
799 return %DataViewGetBuffer(this); 801 return %DataViewGetBuffer(this);
800 } 802 }
801 803
802 function DataViewGetByteOffset() { 804 function DataViewGetByteOffset() {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 "setUint32", DataViewSetUint32JS, 889 "setUint32", DataViewSetUint32JS,
888 890
889 "getFloat32", DataViewGetFloat32JS, 891 "getFloat32", DataViewGetFloat32JS,
890 "setFloat32", DataViewSetFloat32JS, 892 "setFloat32", DataViewSetFloat32JS,
891 893
892 "getFloat64", DataViewGetFloat64JS, 894 "getFloat64", DataViewGetFloat64JS,
893 "setFloat64", DataViewSetFloat64JS 895 "setFloat64", DataViewSetFloat64JS
894 ]); 896 ]);
895 897
896 }) 898 })
OLDNEW
« no previous file with comments | « src/js/regexp.js ('k') | src/js/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698