Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 if (target_length == 0) return isolate->heap()->undefined_value(); | 770 if (target_length == 0) return isolate->heap()->undefined_value(); |
| 771 | 771 |
| 772 ASSERT(NumberToSize(isolate, source->byte_length()) - target_length >= start); | 772 ASSERT(NumberToSize(isolate, source->byte_length()) - target_length >= start); |
| 773 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); | 773 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); |
| 774 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); | 774 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); |
| 775 CopyBytes(target_data, source_data + start, target_length); | 775 CopyBytes(target_data, source_data + start, target_length); |
| 776 return isolate->heap()->undefined_value(); | 776 return isolate->heap()->undefined_value(); |
| 777 } | 777 } |
| 778 | 778 |
| 779 | 779 |
| 780 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { | |
| 781 HandleScope scope(isolate); | |
| 782 ASSERT(args.length() == 4); | |
| 783 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 784 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | |
| 785 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 2); | |
| 786 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 3); | |
| 787 | |
| 788 holder->set_buffer(*buffer); | |
| 789 holder->set_byte_offset(*byte_offset_object); | |
| 790 holder->set_byte_length(*byte_length_object); | |
| 791 | |
| 792 Handle<Map> map = | |
| 793 isolate->factory()->GetElementsTransitionMap( | |
| 794 holder, EXTERNAL_UNSIGNED_BYTE_ELEMENTS); | |
| 795 holder->set_map(*map); | |
|
Dmitry Lomov (no reviews)
2013/06/03 13:09:04
This is completely unneeded. DataViews are not ext
| |
| 796 return isolate->heap()->undefined_value(); | |
| 797 } | |
| 798 | |
| 799 | |
| 800 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetBuffer) { | |
| 801 HandleScope scope(isolate); | |
| 802 ASSERT(args.length() == 1); | |
| 803 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 804 return (*holder)->buffer(); | |
| 805 } | |
| 806 | |
| 807 | |
| 808 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetByteLength) { | |
| 809 HandleScope scope(isolate); | |
| 810 ASSERT(args.length() == 1); | |
| 811 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 812 return (*holder)->byte_length(); | |
| 813 } | |
| 814 | |
| 815 | |
| 816 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetByteOffset) { | |
| 817 HandleScope scope(isolate); | |
| 818 ASSERT(args.length() == 1); | |
| 819 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 820 return (*holder)->byte_offset(); | |
| 821 } | |
| 822 | |
| 823 | |
| 824 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetInt8) { | |
| 825 HandleScope scope(isolate); | |
| 826 ASSERT(args.length() == 2); | |
| 827 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 828 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
|
Dmitry Lomov (no reviews)
2013/06/03 13:09:04
This is wrong. Even if byte_offset is a result of
| |
| 829 ASSERT(byte_offset >= 0); | |
| 830 return Smi::FromInt((*holder)->Get<int8_t>(byte_offset)); | |
| 831 } | |
| 832 | |
| 833 | |
| 834 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetUint8) { | |
| 835 HandleScope scope(isolate); | |
| 836 ASSERT(args.length() == 2); | |
| 837 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 838 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 839 ASSERT(byte_offset >= 0); | |
| 840 return Smi::FromInt((*holder)->Get<uint8_t>(byte_offset)); | |
| 841 } | |
| 842 | |
| 843 | |
| 844 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetInt16) { | |
| 845 HandleScope scope(isolate); | |
| 846 ASSERT(args.length() == 3); | |
| 847 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 848 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 849 ASSERT(byte_offset >= 0); | |
| 850 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 2); | |
| 851 return Smi::FromInt((*holder)->Get<int16_t>(byte_offset, little_endian)); | |
| 852 } | |
| 853 | |
| 854 | |
| 855 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetUint16) { | |
| 856 HandleScope scope(isolate); | |
| 857 ASSERT(args.length() == 3); | |
| 858 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 859 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 860 ASSERT(byte_offset >= 0); | |
| 861 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 2); | |
| 862 return Smi::FromInt((*holder)->Get<uint16_t>(byte_offset, little_endian)); | |
| 863 } | |
| 864 | |
| 865 | |
| 866 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetInt32) { | |
| 867 HandleScope scope(isolate); | |
| 868 ASSERT(args.length() == 3); | |
| 869 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 870 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 871 ASSERT(byte_offset >= 0); | |
| 872 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 2); | |
| 873 return isolate->heap()->NumberFromInt32( | |
| 874 (*holder)->Get<int32_t>(byte_offset, little_endian)); | |
| 875 } | |
| 876 | |
| 877 | |
| 878 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetUint32) { | |
| 879 HandleScope scope(isolate); | |
| 880 ASSERT(args.length() == 3); | |
| 881 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 882 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 883 ASSERT(byte_offset >= 0); | |
| 884 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 2); | |
| 885 return isolate->heap()->NumberFromUint32( | |
| 886 (*holder)->Get<uint32_t>(byte_offset, little_endian)); | |
| 887 } | |
| 888 | |
| 889 | |
| 890 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetFloat32) { | |
| 891 HandleScope scope(isolate); | |
| 892 ASSERT(args.length() == 3); | |
| 893 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 894 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 895 ASSERT(byte_offset >= 0); | |
| 896 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 2); | |
| 897 return isolate->heap()->NumberFromDouble( | |
| 898 (*holder)->Get<float>(byte_offset, little_endian)); | |
| 899 } | |
| 900 | |
| 901 | |
| 902 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetFloat64) { | |
| 903 HandleScope scope(isolate); | |
| 904 ASSERT(args.length() == 3); | |
| 905 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 906 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 907 ASSERT(byte_offset >= 0); | |
| 908 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 2); | |
| 909 return isolate->heap()->NumberFromDouble( | |
| 910 (*holder)->Get<double>(byte_offset, little_endian)); | |
| 911 } | |
| 912 | |
| 913 | |
| 914 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetInt8) { | |
| 915 HandleScope scope(isolate); | |
| 916 ASSERT(args.length() == 3); | |
| 917 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 918 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 919 ASSERT(byte_offset >= 0); | |
| 920 CONVERT_NUMBER_CHECKED(int8_t, value, Int32, args[2]); | |
| 921 (*holder)->Set(byte_offset, value); | |
| 922 return isolate->heap()->undefined_value(); | |
| 923 } | |
| 924 | |
| 925 | |
| 926 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetUint8) { | |
| 927 HandleScope scope(isolate); | |
| 928 ASSERT(args.length() == 3); | |
| 929 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 930 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 931 ASSERT(byte_offset >= 0); | |
| 932 CONVERT_NUMBER_CHECKED(uint8_t, value, Uint32, args[2]); | |
| 933 (*holder)->Set(byte_offset, value); | |
| 934 return isolate->heap()->undefined_value(); | |
| 935 } | |
| 936 | |
| 937 | |
| 938 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetInt16) { | |
| 939 HandleScope scope(isolate); | |
| 940 ASSERT(args.length() == 4); | |
| 941 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 942 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 943 ASSERT(byte_offset >= 0); | |
| 944 CONVERT_NUMBER_CHECKED(int16_t, value, Int32, args[2]); | |
| 945 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 3); | |
| 946 (*holder)->Set(byte_offset, value, little_endian); | |
| 947 return isolate->heap()->undefined_value(); | |
| 948 } | |
| 949 | |
| 950 | |
| 951 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetUint16) { | |
| 952 HandleScope scope(isolate); | |
| 953 ASSERT(args.length() == 4); | |
| 954 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 955 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 956 ASSERT(byte_offset >= 0); | |
| 957 CONVERT_NUMBER_CHECKED(uint16_t, value, Uint32, args[2]); | |
| 958 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 3); | |
| 959 (*holder)->Set(byte_offset, value, little_endian); | |
| 960 return isolate->heap()->undefined_value(); | |
| 961 } | |
| 962 | |
| 963 | |
| 964 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetInt32) { | |
| 965 HandleScope scope(isolate); | |
| 966 ASSERT(args.length() == 4); | |
| 967 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 968 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 969 ASSERT(byte_offset >= 0); | |
| 970 CONVERT_NUMBER_CHECKED(int32_t, value, Int32, args[2]); | |
| 971 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 3); | |
| 972 (*holder)->Set(byte_offset, value, little_endian); | |
| 973 return isolate->heap()->undefined_value(); | |
| 974 } | |
| 975 | |
| 976 | |
| 977 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetUint32) { | |
| 978 HandleScope scope(isolate); | |
| 979 ASSERT(args.length() == 4); | |
| 980 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 981 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 982 ASSERT(byte_offset >= 0); | |
| 983 CONVERT_NUMBER_CHECKED(uint32_t, value, Uint32, args[2]); | |
| 984 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 3); | |
| 985 (*holder)->Set(byte_offset, value, little_endian); | |
| 986 return isolate->heap()->undefined_value(); | |
| 987 } | |
| 988 | |
| 989 | |
| 990 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetFloat32) { | |
| 991 HandleScope scope(isolate); | |
| 992 ASSERT(args.length() == 4); | |
| 993 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 994 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 995 ASSERT(byte_offset >= 0); | |
| 996 CONVERT_DOUBLE_ARG_CHECKED(value, 2); | |
| 997 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 3); | |
| 998 (*holder)->Set(byte_offset, static_cast<float>(value), little_endian); | |
| 999 return isolate->heap()->undefined_value(); | |
| 1000 } | |
| 1001 | |
| 1002 | |
| 1003 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSetFloat64) { | |
| 1004 HandleScope scope(isolate); | |
| 1005 ASSERT(args.length() == 4); | |
| 1006 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | |
| 1007 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | |
| 1008 ASSERT(byte_offset >= 0); | |
| 1009 CONVERT_DOUBLE_ARG_CHECKED(value, 2); | |
| 1010 CONVERT_BOOLEAN_ARG_CHECKED(little_endian, 3); | |
| 1011 (*holder)->Set(byte_offset, value, little_endian); | |
| 1012 return isolate->heap()->undefined_value(); | |
| 1013 } | |
| 1014 | |
| 1015 | |
| 780 enum TypedArrayId { | 1016 enum TypedArrayId { |
| 781 // arrayIds below should be synchromized with typedarray.js natives. | 1017 // arrayIds below should be synchromized with typedarray.js natives. |
| 782 ARRAY_ID_UINT8 = 1, | 1018 ARRAY_ID_UINT8 = 1, |
| 783 ARRAY_ID_INT8 = 2, | 1019 ARRAY_ID_INT8 = 2, |
| 784 ARRAY_ID_UINT16 = 3, | 1020 ARRAY_ID_UINT16 = 3, |
| 785 ARRAY_ID_INT16 = 4, | 1021 ARRAY_ID_INT16 = 4, |
| 786 ARRAY_ID_UINT32 = 5, | 1022 ARRAY_ID_UINT32 = 5, |
| 787 ARRAY_ID_INT32 = 6, | 1023 ARRAY_ID_INT32 = 6, |
| 788 ARRAY_ID_FLOAT32 = 7, | 1024 ARRAY_ID_FLOAT32 = 7, |
| 789 ARRAY_ID_FLOAT64 = 8, | 1025 ARRAY_ID_FLOAT64 = 8, |
| (...skipping 12732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13522 // Handle last resort GC and make sure to allow future allocations | 13758 // Handle last resort GC and make sure to allow future allocations |
| 13523 // to grow the heap without causing GCs (if possible). | 13759 // to grow the heap without causing GCs (if possible). |
| 13524 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13760 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13525 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13761 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13526 "Runtime::PerformGC"); | 13762 "Runtime::PerformGC"); |
| 13527 } | 13763 } |
| 13528 } | 13764 } |
| 13529 | 13765 |
| 13530 | 13766 |
| 13531 } } // namespace v8::internal | 13767 } } // namespace v8::internal |
| OLD | NEW |