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

Side by Side Diff: src/runtime.cc

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