| 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 885 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 896   void* backing_store = array_buffer->backing_store(); | 896   void* backing_store = array_buffer->backing_store(); | 
| 897   size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); | 897   size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); | 
| 898   array_buffer->set_is_external(true); | 898   array_buffer->set_is_external(true); | 
| 899   Runtime::NeuterArrayBuffer(array_buffer); | 899   Runtime::NeuterArrayBuffer(array_buffer); | 
| 900   V8::ArrayBufferAllocator()->Free(backing_store, byte_length); | 900   V8::ArrayBufferAllocator()->Free(backing_store, byte_length); | 
| 901   return isolate->heap()->undefined_value(); | 901   return isolate->heap()->undefined_value(); | 
| 902 } | 902 } | 
| 903 | 903 | 
| 904 | 904 | 
| 905 void Runtime::ArrayIdToTypeAndSize( | 905 void Runtime::ArrayIdToTypeAndSize( | 
| 906     int arrayId, ExternalArrayType* array_type, size_t* element_size) { | 906     int arrayId, | 
|  | 907     ExternalArrayType* array_type, | 
|  | 908     ElementsKind* external_elements_kind, | 
|  | 909     ElementsKind* fixed_elements_kind, | 
|  | 910     size_t* element_size) { | 
| 907   switch (arrayId) { | 911   switch (arrayId) { | 
| 908 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size)                           \ | 912 #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size)                           \ | 
| 909     case ARRAY_ID_##TYPE:                                                      \ | 913     case ARRAY_ID_##TYPE:                                                      \ | 
| 910       *array_type = kExternal##Type##Array;                                    \ | 914       *array_type = kExternal##Type##Array;                                    \ | 
|  | 915       *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS;                    \ | 
|  | 916       *fixed_elements_kind = TYPE##_ELEMENTS;                                  \ | 
| 911       *element_size = size;                                                    \ | 917       *element_size = size;                                                    \ | 
| 912       break; | 918       break; | 
| 913 | 919 | 
| 914     TYPED_ARRAYS(ARRAY_ID_CASE) | 920     TYPED_ARRAYS(ARRAY_ID_CASE) | 
| 915 #undef ARRAY_ID_CASE | 921 #undef ARRAY_ID_CASE | 
| 916 | 922 | 
| 917     default: | 923     default: | 
| 918       UNREACHABLE(); | 924       UNREACHABLE(); | 
| 919   } | 925   } | 
| 920 } | 926 } | 
| 921 | 927 | 
| 922 | 928 | 
| 923 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { | 929 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { | 
| 924   HandleScope scope(isolate); | 930   HandleScope scope(isolate); | 
| 925   ASSERT(args.length() == 5); | 931   ASSERT(args.length() == 5); | 
| 926   CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 932   CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 
| 927   CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 933   CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 
| 928   CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 2); | 934   CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); | 
| 929   CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3); | 935   CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3); | 
| 930   CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); | 936   CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); | 
| 931 | 937 | 
| 932   ASSERT(holder->GetInternalFieldCount() == | 938   ASSERT(holder->GetInternalFieldCount() == | 
| 933       v8::ArrayBufferView::kInternalFieldCount); | 939       v8::ArrayBufferView::kInternalFieldCount); | 
| 934   for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 940   for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 
| 935     holder->SetInternalField(i, Smi::FromInt(0)); | 941     holder->SetInternalField(i, Smi::FromInt(0)); | 
| 936   } | 942   } | 
| 937 | 943 | 
| 938   ExternalArrayType array_type = kExternalInt8Array;  // Bogus initialization. | 944   ExternalArrayType array_type = kExternalInt8Array;  // Bogus initialization. | 
| 939   size_t element_size = 1;  // Bogus initialization. | 945   size_t element_size = 1;  // Bogus initialization. | 
| 940   Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 946   ElementsKind external_elements_kind = EXTERNAL_INT8_ELEMENTS; | 
|  | 947   ElementsKind fixed_elements_kind = INT8_ELEMENTS; | 
|  | 948   Runtime::ArrayIdToTypeAndSize(arrayId, | 
|  | 949       &array_type, | 
|  | 950       &external_elements_kind, | 
|  | 951       &fixed_elements_kind, | 
|  | 952       &element_size); | 
| 941 | 953 | 
| 942   holder->set_buffer(*buffer); |  | 
| 943   holder->set_byte_offset(*byte_offset_object); | 954   holder->set_byte_offset(*byte_offset_object); | 
| 944   holder->set_byte_length(*byte_length_object); | 955   holder->set_byte_length(*byte_length_object); | 
| 945 | 956 | 
| 946   size_t byte_offset = NumberToSize(isolate, *byte_offset_object); | 957   size_t byte_offset = NumberToSize(isolate, *byte_offset_object); | 
| 947   size_t byte_length = NumberToSize(isolate, *byte_length_object); | 958   size_t byte_length = NumberToSize(isolate, *byte_length_object); | 
| 948   size_t array_buffer_byte_length = |  | 
| 949       NumberToSize(isolate, buffer->byte_length()); |  | 
| 950   CHECK(byte_offset <= array_buffer_byte_length); |  | 
| 951   CHECK(array_buffer_byte_length - byte_offset >= byte_length); |  | 
| 952 | 959 | 
| 953   CHECK_EQ(0, static_cast<int>(byte_length % element_size)); | 960   CHECK_EQ(0, static_cast<int>(byte_length % element_size)); | 
| 954   size_t length = byte_length / element_size; | 961   size_t length = byte_length / element_size; | 
| 955 | 962 | 
| 956   if (length > static_cast<unsigned>(Smi::kMaxValue)) { | 963   if (length > static_cast<unsigned>(Smi::kMaxValue)) { | 
| 957     return isolate->Throw(*isolate->factory()-> | 964     return isolate->Throw(*isolate->factory()-> | 
| 958           NewRangeError("invalid_typed_array_length", | 965           NewRangeError("invalid_typed_array_length", | 
| 959             HandleVector<Object>(NULL, 0))); | 966             HandleVector<Object>(NULL, 0))); | 
| 960   } | 967   } | 
| 961 | 968 | 
| 962   Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); | 969   Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); | 
| 963   holder->set_length(*length_obj); | 970   holder->set_length(*length_obj); | 
| 964   holder->set_weak_next(buffer->weak_first_view()); | 971   if (!maybe_buffer->IsNull()) { | 
| 965   buffer->set_weak_first_view(*holder); | 972     Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(*maybe_buffer)); | 
| 966 | 973 | 
| 967   Handle<ExternalArray> elements = | 974     size_t array_buffer_byte_length = | 
| 968       isolate->factory()->NewExternalArray( | 975         NumberToSize(isolate, buffer->byte_length()); | 
| 969           static_cast<int>(length), array_type, | 976     CHECK(byte_offset <= array_buffer_byte_length); | 
| 970           static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 977     CHECK(array_buffer_byte_length - byte_offset >= byte_length); | 
| 971   holder->set_elements(*elements); | 978 | 
|  | 979     holder->set_buffer(*buffer); | 
|  | 980     holder->set_weak_next(buffer->weak_first_view()); | 
|  | 981     buffer->set_weak_first_view(*holder); | 
|  | 982 | 
|  | 983     Handle<ExternalArray> elements = | 
|  | 984         isolate->factory()->NewExternalArray( | 
|  | 985             static_cast<int>(length), array_type, | 
|  | 986             static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 
|  | 987     Handle<Map> map = | 
|  | 988         isolate->factory()->GetElementsTransitionMap( | 
|  | 989             holder, external_elements_kind); | 
|  | 990     holder->set_map_and_elements(*map, *elements); | 
|  | 991     ASSERT(IsExternalArrayElementsKind(holder->map()->elements_kind())); | 
|  | 992   } else { | 
|  | 993     holder->set_buffer(Smi::FromInt(0)); | 
|  | 994     holder->set_weak_next(isolate->heap()->undefined_value()); | 
|  | 995     Handle<FixedTypedArrayBase> elements = | 
|  | 996         isolate->factory()->NewFixedTypedArray( | 
|  | 997             static_cast<int>(length), array_type); | 
|  | 998     holder->set_elements(*elements); | 
|  | 999   } | 
| 972   return isolate->heap()->undefined_value(); | 1000   return isolate->heap()->undefined_value(); | 
| 973 } | 1001 } | 
| 974 | 1002 | 
| 975 | 1003 | 
| 976 // Initializes a typed array from an array-like object. | 1004 // Initializes a typed array from an array-like object. | 
| 977 // If an array-like object happens to be a typed array of the same type, | 1005 // If an array-like object happens to be a typed array of the same type, | 
| 978 // initializes backing store using memove. | 1006 // initializes backing store using memove. | 
| 979 // | 1007 // | 
| 980 // Returns true if backing store was initialized or false otherwise. | 1008 // Returns true if backing store was initialized or false otherwise. | 
| 981 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { | 1009 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { | 
| 982   HandleScope scope(isolate); | 1010   HandleScope scope(isolate); | 
| 983   ASSERT(args.length() == 4); | 1011   ASSERT(args.length() == 4); | 
| 984   CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 1012   CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 
| 985   CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 1013   CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 
| 986   CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); | 1014   CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); | 
| 987   CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); | 1015   CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); | 
| 988 | 1016 | 
| 989   ASSERT(holder->GetInternalFieldCount() == | 1017   ASSERT(holder->GetInternalFieldCount() == | 
| 990       v8::ArrayBufferView::kInternalFieldCount); | 1018       v8::ArrayBufferView::kInternalFieldCount); | 
| 991   for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1019   for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 
| 992     holder->SetInternalField(i, Smi::FromInt(0)); | 1020     holder->SetInternalField(i, Smi::FromInt(0)); | 
| 993   } | 1021   } | 
| 994 | 1022 | 
| 995   ExternalArrayType array_type = kExternalInt8Array;  // Bogus initialization. | 1023   ExternalArrayType array_type = kExternalInt8Array;  // Bogus initialization. | 
| 996   size_t element_size = 1;  // Bogus initialization. | 1024   size_t element_size = 1;  // Bogus initialization. | 
| 997   Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); | 1025   ElementsKind external_elements_kind; | 
|  | 1026   ElementsKind fixed_elements_kind; | 
|  | 1027   Runtime::ArrayIdToTypeAndSize(arrayId, | 
|  | 1028       &array_type, | 
|  | 1029       &external_elements_kind, | 
|  | 1030       &fixed_elements_kind, | 
|  | 1031       &element_size); | 
| 998 | 1032 | 
| 999   Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 1033   Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 
| 1000   if (source->IsJSTypedArray() && | 1034   if (source->IsJSTypedArray() && | 
| 1001       JSTypedArray::cast(*source)->type() == array_type) { | 1035       JSTypedArray::cast(*source)->type() == array_type) { | 
| 1002     length_obj = Handle<Object>(JSTypedArray::cast(*source)->length(), isolate); | 1036     length_obj = Handle<Object>(JSTypedArray::cast(*source)->length(), isolate); | 
| 1003   } | 1037   } | 
| 1004   size_t length = NumberToSize(isolate, *length_obj); | 1038   size_t length = NumberToSize(isolate, *length_obj); | 
| 1005 | 1039 | 
| 1006   if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 1040   if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 
| 1007       (length > (kMaxInt / element_size))) { | 1041       (length > (kMaxInt / element_size))) { | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1040       isolate->factory()->NewNumberFromSize(byte_length)); | 1074       isolate->factory()->NewNumberFromSize(byte_length)); | 
| 1041   holder->set_byte_length(*byte_length_obj); | 1075   holder->set_byte_length(*byte_length_obj); | 
| 1042   holder->set_length(*length_obj); | 1076   holder->set_length(*length_obj); | 
| 1043   holder->set_weak_next(buffer->weak_first_view()); | 1077   holder->set_weak_next(buffer->weak_first_view()); | 
| 1044   buffer->set_weak_first_view(*holder); | 1078   buffer->set_weak_first_view(*holder); | 
| 1045 | 1079 | 
| 1046   Handle<ExternalArray> elements = | 1080   Handle<ExternalArray> elements = | 
| 1047       isolate->factory()->NewExternalArray( | 1081       isolate->factory()->NewExternalArray( | 
| 1048           static_cast<int>(length), array_type, | 1082           static_cast<int>(length), array_type, | 
| 1049           static_cast<uint8_t*>(buffer->backing_store())); | 1083           static_cast<uint8_t*>(buffer->backing_store())); | 
| 1050   holder->set_elements(*elements); | 1084   Handle<Map> map = | 
|  | 1085       isolate->factory()->GetElementsTransitionMap( | 
|  | 1086           holder, external_elements_kind); | 
|  | 1087   holder->set_map_and_elements(*map, *elements); | 
| 1051 | 1088 | 
| 1052   if (source->IsJSTypedArray()) { | 1089   if (source->IsJSTypedArray()) { | 
| 1053     Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); | 1090     Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); | 
| 1054 | 1091 | 
| 1055     if (typed_array->type() == holder->type()) { | 1092     if (typed_array->type() == holder->type()) { | 
| 1056       uint8_t* backing_store = | 1093       uint8_t* backing_store = | 
| 1057         static_cast<uint8_t*>( | 1094         static_cast<uint8_t*>( | 
| 1058           JSArrayBuffer::cast(typed_array->buffer())->backing_store()); | 1095           typed_array->GetBuffer()->backing_store()); | 
| 1059       size_t source_byte_offset = | 1096       size_t source_byte_offset = | 
| 1060           NumberToSize(isolate, typed_array->byte_offset()); | 1097           NumberToSize(isolate, typed_array->byte_offset()); | 
| 1061       memcpy( | 1098       memcpy( | 
| 1062           buffer->backing_store(), | 1099           buffer->backing_store(), | 
| 1063           backing_store + source_byte_offset, | 1100           backing_store + source_byte_offset, | 
| 1064           byte_length); | 1101           byte_length); | 
| 1065       return *isolate->factory()->true_value(); | 1102       return *isolate->factory()->true_value(); | 
| 1066     } else { | 1103     } else { | 
| 1067       return *isolate->factory()->false_value(); | 1104       return *isolate->factory()->false_value(); | 
| 1068     } | 1105     } | 
| 1069   } | 1106   } | 
| 1070 | 1107 | 
| 1071   return *isolate->factory()->false_value(); | 1108   return *isolate->factory()->false_value(); | 
| 1072 } | 1109 } | 
| 1073 | 1110 | 
| 1074 | 1111 | 
| 1075 #define TYPED_ARRAY_GETTER(getter, accessor) \ | 1112 #define TYPED_ARRAY_GETTER(getter, accessor) \ | 
| 1076   RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) {             \ | 1113   RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) {             \ | 
| 1077     HandleScope scope(isolate);                                               \ | 1114     HandleScope scope(isolate);                                               \ | 
| 1078     ASSERT(args.length() == 1);                                               \ | 1115     ASSERT(args.length() == 1);                                               \ | 
| 1079     CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0);                            \ | 1116     CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0);                            \ | 
| 1080     if (!holder->IsJSTypedArray())                                            \ | 1117     if (!holder->IsJSTypedArray())                                            \ | 
| 1081       return isolate->Throw(*isolate->factory()->NewTypeError(                \ | 1118       return isolate->Throw(*isolate->factory()->NewTypeError(                \ | 
| 1082           "not_typed_array", HandleVector<Object>(NULL, 0)));                 \ | 1119           "not_typed_array", HandleVector<Object>(NULL, 0)));                 \ | 
| 1083     Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder));            \ | 1120     Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder));            \ | 
| 1084     return typed_array->accessor();                                           \ | 1121     return typed_array->accessor();                                           \ | 
| 1085   } | 1122   } | 
| 1086 | 1123 | 
| 1087 TYPED_ARRAY_GETTER(Buffer, buffer) |  | 
| 1088 TYPED_ARRAY_GETTER(ByteLength, byte_length) | 1124 TYPED_ARRAY_GETTER(ByteLength, byte_length) | 
| 1089 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) | 1125 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) | 
| 1090 TYPED_ARRAY_GETTER(Length, length) | 1126 TYPED_ARRAY_GETTER(Length, length) | 
| 1091 | 1127 | 
| 1092 #undef TYPED_ARRAY_GETTER | 1128 #undef TYPED_ARRAY_GETTER | 
| 1093 | 1129 | 
|  | 1130 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) { | 
|  | 1131   HandleScope scope(isolate); | 
|  | 1132   ASSERT(args.length() == 1); | 
|  | 1133   CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); | 
|  | 1134   if (!holder->IsJSTypedArray()) | 
|  | 1135     return isolate->Throw(*isolate->factory()->NewTypeError( | 
|  | 1136         "not_typed_array", HandleVector<Object>(NULL, 0))); | 
|  | 1137   Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); | 
|  | 1138   return *typed_array->GetBuffer(); | 
|  | 1139 } | 
|  | 1140 | 
|  | 1141 | 
| 1094 // Return codes for Runtime_TypedArraySetFastCases. | 1142 // Return codes for Runtime_TypedArraySetFastCases. | 
| 1095 // Should be synchronized with typedarray.js natives. | 1143 // Should be synchronized with typedarray.js natives. | 
| 1096 enum TypedArraySetResultCodes { | 1144 enum TypedArraySetResultCodes { | 
| 1097   // Set from typed array of the same type. | 1145   // Set from typed array of the same type. | 
| 1098   // This is processed by TypedArraySetFastCases | 1146   // This is processed by TypedArraySetFastCases | 
| 1099   TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 1147   TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 
| 1100   // Set from typed array of the different type, overlapping in memory. | 1148   // Set from typed array of the different type, overlapping in memory. | 
| 1101   TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, | 1149   TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, | 
| 1102   // Set from typed array of the different type, non-overlapping. | 1150   // Set from typed array of the different type, non-overlapping. | 
| 1103   TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 1151   TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 1129   if (offset > target_length || | 1177   if (offset > target_length || | 
| 1130       offset + source_length > target_length || | 1178       offset + source_length > target_length || | 
| 1131       offset + source_length < offset)  // overflow | 1179       offset + source_length < offset)  // overflow | 
| 1132     return isolate->Throw(*isolate->factory()->NewRangeError( | 1180     return isolate->Throw(*isolate->factory()->NewRangeError( | 
| 1133           "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); | 1181           "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); | 
| 1134 | 1182 | 
| 1135   size_t target_offset = NumberToSize(isolate, target->byte_offset()); | 1183   size_t target_offset = NumberToSize(isolate, target->byte_offset()); | 
| 1136   size_t source_offset = NumberToSize(isolate, source->byte_offset()); | 1184   size_t source_offset = NumberToSize(isolate, source->byte_offset()); | 
| 1137   uint8_t* target_base = | 1185   uint8_t* target_base = | 
| 1138       static_cast<uint8_t*>( | 1186       static_cast<uint8_t*>( | 
| 1139         JSArrayBuffer::cast(target->buffer())->backing_store()) + target_offset; | 1187         target->GetBuffer()->backing_store()) + target_offset; | 
| 1140   uint8_t* source_base = | 1188   uint8_t* source_base = | 
| 1141       static_cast<uint8_t*>( | 1189       static_cast<uint8_t*>( | 
| 1142         JSArrayBuffer::cast(source->buffer())->backing_store()) + source_offset; | 1190         source->GetBuffer()->backing_store()) + source_offset; | 
| 1143 | 1191 | 
| 1144   // Typed arrays of the same type: use memmove. | 1192   // Typed arrays of the same type: use memmove. | 
| 1145   if (target->type() == source->type()) { | 1193   if (target->type() == source->type()) { | 
| 1146     memmove(target_base + offset * target->element_size(), | 1194     memmove(target_base + offset * target->element_size(), | 
| 1147         source_base, source_byte_length); | 1195         source_base, source_byte_length); | 
| 1148     return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); | 1196     return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); | 
| 1149   } | 1197   } | 
| 1150 | 1198 | 
| 1151   // Typed arrays of different types over the same backing store | 1199   // Typed arrays of different types over the same backing store | 
| 1152   if ((source_base <= target_base && | 1200   if ((source_base <= target_base && | 
| 1153         source_base + source_byte_length > target_base) || | 1201         source_base + source_byte_length > target_base) || | 
| 1154       (target_base <= source_base && | 1202       (target_base <= source_base && | 
| 1155         target_base + target_byte_length > source_base)) { | 1203         target_base + target_byte_length > source_base)) { | 
| 1156     // We do not support overlapping ArrayBuffers | 1204     // We do not support overlapping ArrayBuffers | 
| 1157     ASSERT( | 1205     ASSERT( | 
| 1158       JSArrayBuffer::cast(target->buffer())->backing_store() == | 1206       target->GetBuffer()->backing_store() == | 
| 1159       JSArrayBuffer::cast(source->buffer())->backing_store()); | 1207       source->GetBuffer()->backing_store()); | 
| 1160     return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); | 1208     return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); | 
| 1161   } else {  // Non-overlapping typed arrays | 1209   } else {  // Non-overlapping typed arrays | 
| 1162     return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); | 1210     return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); | 
| 1163   } | 1211   } | 
| 1164 } | 1212 } | 
| 1165 | 1213 | 
| 1166 | 1214 | 
|  | 1215 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayMaxSizeInHeap) { | 
|  | 1216   ASSERT_OBJECT_SIZE(FLAG_typed_array_max_size_in_heap); | 
|  | 1217   return Smi::FromInt(FLAG_typed_array_max_size_in_heap); | 
|  | 1218 } | 
|  | 1219 | 
|  | 1220 | 
| 1167 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { | 1221 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { | 
| 1168   HandleScope scope(isolate); | 1222   HandleScope scope(isolate); | 
| 1169   ASSERT(args.length() == 4); | 1223   ASSERT(args.length() == 4); | 
| 1170   CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 1224   CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 
| 1171   CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 1225   CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 
| 1172   CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); | 1226   CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); | 
| 1173   CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); | 1227   CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); | 
| 1174 | 1228 | 
| 1175   ASSERT(holder->GetInternalFieldCount() == | 1229   ASSERT(holder->GetInternalFieldCount() == | 
| 1176       v8::ArrayBufferView::kInternalFieldCount); | 1230       v8::ArrayBufferView::kInternalFieldCount); | 
| (...skipping 13510 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14687   RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) {        \ | 14741   RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) {        \ | 
| 14688     CONVERT_ARG_CHECKED(JSObject, obj, 0);                                     \ | 14742     CONVERT_ARG_CHECKED(JSObject, obj, 0);                                     \ | 
| 14689     return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements());     \ | 14743     return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements());     \ | 
| 14690   } | 14744   } | 
| 14691 | 14745 | 
| 14692 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14746 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 
| 14693 | 14747 | 
| 14694 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14748 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 
| 14695 | 14749 | 
| 14696 | 14750 | 
|  | 14751 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s)  \ | 
|  | 14752   RUNTIME_FUNCTION(MaybeObject*, Runtime_HasFixed##Type##Elements) {           \ | 
|  | 14753     CONVERT_ARG_CHECKED(JSObject, obj, 0);                                     \ | 
|  | 14754     return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements());        \ | 
|  | 14755   } | 
|  | 14756 | 
|  | 14757 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 
|  | 14758 | 
|  | 14759 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 
|  | 14760 | 
|  | 14761 | 
| 14697 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 14762 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 
| 14698   SealHandleScope shs(isolate); | 14763   SealHandleScope shs(isolate); | 
| 14699   ASSERT(args.length() == 2); | 14764   ASSERT(args.length() == 2); | 
| 14700   CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 14765   CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 
| 14701   CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 14766   CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 
| 14702   return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 14767   return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 
| 14703 } | 14768 } | 
| 14704 | 14769 | 
| 14705 | 14770 | 
| 14706 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { | 14771 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { | 
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 15060     // Handle last resort GC and make sure to allow future allocations | 15125     // Handle last resort GC and make sure to allow future allocations | 
| 15061     // to grow the heap without causing GCs (if possible). | 15126     // to grow the heap without causing GCs (if possible). | 
| 15062     isolate->counters()->gc_last_resort_from_js()->Increment(); | 15127     isolate->counters()->gc_last_resort_from_js()->Increment(); | 
| 15063     isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15128     isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 
| 15064                                        "Runtime::PerformGC"); | 15129                                        "Runtime::PerformGC"); | 
| 15065   } | 15130   } | 
| 15066 } | 15131 } | 
| 15067 | 15132 | 
| 15068 | 15133 | 
| 15069 } }  // namespace v8::internal | 15134 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|