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 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 return *isolate->factory()->true_value(); | 1125 return *isolate->factory()->true_value(); |
1126 } else { | 1126 } else { |
1127 return *isolate->factory()->false_value(); | 1127 return *isolate->factory()->false_value(); |
1128 } | 1128 } |
1129 } | 1129 } |
1130 | 1130 |
1131 return *isolate->factory()->false_value(); | 1131 return *isolate->factory()->false_value(); |
1132 } | 1132 } |
1133 | 1133 |
1134 | 1134 |
1135 #define TYPED_ARRAY_GETTER(getter, accessor) \ | 1135 #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ |
1136 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGet##getter) { \ | 1136 RUNTIME_FUNCTION(MaybeObject*, Runtime_##Type##Get##getter) { \ |
1137 HandleScope scope(isolate); \ | 1137 HandleScope scope(isolate); \ |
1138 ASSERT(args.length() == 1); \ | 1138 ASSERT(args.length() == 1); \ |
1139 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); \ | 1139 CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ |
1140 if (!holder->IsJSTypedArray()) \ | 1140 return holder->accessor(); \ |
1141 return isolate->Throw(*isolate->factory()->NewTypeError( \ | |
1142 "not_typed_array", HandleVector<Object>(NULL, 0))); \ | |
1143 Handle<JSTypedArray> typed_array(JSTypedArray::cast(*holder)); \ | |
1144 return typed_array->accessor(); \ | |
1145 } | 1141 } |
1146 | 1142 |
1147 TYPED_ARRAY_GETTER(ByteLength, byte_length) | 1143 BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) |
1148 TYPED_ARRAY_GETTER(ByteOffset, byte_offset) | 1144 BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) |
1149 TYPED_ARRAY_GETTER(Length, length) | 1145 BUFFER_VIEW_GETTER(TypedArray, Length, length) |
| 1146 BUFFER_VIEW_GETTER(DataView, Buffer, buffer) |
1150 | 1147 |
1151 #undef TYPED_ARRAY_GETTER | 1148 #undef BUFFER_VIEW_GETTER |
1152 | 1149 |
1153 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) { | 1150 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) { |
1154 HandleScope scope(isolate); | 1151 HandleScope scope(isolate); |
1155 ASSERT(args.length() == 1); | 1152 ASSERT(args.length() == 1); |
1156 CONVERT_ARG_HANDLE_CHECKED(Object, holder, 0); | 1153 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
1157 if (!holder->IsJSTypedArray()) | 1154 return *holder->GetBuffer(); |
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 } | 1155 } |
1163 | 1156 |
1164 | 1157 |
1165 // Return codes for Runtime_TypedArraySetFastCases. | 1158 // Return codes for Runtime_TypedArraySetFastCases. |
1166 // Should be synchronized with typedarray.js natives. | 1159 // Should be synchronized with typedarray.js natives. |
1167 enum TypedArraySetResultCodes { | 1160 enum TypedArraySetResultCodes { |
1168 // Set from typed array of the same type. | 1161 // Set from typed array of the same type. |
1169 // This is processed by TypedArraySetFastCases | 1162 // This is processed by TypedArraySetFastCases |
1170 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 1163 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, |
1171 // Set from typed array of the different type, overlapping in memory. | 1164 // Set from typed array of the different type, overlapping in memory. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 ASSERT(byte_length->IsNumber()); | 1259 ASSERT(byte_length->IsNumber()); |
1267 holder->set_byte_length(*byte_length); | 1260 holder->set_byte_length(*byte_length); |
1268 | 1261 |
1269 holder->set_weak_next(buffer->weak_first_view()); | 1262 holder->set_weak_next(buffer->weak_first_view()); |
1270 buffer->set_weak_first_view(*holder); | 1263 buffer->set_weak_first_view(*holder); |
1271 | 1264 |
1272 return isolate->heap()->undefined_value(); | 1265 return isolate->heap()->undefined_value(); |
1273 } | 1266 } |
1274 | 1267 |
1275 | 1268 |
1276 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetBuffer) { | |
1277 HandleScope scope(isolate); | |
1278 ASSERT(args.length() == 1); | |
1279 CONVERT_ARG_HANDLE_CHECKED(JSDataView, data_view, 0); | |
1280 return data_view->buffer(); | |
1281 } | |
1282 | |
1283 | |
1284 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetByteOffset) { | |
1285 HandleScope scope(isolate); | |
1286 ASSERT(args.length() == 1); | |
1287 CONVERT_ARG_HANDLE_CHECKED(JSDataView, data_view, 0); | |
1288 return data_view->byte_offset(); | |
1289 } | |
1290 | |
1291 | |
1292 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGetByteLength) { | |
1293 HandleScope scope(isolate); | |
1294 ASSERT(args.length() == 1); | |
1295 CONVERT_ARG_HANDLE_CHECKED(JSDataView, data_view, 0); | |
1296 return data_view->byte_length(); | |
1297 } | |
1298 | |
1299 | |
1300 inline static bool NeedToFlipBytes(bool is_little_endian) { | 1269 inline static bool NeedToFlipBytes(bool is_little_endian) { |
1301 #ifdef V8_TARGET_LITTLE_ENDIAN | 1270 #ifdef V8_TARGET_LITTLE_ENDIAN |
1302 return !is_little_endian; | 1271 return !is_little_endian; |
1303 #else | 1272 #else |
1304 return is_little_endian; | 1273 return is_little_endian; |
1305 #endif | 1274 #endif |
1306 } | 1275 } |
1307 | 1276 |
1308 | 1277 |
1309 template<int n> | 1278 template<int n> |
(...skipping 13856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15166 } | 15135 } |
15167 } | 15136 } |
15168 | 15137 |
15169 | 15138 |
15170 void Runtime::OutOfMemory() { | 15139 void Runtime::OutOfMemory() { |
15171 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15140 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15172 UNREACHABLE(); | 15141 UNREACHABLE(); |
15173 } | 15142 } |
15174 | 15143 |
15175 } } // namespace v8::internal | 15144 } } // namespace v8::internal |
OLD | NEW |