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 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 HandleScope scope(isolate); | 868 HandleScope scope(isolate); |
869 ASSERT(args.length() == 1); | 869 ASSERT(args.length() == 1); |
870 CONVERT_ARG_CHECKED(Object, object, 0); | 870 CONVERT_ARG_CHECKED(Object, object, 0); |
871 return object->IsJSArrayBufferView() | 871 return object->IsJSArrayBufferView() |
872 ? isolate->heap()->true_value() | 872 ? isolate->heap()->true_value() |
873 : isolate->heap()->false_value(); | 873 : isolate->heap()->false_value(); |
874 } | 874 } |
875 | 875 |
876 | 876 |
877 void Runtime::ArrayIdToTypeAndSize( | 877 void Runtime::ArrayIdToTypeAndSize( |
878 int arrayId, ExternalArrayType* array_type, size_t* element_size) { | 878 int arrayId, |
| 879 ExternalArrayType* array_type, |
| 880 ElementsKind* external_elements_kind, |
| 881 ElementsKind* fixed_elements_kind, |
| 882 size_t* element_size) { |
879 switch (arrayId) { | 883 switch (arrayId) { |
880 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \ | 884 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \ |
881 case ARRAY_ID_##TYPE: \ | 885 case ARRAY_ID_##TYPE: \ |
882 *array_type = kExternal##Type##Array; \ | 886 *array_type = kExternal##Type##Array; \ |
| 887 *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS; \ |
| 888 *fixed_elements_kind = TYPE##_ELEMENTS; \ |
883 *element_size = size; \ | 889 *element_size = size; \ |
884 break; | 890 break; |
885 | 891 |
886 TYPED_ARRAYS(ARRAY_ID_CASE) | 892 TYPED_ARRAYS(ARRAY_ID_CASE) |
887 #undef ARRAY_ID_CASE | 893 #undef ARRAY_ID_CASE |
888 | 894 |
889 default: | 895 default: |
890 UNREACHABLE(); | 896 UNREACHABLE(); |
891 } | 897 } |
892 } | 898 } |
893 | 899 |
894 | 900 |
895 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { | 901 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { |
896 HandleScope scope(isolate); | 902 HandleScope scope(isolate); |
897 ASSERT(args.length() == 5); | 903 ASSERT(args.length() == 5); |
898 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 904 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
899 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 905 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
900 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 2); | 906 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); |
901 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3); | 907 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3); |
902 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); | 908 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); |
903 | 909 |
904 ASSERT(holder->GetInternalFieldCount() == | 910 ASSERT(holder->GetInternalFieldCount() == |
905 v8::ArrayBufferView::kInternalFieldCount); | 911 v8::ArrayBufferView::kInternalFieldCount); |
906 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 912 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
907 holder->SetInternalField(i, Smi::FromInt(0)); | 913 holder->SetInternalField(i, Smi::FromInt(0)); |
908 } | 914 } |
909 | 915 |
910 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 916 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
911 size_t element_size = 1; // Bogus initialization. | 917 size_t element_size = 1; // Bogus initialization. |
912 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 918 ElementsKind external_elements_kind = EXTERNAL_INT8_ELEMENTS; |
| 919 ElementsKind fixed_elements_kind = INT8_ELEMENTS; |
| 920 Runtime::ArrayIdToTypeAndSize(arrayId, |
| 921 &array_type, |
| 922 &external_elements_kind, |
| 923 &fixed_elements_kind, |
| 924 &element_size); |
913 | 925 |
914 holder->set_buffer(*buffer); | |
915 holder->set_byte_offset(*byte_offset_object); | 926 holder->set_byte_offset(*byte_offset_object); |
916 holder->set_byte_length(*byte_length_object); | 927 holder->set_byte_length(*byte_length_object); |
917 | 928 |
918 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); | 929 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); |
919 size_t byte_length = NumberToSize(isolate, *byte_length_object); | 930 size_t byte_length = NumberToSize(isolate, *byte_length_object); |
920 ASSERT(byte_length % element_size == 0); | 931 ASSERT(byte_length % element_size == 0); |
921 size_t length = byte_length / element_size; | 932 size_t length = byte_length / element_size; |
922 | 933 |
923 if (length > static_cast<unsigned>(Smi::kMaxValue)) { | 934 if (length > static_cast<unsigned>(Smi::kMaxValue)) { |
924 return isolate->Throw(*isolate->factory()-> | 935 return isolate->Throw(*isolate->factory()-> |
925 NewRangeError("invalid_typed_array_length", | 936 NewRangeError("invalid_typed_array_length", |
926 HandleVector<Object>(NULL, 0))); | 937 HandleVector<Object>(NULL, 0))); |
927 } | 938 } |
928 | 939 |
929 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); | 940 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); |
930 holder->set_length(*length_obj); | 941 holder->set_length(*length_obj); |
931 holder->set_weak_next(buffer->weak_first_view()); | 942 if (!maybe_buffer->IsNull()) { |
932 buffer->set_weak_first_view(*holder); | 943 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(*maybe_buffer)); |
| 944 holder->set_buffer(*buffer); |
| 945 holder->set_weak_next(buffer->weak_first_view()); |
| 946 buffer->set_weak_first_view(*holder); |
933 | 947 |
934 Handle<ExternalArray> elements = | 948 Handle<ExternalArray> elements = |
935 isolate->factory()->NewExternalArray( | 949 isolate->factory()->NewExternalArray( |
936 static_cast<int>(length), array_type, | 950 static_cast<int>(length), array_type, |
937 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 951 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
938 holder->set_elements(*elements); | 952 Handle<Map> map = |
| 953 isolate->factory()->GetElementsTransitionMap( |
| 954 holder, external_elements_kind); |
| 955 holder->set_map_and_elements(*map, *elements); |
| 956 ASSERT(IsExternalArrayElementsKind(holder->map()->elements_kind())); |
| 957 } else { |
| 958 holder->set_buffer(Smi::FromInt(0)); |
| 959 holder->set_weak_next(isolate->heap()->undefined_value()); |
| 960 Handle<FixedTypedArrayBase> elements = |
| 961 isolate->factory()->NewFixedTypedArray( |
| 962 static_cast<int>(length), array_type); |
| 963 holder->set_elements(*elements); |
| 964 } |
939 return isolate->heap()->undefined_value(); | 965 return isolate->heap()->undefined_value(); |
940 } | 966 } |
941 | 967 |
942 | 968 |
943 // Initializes a typed array from an array-like object. | 969 // Initializes a typed array from an array-like object. |
944 // If an array-like object happens to be a typed array of the same type, | 970 // If an array-like object happens to be a typed array of the same type, |
945 // initializes backing store using memove. | 971 // initializes backing store using memove. |
946 // | 972 // |
947 // Returns true if backing store was initialized or false otherwise. | 973 // Returns true if backing store was initialized or false otherwise. |
948 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { | 974 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { |
949 HandleScope scope(isolate); | 975 HandleScope scope(isolate); |
950 ASSERT(args.length() == 4); | 976 ASSERT(args.length() == 4); |
951 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 977 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
952 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 978 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
953 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); | 979 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); |
954 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); | 980 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); |
955 | 981 |
956 ASSERT(holder->GetInternalFieldCount() == | 982 ASSERT(holder->GetInternalFieldCount() == |
957 v8::ArrayBufferView::kInternalFieldCount); | 983 v8::ArrayBufferView::kInternalFieldCount); |
958 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 984 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
959 holder->SetInternalField(i, Smi::FromInt(0)); | 985 holder->SetInternalField(i, Smi::FromInt(0)); |
960 } | 986 } |
961 | 987 |
962 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 988 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
963 size_t element_size = 1; // Bogus initialization. | 989 size_t element_size = 1; // Bogus initialization. |
964 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 990 ElementsKind external_elements_kind; |
| 991 ElementsKind fixed_elements_kind; |
| 992 Runtime::ArrayIdToTypeAndSize(arrayId, |
| 993 &array_type, |
| 994 &external_elements_kind, |
| 995 &fixed_elements_kind, |
| 996 &element_size); |
965 | 997 |
966 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 998 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); |
967 size_t length = NumberToSize(isolate, *length_obj); | 999 size_t length = NumberToSize(isolate, *length_obj); |
968 | 1000 |
969 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 1001 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || |
970 (length > (kMaxInt / element_size))) { | 1002 (length > (kMaxInt / element_size))) { |
971 return isolate->Throw(*isolate->factory()-> | 1003 return isolate->Throw(*isolate->factory()-> |
972 NewRangeError("invalid_typed_array_length", | 1004 NewRangeError("invalid_typed_array_length", |
973 HandleVector<Object>(NULL, 0))); | 1005 HandleVector<Object>(NULL, 0))); |
974 } | 1006 } |
(...skipping 28 matching lines...) Expand all Loading... |
1003 isolate->factory()->NewNumberFromSize(byte_length)); | 1035 isolate->factory()->NewNumberFromSize(byte_length)); |
1004 holder->set_byte_length(*byte_length_obj); | 1036 holder->set_byte_length(*byte_length_obj); |
1005 holder->set_length(*length_obj); | 1037 holder->set_length(*length_obj); |
1006 holder->set_weak_next(buffer->weak_first_view()); | 1038 holder->set_weak_next(buffer->weak_first_view()); |
1007 buffer->set_weak_first_view(*holder); | 1039 buffer->set_weak_first_view(*holder); |
1008 | 1040 |
1009 Handle<ExternalArray> elements = | 1041 Handle<ExternalArray> elements = |
1010 isolate->factory()->NewExternalArray( | 1042 isolate->factory()->NewExternalArray( |
1011 static_cast<int>(length), array_type, | 1043 static_cast<int>(length), array_type, |
1012 static_cast<uint8_t*>(buffer->backing_store())); | 1044 static_cast<uint8_t*>(buffer->backing_store())); |
1013 holder->set_elements(*elements); | 1045 Handle<Map> map = |
| 1046 isolate->factory()->GetElementsTransitionMap( |
| 1047 holder, external_elements_kind); |
| 1048 holder->set_map_and_elements(*map, *elements); |
1014 | 1049 |
1015 if (source->IsJSTypedArray()) { | 1050 if (source->IsJSTypedArray()) { |
1016 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); | 1051 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); |
1017 | 1052 |
1018 if (typed_array->type() == holder->type()) { | 1053 if (typed_array->type() == holder->type()) { |
1019 uint8_t* backing_store = | 1054 uint8_t* backing_store = |
1020 static_cast<uint8_t*>( | 1055 static_cast<uint8_t*>( |
1021 JSArrayBuffer::cast(typed_array->buffer())->backing_store()); | 1056 typed_array->GetBuffer()->backing_store()); |
1022 size_t source_byte_offset = | 1057 size_t source_byte_offset = |
1023 NumberToSize(isolate, typed_array->byte_offset()); | 1058 NumberToSize(isolate, typed_array->byte_offset()); |
1024 memcpy( | 1059 memcpy( |
1025 buffer->backing_store(), | 1060 buffer->backing_store(), |
1026 backing_store + source_byte_offset, | 1061 backing_store + source_byte_offset, |
1027 byte_length); | 1062 byte_length); |
1028 return *isolate->factory()->true_value(); | 1063 return *isolate->factory()->true_value(); |
1029 } else { | 1064 } else { |
1030 return *isolate->factory()->false_value(); | 1065 return *isolate->factory()->false_value(); |
1031 } | 1066 } |
1032 } | 1067 } |
1033 | 1068 |
1034 return *isolate->factory()->false_value(); | 1069 return *isolate->factory()->false_value(); |
1035 } | 1070 } |
1036 | 1071 |
1037 | 1072 |
1038 #define TYPED_ARRAY_GETTER(getter, accessor) \ | 1073 #define TYPED_ARRAY_GETTER(getter, accessor) \ |
1039 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \ | 1074 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \ |
1040 HandleScope scope(isolate); \ | 1075 HandleScope scope(isolate); \ |
1041 ASSERT(args.length() == 1); \ | 1076 ASSERT(args.length() == 1); \ |
1042 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \ | 1077 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \ |
1043 if (!holder->IsJSTypedArray()) \ | 1078 if (!holder->IsJSTypedArray()) \ |
1044 return isolate->Throw(*isolate->factory()->NewTypeError( \ | 1079 return isolate->Throw(*isolate->factory()->NewTypeError( \ |
1045 "not_typed_array", HandleVector<Object>(NULL, 0))); \ | 1080 "not_typed_array", HandleVector<Object>(NULL, 0))); \ |
1046 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \ | 1081 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \ |
1047 return typed_array->accessor(); \ | 1082 return typed_array->accessor(); \ |
1048 } | 1083 } |
1049 | 1084 |
1050 TYPED_ARRAY_GETTER(Buffer, buffer) | |
1051 TYPED_ARRAY_GETTER(ByteLength, byte_length) | 1085 TYPED_ARRAY_GETTER(ByteLength, byte_length) |
1052 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) | 1086 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) |
1053 TYPED_ARRAY_GETTER(Length, length) | 1087 TYPED_ARRAY_GETTER(Length, length) |
1054 | 1088 |
1055 #undef TYPED_ARRAY_GETTER | 1089 #undef TYPED_ARRAY_GETTER |
1056 | 1090 |
| 1091 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) { |
| 1092 HandleScope scope(isolate); |
| 1093 ASSERT(args.length() == 1); |
| 1094 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); |
| 1095 if (!holder->IsJSTypedArray()) |
| 1096 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 1097 "not_typed_array", HandleVector<Object>(NULL, 0))); |
| 1098 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); |
| 1099 return *typed_array->GetBuffer(); |
| 1100 } |
| 1101 |
| 1102 |
1057 // Return codes for Runtime_TypedArraySetFastCases. | 1103 // Return codes for Runtime_TypedArraySetFastCases. |
1058 // Should be synchronized with typedarray.js natives. | 1104 // Should be synchronized with typedarray.js natives. |
1059 enum TypedArraySetResultCodes { | 1105 enum TypedArraySetResultCodes { |
1060 // Set from typed array of the same type. | 1106 // Set from typed array of the same type. |
1061 // This is processed by TypedArraySetFastCases | 1107 // This is processed by TypedArraySetFastCases |
1062 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 1108 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, |
1063 // Set from typed array of the different type, overlapping in memory. | 1109 // Set from typed array of the different type, overlapping in memory. |
1064 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, | 1110 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, |
1065 // Set from typed array of the different type, non-overlapping. | 1111 // Set from typed array of the different type, non-overlapping. |
1066 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 1112 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, |
(...skipping 25 matching lines...) Expand all Loading... |
1092 if (offset > target_length || | 1138 if (offset > target_length || |
1093 offset + source_length > target_length || | 1139 offset + source_length > target_length || |
1094 offset + source_length < offset) // overflow | 1140 offset + source_length < offset) // overflow |
1095 return isolate->Throw(*isolate->factory()->NewRangeError( | 1141 return isolate->Throw(*isolate->factory()->NewRangeError( |
1096 "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); | 1142 "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); |
1097 | 1143 |
1098 size_t target_offset = NumberToSize(isolate, target->byte_offset()); | 1144 size_t target_offset = NumberToSize(isolate, target->byte_offset()); |
1099 size_t source_offset = NumberToSize(isolate, source->byte_offset()); | 1145 size_t source_offset = NumberToSize(isolate, source->byte_offset()); |
1100 uint8_t* target_base = | 1146 uint8_t* target_base = |
1101 static_cast<uint8_t*>( | 1147 static_cast<uint8_t*>( |
1102 JSArrayBuffer::cast(target->buffer())->backing_store()) + target_offset; | 1148 target->GetBuffer()->backing_store()) + target_offset; |
1103 uint8_t* source_base = | 1149 uint8_t* source_base = |
1104 static_cast<uint8_t*>( | 1150 static_cast<uint8_t*>( |
1105 JSArrayBuffer::cast(source->buffer())->backing_store()) + source_offset; | 1151 source->GetBuffer()->backing_store()) + source_offset; |
1106 | 1152 |
1107 // Typed arrays of the same type: use memmove. | 1153 // Typed arrays of the same type: use memmove. |
1108 if (target->type() == source->type()) { | 1154 if (target->type() == source->type()) { |
1109 memmove(target_base + offset * target->element_size(), | 1155 memmove(target_base + offset * target->element_size(), |
1110 source_base, source_byte_length); | 1156 source_base, source_byte_length); |
1111 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); | 1157 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); |
1112 } | 1158 } |
1113 | 1159 |
1114 // Typed arrays of different types over the same backing store | 1160 // Typed arrays of different types over the same backing store |
1115 if ((source_base <= target_base && | 1161 if ((source_base <= target_base && |
1116 source_base + source_byte_length > target_base) || | 1162 source_base + source_byte_length > target_base) || |
1117 (target_base <= source_base && | 1163 (target_base <= source_base && |
1118 target_base + target_byte_length > source_base)) { | 1164 target_base + target_byte_length > source_base)) { |
1119 // We do not support overlapping ArrayBuffers | 1165 // We do not support overlapping ArrayBuffers |
1120 ASSERT( | 1166 ASSERT( |
1121 JSArrayBuffer::cast(target->buffer())->backing_store() == | 1167 target->GetBuffer()->backing_store() == |
1122 JSArrayBuffer::cast(source->buffer())->backing_store()); | 1168 source->GetBuffer()->backing_store()); |
1123 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); | 1169 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); |
1124 } else { // Non-overlapping typed arrays | 1170 } else { // Non-overlapping typed arrays |
1125 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); | 1171 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); |
1126 } | 1172 } |
1127 } | 1173 } |
1128 | 1174 |
1129 | 1175 |
| 1176 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayMaxSizeInHeap) { |
| 1177 ASSERT_OBJECT_SIZE(FLAG_typed_array_max_size_in_heap); |
| 1178 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); |
| 1179 } |
| 1180 |
| 1181 |
1130 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { | 1182 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { |
1131 HandleScope scope(isolate); | 1183 HandleScope scope(isolate); |
1132 ASSERT(args.length() == 4); | 1184 ASSERT(args.length() == 4); |
1133 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 1185 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); |
1134 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 1186 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); |
1135 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); | 1187 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); |
1136 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); | 1188 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); |
1137 | 1189 |
1138 ASSERT(holder->GetInternalFieldCount() == | 1190 ASSERT(holder->GetInternalFieldCount() == |
1139 v8::ArrayBufferView::kInternalFieldCount); | 1191 v8::ArrayBufferView::kInternalFieldCount); |
(...skipping 13451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14591 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ | 14643 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ |
14592 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14644 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
14593 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ | 14645 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ |
14594 } | 14646 } |
14595 | 14647 |
14596 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14648 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
14597 | 14649 |
14598 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14650 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
14599 | 14651 |
14600 | 14652 |
| 14653 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \ |
| 14654 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasFixed##Type##Elements) { \ |
| 14655 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
| 14656 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
| 14657 } |
| 14658 |
| 14659 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
| 14660 |
| 14661 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 14662 |
| 14663 |
14601 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 14664 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { |
14602 SealHandleScope shs(isolate); | 14665 SealHandleScope shs(isolate); |
14603 ASSERT(args.length() == 2); | 14666 ASSERT(args.length() == 2); |
14604 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 14667 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
14605 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 14668 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
14606 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 14669 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
14607 } | 14670 } |
14608 | 14671 |
14609 | 14672 |
14610 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { | 14673 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14969 // Handle last resort GC and make sure to allow future allocations | 15032 // Handle last resort GC and make sure to allow future allocations |
14970 // to grow the heap without causing GCs (if possible). | 15033 // to grow the heap without causing GCs (if possible). |
14971 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15034 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14972 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15035 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14973 "Runtime::PerformGC"); | 15036 "Runtime::PerformGC"); |
14974 } | 15037 } |
14975 } | 15038 } |
14976 | 15039 |
14977 | 15040 |
14978 } } // namespace v8::internal | 15041 } } // namespace v8::internal |
OLD | NEW |