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

Side by Side Diff: src/runtime.cc

Issue 208503007: Revert "This implements allocating small typed arrays in heap." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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.h ('k') | src/typedarray.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 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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 void* backing_store = array_buffer->backing_store(); 919 void* backing_store = array_buffer->backing_store();
920 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); 920 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
921 array_buffer->set_is_external(true); 921 array_buffer->set_is_external(true);
922 Runtime::NeuterArrayBuffer(array_buffer); 922 Runtime::NeuterArrayBuffer(array_buffer);
923 V8::ArrayBufferAllocator()->Free(backing_store, byte_length); 923 V8::ArrayBufferAllocator()->Free(backing_store, byte_length);
924 return isolate->heap()->undefined_value(); 924 return isolate->heap()->undefined_value();
925 } 925 }
926 926
927 927
928 void Runtime::ArrayIdToTypeAndSize( 928 void Runtime::ArrayIdToTypeAndSize(
929 int arrayId, 929 int arrayId, ExternalArrayType* array_type, size_t* element_size) {
930 ExternalArrayType* array_type,
931 ElementsKind* external_elements_kind,
932 ElementsKind* fixed_elements_kind,
933 size_t* element_size) {
934 switch (arrayId) { 930 switch (arrayId) {
935 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \ 931 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \
936 case ARRAY_ID_##TYPE: \ 932 case ARRAY_ID_##TYPE: \
937 *array_type = kExternal##Type##Array; \ 933 *array_type = kExternal##Type##Array; \
938 *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS; \
939 *fixed_elements_kind = TYPE##_ELEMENTS; \
940 *element_size = size; \ 934 *element_size = size; \
941 break; 935 break;
942 936
943 TYPED_ARRAYS(ARRAY_ID_CASE) 937 TYPED_ARRAYS(ARRAY_ID_CASE)
944 #undef ARRAY_ID_CASE 938 #undef ARRAY_ID_CASE
945 939
946 default: 940 default:
947 UNREACHABLE(); 941 UNREACHABLE();
948 } 942 }
949 } 943 }
950 944
951 945
952 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { 946 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) {
953 HandleScope scope(isolate); 947 HandleScope scope(isolate);
954 ASSERT(args.length() == 5); 948 ASSERT(args.length() == 5);
955 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); 949 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0);
956 CONVERT_SMI_ARG_CHECKED(arrayId, 1); 950 CONVERT_SMI_ARG_CHECKED(arrayId, 1);
957 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); 951 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 2);
958 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3); 952 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3);
959 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); 953 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4);
960 954
961 ASSERT(holder->GetInternalFieldCount() == 955 ASSERT(holder->GetInternalFieldCount() ==
962 v8::ArrayBufferView::kInternalFieldCount); 956 v8::ArrayBufferView::kInternalFieldCount);
963 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 957 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
964 holder->SetInternalField(i, Smi::FromInt(0)); 958 holder->SetInternalField(i, Smi::FromInt(0));
965 } 959 }
966 960
967 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. 961 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
968 size_t element_size = 1; // Bogus initialization. 962 size_t element_size = 1; // Bogus initialization.
969 ElementsKind external_elements_kind = EXTERNAL_INT8_ELEMENTS; 963 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size);
970 ElementsKind fixed_elements_kind = INT8_ELEMENTS;
971 Runtime::ArrayIdToTypeAndSize(arrayId,
972 &array_type,
973 &external_elements_kind,
974 &fixed_elements_kind,
975 &element_size);
976 964
965 holder->set_buffer(*buffer);
977 holder->set_byte_offset(*byte_offset_object); 966 holder->set_byte_offset(*byte_offset_object);
978 holder->set_byte_length(*byte_length_object); 967 holder->set_byte_length(*byte_length_object);
979 968
980 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); 969 size_t byte_offset = NumberToSize(isolate, *byte_offset_object);
981 size_t byte_length = NumberToSize(isolate, *byte_length_object); 970 size_t byte_length = NumberToSize(isolate, *byte_length_object);
971 size_t array_buffer_byte_length =
972 NumberToSize(isolate, buffer->byte_length());
973 CHECK(byte_offset <= array_buffer_byte_length);
974 CHECK(array_buffer_byte_length - byte_offset >= byte_length);
982 975
983 CHECK_EQ(0, static_cast<int>(byte_length % element_size)); 976 CHECK_EQ(0, static_cast<int>(byte_length % element_size));
984 size_t length = byte_length / element_size; 977 size_t length = byte_length / element_size;
985 978
986 if (length > static_cast<unsigned>(Smi::kMaxValue)) { 979 if (length > static_cast<unsigned>(Smi::kMaxValue)) {
987 return isolate->Throw(*isolate->factory()-> 980 return isolate->Throw(*isolate->factory()->
988 NewRangeError("invalid_typed_array_length", 981 NewRangeError("invalid_typed_array_length",
989 HandleVector<Object>(NULL, 0))); 982 HandleVector<Object>(NULL, 0)));
990 } 983 }
991 984
992 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); 985 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
993 holder->set_length(*length_obj); 986 holder->set_length(*length_obj);
994 if (!maybe_buffer->IsNull()) { 987 holder->set_weak_next(buffer->weak_first_view());
995 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(*maybe_buffer)); 988 buffer->set_weak_first_view(*holder);
996 989
997 size_t array_buffer_byte_length = 990 Handle<ExternalArray> elements =
998 NumberToSize(isolate, buffer->byte_length()); 991 isolate->factory()->NewExternalArray(
999 CHECK(byte_offset <= array_buffer_byte_length); 992 static_cast<int>(length), array_type,
1000 CHECK(array_buffer_byte_length - byte_offset >= byte_length); 993 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
1001 994 holder->set_elements(*elements);
1002 holder->set_buffer(*buffer);
1003 holder->set_weak_next(buffer->weak_first_view());
1004 buffer->set_weak_first_view(*holder);
1005
1006 Handle<ExternalArray> elements =
1007 isolate->factory()->NewExternalArray(
1008 static_cast<int>(length), array_type,
1009 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
1010 Handle<Map> map =
1011 isolate->factory()->GetElementsTransitionMap(
1012 holder, external_elements_kind);
1013 holder->set_map_and_elements(*map, *elements);
1014 ASSERT(IsExternalArrayElementsKind(holder->map()->elements_kind()));
1015 } else {
1016 holder->set_buffer(Smi::FromInt(0));
1017 holder->set_weak_next(isolate->heap()->undefined_value());
1018 Handle<FixedTypedArrayBase> elements =
1019 isolate->factory()->NewFixedTypedArray(
1020 static_cast<int>(length), array_type);
1021 holder->set_elements(*elements);
1022 }
1023 return isolate->heap()->undefined_value(); 995 return isolate->heap()->undefined_value();
1024 } 996 }
1025 997
1026 998
1027 // Initializes a typed array from an array-like object. 999 // Initializes a typed array from an array-like object.
1028 // If an array-like object happens to be a typed array of the same type, 1000 // If an array-like object happens to be a typed array of the same type,
1029 // initializes backing store using memove. 1001 // initializes backing store using memove.
1030 // 1002 //
1031 // Returns true if backing store was initialized or false otherwise. 1003 // Returns true if backing store was initialized or false otherwise.
1032 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { 1004 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) {
1033 HandleScope scope(isolate); 1005 HandleScope scope(isolate);
1034 ASSERT(args.length() == 4); 1006 ASSERT(args.length() == 4);
1035 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); 1007 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0);
1036 CONVERT_SMI_ARG_CHECKED(arrayId, 1); 1008 CONVERT_SMI_ARG_CHECKED(arrayId, 1);
1037 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); 1009 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2);
1038 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); 1010 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3);
1039 1011
1040 ASSERT(holder->GetInternalFieldCount() == 1012 ASSERT(holder->GetInternalFieldCount() ==
1041 v8::ArrayBufferView::kInternalFieldCount); 1013 v8::ArrayBufferView::kInternalFieldCount);
1042 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 1014 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
1043 holder->SetInternalField(i, Smi::FromInt(0)); 1015 holder->SetInternalField(i, Smi::FromInt(0));
1044 } 1016 }
1045 1017
1046 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. 1018 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
1047 size_t element_size = 1; // Bogus initialization. 1019 size_t element_size = 1; // Bogus initialization.
1048 ElementsKind external_elements_kind; 1020 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size);
1049 ElementsKind fixed_elements_kind;
1050 Runtime::ArrayIdToTypeAndSize(arrayId,
1051 &array_type,
1052 &external_elements_kind,
1053 &fixed_elements_kind,
1054 &element_size);
1055 1021
1056 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); 1022 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
1057 if (source->IsJSTypedArray() && 1023 if (source->IsJSTypedArray() &&
1058 JSTypedArray::cast(*source)->type() == array_type) { 1024 JSTypedArray::cast(*source)->type() == array_type) {
1059 length_obj = Handle<Object>(JSTypedArray::cast(*source)->length(), isolate); 1025 length_obj = Handle<Object>(JSTypedArray::cast(*source)->length(), isolate);
1060 } 1026 }
1061 size_t length = NumberToSize(isolate, *length_obj); 1027 size_t length = NumberToSize(isolate, *length_obj);
1062 1028
1063 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || 1029 if ((length > static_cast<unsigned>(Smi::kMaxValue)) ||
1064 (length > (kMaxInt / element_size))) { 1030 (length > (kMaxInt / element_size))) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 isolate->factory()->NewNumberFromSize(byte_length)); 1063 isolate->factory()->NewNumberFromSize(byte_length));
1098 holder->set_byte_length(*byte_length_obj); 1064 holder->set_byte_length(*byte_length_obj);
1099 holder->set_length(*length_obj); 1065 holder->set_length(*length_obj);
1100 holder->set_weak_next(buffer->weak_first_view()); 1066 holder->set_weak_next(buffer->weak_first_view());
1101 buffer->set_weak_first_view(*holder); 1067 buffer->set_weak_first_view(*holder);
1102 1068
1103 Handle<ExternalArray> elements = 1069 Handle<ExternalArray> elements =
1104 isolate->factory()->NewExternalArray( 1070 isolate->factory()->NewExternalArray(
1105 static_cast<int>(length), array_type, 1071 static_cast<int>(length), array_type,
1106 static_cast<uint8_t*>(buffer->backing_store())); 1072 static_cast<uint8_t*>(buffer->backing_store()));
1107 Handle<Map> map = 1073 holder->set_elements(*elements);
1108 isolate->factory()->GetElementsTransitionMap(
1109 holder, external_elements_kind);
1110 holder->set_map_and_elements(*map, *elements);
1111 1074
1112 if (source->IsJSTypedArray()) { 1075 if (source->IsJSTypedArray()) {
1113 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); 1076 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source));
1114 1077
1115 if (typed_array->type() == holder->type()) { 1078 if (typed_array->type() == holder->type()) {
1116 uint8_t* backing_store = 1079 uint8_t* backing_store =
1117 static_cast<uint8_t*>( 1080 static_cast<uint8_t*>(
1118 typed_array->GetBuffer()->backing_store()); 1081 JSArrayBuffer::cast(typed_array->buffer())->backing_store());
1119 size_t source_byte_offset = 1082 size_t source_byte_offset =
1120 NumberToSize(isolate, typed_array->byte_offset()); 1083 NumberToSize(isolate, typed_array->byte_offset());
1121 memcpy( 1084 memcpy(
1122 buffer->backing_store(), 1085 buffer->backing_store(),
1123 backing_store + source_byte_offset, 1086 backing_store + source_byte_offset,
1124 byte_length); 1087 byte_length);
1125 return *isolate->factory()->true_value(); 1088 return *isolate->factory()->true_value();
1126 } else { 1089 } else {
1127 return *isolate->factory()->false_value(); 1090 return *isolate->factory()->false_value();
1128 } 1091 }
1129 } 1092 }
1130 1093
1131 return *isolate->factory()->false_value(); 1094 return *isolate->factory()->false_value();
1132 } 1095 }
1133 1096
1134 1097
1135 #define TYPED_ARRAY_GETTER(getter, accessor) \ 1098 #define TYPED_ARRAY_GETTER(getter, accessor) \
1136 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \ 1099 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \
1137 HandleScope scope(isolate); \ 1100 HandleScope scope(isolate); \
1138 ASSERT(args.length() == 1); \ 1101 ASSERT(args.length() == 1); \
1139 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \ 1102 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \
1140 if (!holder->IsJSTypedArray()) \ 1103 if (!holder->IsJSTypedArray()) \
1141 return isolate->Throw(*isolate->factory()->NewTypeError( \ 1104 return isolate->Throw(*isolate->factory()->NewTypeError( \
1142 "not_typed_array", HandleVector<Object>(NULL, 0))); \ 1105 "not_typed_array", HandleVector<Object>(NULL, 0))); \
1143 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \ 1106 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \
1144 return typed_array->accessor(); \ 1107 return typed_array->accessor(); \
1145 } 1108 }
1146 1109
1110 TYPED_ARRAY_GETTER(Buffer, buffer)
1147 TYPED_ARRAY_GETTER(ByteLength, byte_length) 1111 TYPED_ARRAY_GETTER(ByteLength, byte_length)
1148 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) 1112 TYPED_ARRAY_GETTER(ByteOffset, byte_offset)
1149 TYPED_ARRAY_GETTER(Length, length) 1113 TYPED_ARRAY_GETTER(Length, length)
1150 1114
1151 #undef TYPED_ARRAY_GETTER 1115 #undef TYPED_ARRAY_GETTER
1152 1116
1153 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) {
1154 HandleScope scope(isolate);
1155 ASSERT(args.length() == 1);
1156 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0);
1157 if (!holder->IsJSTypedArray())
1158 return isolate->Throw(*isolate->factory()->NewTypeError(
1159 "not_typed_array", HandleVector<Object>(NULL, 0)));
1160 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder));
1161 return *typed_array->GetBuffer();
1162 }
1163
1164
1165 // Return codes for Runtime_TypedArraySetFastCases. 1117 // Return codes for Runtime_TypedArraySetFastCases.
1166 // Should be synchronized with typedarray.js natives. 1118 // Should be synchronized with typedarray.js natives.
1167 enum TypedArraySetResultCodes { 1119 enum TypedArraySetResultCodes {
1168 // Set from typed array of the same type. 1120 // Set from typed array of the same type.
1169 // This is processed by TypedArraySetFastCases 1121 // This is processed by TypedArraySetFastCases
1170 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, 1122 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0,
1171 // Set from typed array of the different type, overlapping in memory. 1123 // Set from typed array of the different type, overlapping in memory.
1172 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, 1124 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1,
1173 // Set from typed array of the different type, non-overlapping. 1125 // Set from typed array of the different type, non-overlapping.
1174 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, 1126 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2,
(...skipping 25 matching lines...) Expand all
1200 if (offset > target_length || 1152 if (offset > target_length ||
1201 offset + source_length > target_length || 1153 offset + source_length > target_length ||
1202 offset + source_length < offset) // overflow 1154 offset + source_length < offset) // overflow
1203 return isolate->Throw(*isolate->factory()->NewRangeError( 1155 return isolate->Throw(*isolate->factory()->NewRangeError(
1204 "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); 1156 "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0)));
1205 1157
1206 size_t target_offset = NumberToSize(isolate, target->byte_offset()); 1158 size_t target_offset = NumberToSize(isolate, target->byte_offset());
1207 size_t source_offset = NumberToSize(isolate, source->byte_offset()); 1159 size_t source_offset = NumberToSize(isolate, source->byte_offset());
1208 uint8_t* target_base = 1160 uint8_t* target_base =
1209 static_cast<uint8_t*>( 1161 static_cast<uint8_t*>(
1210 target->GetBuffer()->backing_store()) + target_offset; 1162 JSArrayBuffer::cast(target->buffer())->backing_store()) + target_offset;
1211 uint8_t* source_base = 1163 uint8_t* source_base =
1212 static_cast<uint8_t*>( 1164 static_cast<uint8_t*>(
1213 source->GetBuffer()->backing_store()) + source_offset; 1165 JSArrayBuffer::cast(source->buffer())->backing_store()) + source_offset;
1214 1166
1215 // Typed arrays of the same type: use memmove. 1167 // Typed arrays of the same type: use memmove.
1216 if (target->type() == source->type()) { 1168 if (target->type() == source->type()) {
1217 memmove(target_base + offset * target->element_size(), 1169 memmove(target_base + offset * target->element_size(),
1218 source_base, source_byte_length); 1170 source_base, source_byte_length);
1219 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); 1171 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE);
1220 } 1172 }
1221 1173
1222 // Typed arrays of different types over the same backing store 1174 // Typed arrays of different types over the same backing store
1223 if ((source_base <= target_base && 1175 if ((source_base <= target_base &&
1224 source_base + source_byte_length > target_base) || 1176 source_base + source_byte_length > target_base) ||
1225 (target_base <= source_base && 1177 (target_base <= source_base &&
1226 target_base + target_byte_length > source_base)) { 1178 target_base + target_byte_length > source_base)) {
1227 // We do not support overlapping ArrayBuffers 1179 // We do not support overlapping ArrayBuffers
1228 ASSERT( 1180 ASSERT(
1229 target->GetBuffer()->backing_store() == 1181 JSArrayBuffer::cast(target->buffer())->backing_store() ==
1230 source->GetBuffer()->backing_store()); 1182 JSArrayBuffer::cast(source->buffer())->backing_store());
1231 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); 1183 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING);
1232 } else { // Non-overlapping typed arrays 1184 } else { // Non-overlapping typed arrays
1233 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); 1185 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING);
1234 } 1186 }
1235 } 1187 }
1236 1188
1237 1189
1238 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayMaxSizeInHeap) {
1239 ASSERT_OBJECT_SIZE(FLAG_typed_array_max_size_in_heap);
1240 return Smi::FromInt(FLAG_typed_array_max_size_in_heap);
1241 }
1242
1243
1244 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { 1190 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) {
1245 HandleScope scope(isolate); 1191 HandleScope scope(isolate);
1246 ASSERT(args.length() == 4); 1192 ASSERT(args.length() == 4);
1247 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); 1193 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0);
1248 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); 1194 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1);
1249 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); 1195 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2);
1250 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); 1196 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3);
1251 1197
1252 ASSERT(holder->GetInternalFieldCount() == 1198 ASSERT(holder->GetInternalFieldCount() ==
1253 v8::ArrayBufferView::kInternalFieldCount); 1199 v8::ArrayBufferView::kInternalFieldCount);
(...skipping 13531 matching lines...) Expand 10 before | Expand all | Expand 10 after
14785 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ 14731 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \
14786 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ 14732 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
14787 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ 14733 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \
14788 } 14734 }
14789 14735
14790 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) 14736 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION)
14791 14737
14792 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION 14738 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
14793 14739
14794 14740
14795 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \
14796 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasFixed##Type##Elements) { \
14797 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
14798 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \
14799 }
14800
14801 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION)
14802
14803 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
14804
14805
14806 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { 14741 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) {
14807 SealHandleScope shs(isolate); 14742 SealHandleScope shs(isolate);
14808 ASSERT(args.length() == 2); 14743 ASSERT(args.length() == 2);
14809 CONVERT_ARG_CHECKED(JSObject, obj1, 0); 14744 CONVERT_ARG_CHECKED(JSObject, obj1, 0);
14810 CONVERT_ARG_CHECKED(JSObject, obj2, 1); 14745 CONVERT_ARG_CHECKED(JSObject, obj2, 1);
14811 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); 14746 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
14812 } 14747 }
14813 14748
14814 14749
14815 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { 14750 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
15169 // Handle last resort GC and make sure to allow future allocations 15104 // Handle last resort GC and make sure to allow future allocations
15170 // to grow the heap without causing GCs (if possible). 15105 // to grow the heap without causing GCs (if possible).
15171 isolate->counters()->gc_last_resort_from_js()->Increment(); 15106 isolate->counters()->gc_last_resort_from_js()->Increment();
15172 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 15107 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
15173 "Runtime::PerformGC"); 15108 "Runtime::PerformGC");
15174 } 15109 }
15175 } 15110 }
15176 15111
15177 15112
15178 } } // namespace v8::internal 15113 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698