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 #ifdef DEBUG | |
956 holder->map()->Print(); | |
mvstanton
2014/03/03 10:37:49
Remove this debugging code.
Dmitry Lomov (no reviews)
2014/03/10 09:20:35
Done.
| |
957 map->Print(); | |
958 #endif | |
959 holder->set_map_and_elements(*map, *elements); | |
960 ASSERT(IsExternalArrayElementsKind(holder->map()->elements_kind())); | |
961 } else { | |
962 holder->set_buffer(Smi::FromInt(0)); | |
963 holder->set_weak_next(isolate->heap()->undefined_value()); | |
964 Handle<FixedTypedArrayBase> elements = | |
965 isolate->factory()->NewFixedTypedArray( | |
966 static_cast<int>(length), array_type); | |
967 holder->set_elements(*elements); | |
968 } | |
939 return isolate->heap()->undefined_value(); | 969 return isolate->heap()->undefined_value(); |
940 } | 970 } |
941 | 971 |
942 | 972 |
943 // Initializes a typed array from an array-like object. | 973 // 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, | 974 // If an array-like object happens to be a typed array of the same type, |
945 // initializes backing store using memove. | 975 // initializes backing store using memove. |
946 // | 976 // |
947 // Returns true if backing store was initialized or false otherwise. | 977 // Returns true if backing store was initialized or false otherwise. |
948 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { | 978 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { |
949 HandleScope scope(isolate); | 979 HandleScope scope(isolate); |
950 ASSERT(args.length() == 4); | 980 ASSERT(args.length() == 4); |
951 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 981 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
952 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 982 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
953 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); | 983 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); |
954 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); | 984 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); |
955 | 985 |
956 ASSERT(holder->GetInternalFieldCount() == | 986 ASSERT(holder->GetInternalFieldCount() == |
957 v8::ArrayBufferView::kInternalFieldCount); | 987 v8::ArrayBufferView::kInternalFieldCount); |
958 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 988 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
959 holder->SetInternalField(i, Smi::FromInt(0)); | 989 holder->SetInternalField(i, Smi::FromInt(0)); |
960 } | 990 } |
961 | 991 |
962 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 992 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
963 size_t element_size = 1; // Bogus initialization. | 993 size_t element_size = 1; // Bogus initialization. |
964 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 994 ElementsKind external_elements_kind; |
995 ElementsKind fixed_elements_kind; | |
996 Runtime::ArrayIdToTypeAndSize(arrayId, | |
997 &array_type, | |
998 &external_elements_kind, | |
999 &fixed_elements_kind, | |
1000 &element_size); | |
965 | 1001 |
966 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 1002 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); |
967 size_t length = NumberToSize(isolate, *length_obj); | 1003 size_t length = NumberToSize(isolate, *length_obj); |
968 | 1004 |
969 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 1005 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || |
970 (length > (kMaxInt / element_size))) { | 1006 (length > (kMaxInt / element_size))) { |
971 return isolate->Throw(*isolate->factory()-> | 1007 return isolate->Throw(*isolate->factory()-> |
972 NewRangeError("invalid_typed_array_length", | 1008 NewRangeError("invalid_typed_array_length", |
973 HandleVector<Object>(NULL, 0))); | 1009 HandleVector<Object>(NULL, 0))); |
974 } | 1010 } |
(...skipping 28 matching lines...) Expand all Loading... | |
1003 isolate->factory()->NewNumberFromSize(byte_length)); | 1039 isolate->factory()->NewNumberFromSize(byte_length)); |
1004 holder->set_byte_length(*byte_length_obj); | 1040 holder->set_byte_length(*byte_length_obj); |
1005 holder->set_length(*length_obj); | 1041 holder->set_length(*length_obj); |
1006 holder->set_weak_next(buffer->weak_first_view()); | 1042 holder->set_weak_next(buffer->weak_first_view()); |
1007 buffer->set_weak_first_view(*holder); | 1043 buffer->set_weak_first_view(*holder); |
1008 | 1044 |
1009 Handle<ExternalArray> elements = | 1045 Handle<ExternalArray> elements = |
1010 isolate->factory()->NewExternalArray( | 1046 isolate->factory()->NewExternalArray( |
1011 static_cast<int>(length), array_type, | 1047 static_cast<int>(length), array_type, |
1012 static_cast<uint8_t*>(buffer->backing_store())); | 1048 static_cast<uint8_t*>(buffer->backing_store())); |
1013 holder->set_elements(*elements); | 1049 Handle<Map> map = |
1050 isolate->factory()->GetElementsTransitionMap( | |
1051 holder, external_elements_kind); | |
1052 holder->set_map_and_elements(*map, *elements); | |
1014 | 1053 |
1015 if (source->IsJSTypedArray()) { | 1054 if (source->IsJSTypedArray()) { |
1016 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); | 1055 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); |
1017 | 1056 |
1018 if (typed_array->type() == holder->type()) { | 1057 if (typed_array->type() == holder->type()) { |
1019 uint8_t* backing_store = | 1058 uint8_t* backing_store = |
1020 static_cast<uint8_t*>( | 1059 static_cast<uint8_t*>( |
1021 JSArrayBuffer::cast(typed_array->buffer())->backing_store()); | 1060 typed_array->GetBuffer()->backing_store()); |
1022 size_t source_byte_offset = | 1061 size_t source_byte_offset = |
1023 NumberToSize(isolate, typed_array->byte_offset()); | 1062 NumberToSize(isolate, typed_array->byte_offset()); |
1024 memcpy( | 1063 memcpy( |
mvstanton
2014/03/03 10:37:49
Could the memcpy code in this block be encapsulate
Dmitry Lomov (no reviews)
2014/03/10 09:20:35
Maybe, but maybe in separate CL?
mvstanton
2014/03/11 10:43:51
Yep, okay. It seems weird to me to see primitive m
| |
1025 buffer->backing_store(), | 1064 buffer->backing_store(), |
1026 backing_store + source_byte_offset, | 1065 backing_store + source_byte_offset, |
1027 byte_length); | 1066 byte_length); |
1028 return *isolate->factory()->true_value(); | 1067 return *isolate->factory()->true_value(); |
1029 } else { | 1068 } else { |
1030 return *isolate->factory()->false_value(); | 1069 return *isolate->factory()->false_value(); |
1031 } | 1070 } |
1032 } | 1071 } |
1033 | 1072 |
1034 return *isolate->factory()->false_value(); | 1073 return *isolate->factory()->false_value(); |
1035 } | 1074 } |
1036 | 1075 |
1037 | 1076 |
1038 #define TYPED_ARRAY_GETTER(getter, accessor) \ | 1077 #define TYPED_ARRAY_GETTER(getter, accessor) \ |
1039 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \ | 1078 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \ |
1040 HandleScope scope(isolate); \ | 1079 HandleScope scope(isolate); \ |
1041 ASSERT(args.length() == 1); \ | 1080 ASSERT(args.length() == 1); \ |
1042 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \ | 1081 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \ |
1043 if (!holder->IsJSTypedArray()) \ | 1082 if (!holder->IsJSTypedArray()) \ |
1044 return isolate->Throw(*isolate->factory()->NewTypeError( \ | 1083 return isolate->Throw(*isolate->factory()->NewTypeError( \ |
1045 "not_typed_array", HandleVector<Object>(NULL, 0))); \ | 1084 "not_typed_array", HandleVector<Object>(NULL, 0))); \ |
1046 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \ | 1085 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \ |
1047 return typed_array->accessor(); \ | 1086 return typed_array->accessor(); \ |
1048 } | 1087 } |
1049 | 1088 |
1050 TYPED_ARRAY_GETTER(Buffer, buffer) | |
1051 TYPED_ARRAY_GETTER(ByteLength, byte_length) | 1089 TYPED_ARRAY_GETTER(ByteLength, byte_length) |
1052 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) | 1090 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) |
1053 TYPED_ARRAY_GETTER(Length, length) | 1091 TYPED_ARRAY_GETTER(Length, length) |
1054 | 1092 |
1055 #undef TYPED_ARRAY_GETTER | 1093 #undef TYPED_ARRAY_GETTER |
1056 | 1094 |
1095 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) { | |
1096 HandleScope scope(isolate); | |
1097 ASSERT(args.length() == 1); | |
1098 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); | |
1099 if (!holder->IsJSTypedArray()) | |
1100 return isolate->Throw(*isolate->factory()->NewTypeError( | |
1101 "not_typed_array", HandleVector<Object>(NULL, 0))); | |
1102 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); | |
1103 return *typed_array->GetBuffer(); | |
1104 } | |
1105 | |
1106 | |
1057 // Return codes for Runtime_TypedArraySetFastCases. | 1107 // Return codes for Runtime_TypedArraySetFastCases. |
1058 // Should be synchronized with typedarray.js natives. | 1108 // Should be synchronized with typedarray.js natives. |
1059 enum TypedArraySetResultCodes { | 1109 enum TypedArraySetResultCodes { |
1060 // Set from typed array of the same type. | 1110 // Set from typed array of the same type. |
1061 // This is processed by TypedArraySetFastCases | 1111 // This is processed by TypedArraySetFastCases |
1062 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 1112 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, |
1063 // Set from typed array of the different type, overlapping in memory. | 1113 // Set from typed array of the different type, overlapping in memory. |
1064 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, | 1114 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, |
1065 // Set from typed array of the different type, non-overlapping. | 1115 // Set from typed array of the different type, non-overlapping. |
1066 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 1116 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, |
(...skipping 25 matching lines...) Expand all Loading... | |
1092 if (offset > target_length || | 1142 if (offset > target_length || |
1093 offset + source_length > target_length || | 1143 offset + source_length > target_length || |
1094 offset + source_length < offset) // overflow | 1144 offset + source_length < offset) // overflow |
1095 return isolate->Throw(*isolate->factory()->NewRangeError( | 1145 return isolate->Throw(*isolate->factory()->NewRangeError( |
1096 "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); | 1146 "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); |
1097 | 1147 |
1098 size_t target_offset = NumberToSize(isolate, target->byte_offset()); | 1148 size_t target_offset = NumberToSize(isolate, target->byte_offset()); |
1099 size_t source_offset = NumberToSize(isolate, source->byte_offset()); | 1149 size_t source_offset = NumberToSize(isolate, source->byte_offset()); |
1100 uint8_t* target_base = | 1150 uint8_t* target_base = |
1101 static_cast<uint8_t*>( | 1151 static_cast<uint8_t*>( |
1102 JSArrayBuffer::cast(target->buffer())->backing_store()) + target_offset; | 1152 target->GetBuffer()->backing_store()) + target_offset; |
1103 uint8_t* source_base = | 1153 uint8_t* source_base = |
1104 static_cast<uint8_t*>( | 1154 static_cast<uint8_t*>( |
1105 JSArrayBuffer::cast(source->buffer())->backing_store()) + source_offset; | 1155 source->GetBuffer()->backing_store()) + source_offset; |
1106 | 1156 |
1107 // Typed arrays of the same type: use memmove. | 1157 // Typed arrays of the same type: use memmove. |
1108 if (target->type() == source->type()) { | 1158 if (target->type() == source->type()) { |
1109 memmove(target_base + offset * target->element_size(), | 1159 memmove(target_base + offset * target->element_size(), |
1110 source_base, source_byte_length); | 1160 source_base, source_byte_length); |
1111 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); | 1161 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); |
1112 } | 1162 } |
1113 | 1163 |
1114 // Typed arrays of different types over the same backing store | 1164 // Typed arrays of different types over the same backing store |
1115 if ((source_base <= target_base && | 1165 if ((source_base <= target_base && |
1116 source_base + source_byte_length > target_base) || | 1166 source_base + source_byte_length > target_base) || |
1117 (target_base <= source_base && | 1167 (target_base <= source_base && |
1118 target_base + target_byte_length > source_base)) { | 1168 target_base + target_byte_length > source_base)) { |
1119 // We do not support overlapping ArrayBuffers | 1169 // We do not support overlapping ArrayBuffers |
1120 ASSERT( | 1170 ASSERT( |
1121 JSArrayBuffer::cast(target->buffer())->backing_store() == | 1171 target->GetBuffer()->backing_store() == |
1122 JSArrayBuffer::cast(source->buffer())->backing_store()); | 1172 source->GetBuffer()->backing_store()); |
1123 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); | 1173 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); |
1124 } else { // Non-overlapping typed arrays | 1174 } else { // Non-overlapping typed arrays |
1125 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); | 1175 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); |
1126 } | 1176 } |
1127 } | 1177 } |
1128 | 1178 |
1129 | 1179 |
1180 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInHeapThreshold) { | |
1181 return Smi::FromInt(FLAG_typed_array_in_heap_threshold); | |
1182 } | |
1183 | |
1184 | |
1130 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { | 1185 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { |
1131 HandleScope scope(isolate); | 1186 HandleScope scope(isolate); |
1132 ASSERT(args.length() == 4); | 1187 ASSERT(args.length() == 4); |
1133 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 1188 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); |
1134 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 1189 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); |
1135 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); | 1190 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); |
1136 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); | 1191 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); |
1137 | 1192 |
1138 ASSERT(holder->GetInternalFieldCount() == | 1193 ASSERT(holder->GetInternalFieldCount() == |
1139 v8::ArrayBufferView::kInternalFieldCount); | 1194 v8::ArrayBufferView::kInternalFieldCount); |
(...skipping 13471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14611 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ | 14666 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ |
14612 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14667 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
14613 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ | 14668 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ |
14614 } | 14669 } |
14615 | 14670 |
14616 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14671 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
14617 | 14672 |
14618 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14673 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
14619 | 14674 |
14620 | 14675 |
14676 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \ | |
14677 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasFixed##Type##Elements) { \ | |
14678 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | |
14679 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ | |
14680 } | |
14681 | |
14682 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | |
14683 | |
14684 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | |
14685 | |
14686 | |
14621 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 14687 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { |
14622 SealHandleScope shs(isolate); | 14688 SealHandleScope shs(isolate); |
14623 ASSERT(args.length() == 2); | 14689 ASSERT(args.length() == 2); |
14624 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 14690 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
14625 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 14691 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
14626 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 14692 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
14627 } | 14693 } |
14628 | 14694 |
14629 | 14695 |
14630 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { | 14696 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14965 // Handle last resort GC and make sure to allow future allocations | 15031 // Handle last resort GC and make sure to allow future allocations |
14966 // to grow the heap without causing GCs (if possible). | 15032 // to grow the heap without causing GCs (if possible). |
14967 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15033 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14968 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15034 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14969 "Runtime::PerformGC"); | 15035 "Runtime::PerformGC"); |
14970 } | 15036 } |
14971 } | 15037 } |
14972 | 15038 |
14973 | 15039 |
14974 } } // namespace v8::internal | 15040 } } // namespace v8::internal |
OLD | NEW |