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