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 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 } | 1205 } |
1206 | 1206 |
1207 | 1207 |
1208 template<typename T> | 1208 template<typename T> |
1209 inline static bool DataViewGetValue( | 1209 inline static bool DataViewGetValue( |
1210 Isolate* isolate, | 1210 Isolate* isolate, |
1211 Handle<JSDataView> data_view, | 1211 Handle<JSDataView> data_view, |
1212 Handle<Object> byte_offset_obj, | 1212 Handle<Object> byte_offset_obj, |
1213 bool is_little_endian, | 1213 bool is_little_endian, |
1214 T* result) { | 1214 T* result) { |
1215 size_t byte_offset = 0; | 1215 size_t byte_offset = NumberToSize(isolate, *byte_offset_obj); |
1216 if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) { | |
1217 return false; | |
1218 } | |
1219 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer())); | 1216 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer())); |
1220 | 1217 |
1221 size_t data_view_byte_offset = | 1218 size_t data_view_byte_offset = |
1222 NumberToSize(isolate, data_view->byte_offset()); | 1219 NumberToSize(isolate, data_view->byte_offset()); |
1223 size_t data_view_byte_length = | 1220 size_t data_view_byte_length = |
1224 NumberToSize(isolate, data_view->byte_length()); | 1221 NumberToSize(isolate, data_view->byte_length()); |
1225 if (byte_offset + sizeof(T) > data_view_byte_length || | 1222 if (byte_offset + sizeof(T) > data_view_byte_length || |
1226 byte_offset + sizeof(T) < byte_offset) { // overflow | 1223 byte_offset + sizeof(T) < byte_offset) { // overflow |
1227 return false; | 1224 return false; |
1228 } | 1225 } |
(...skipping 20 matching lines...) Expand all Loading... |
1249 } | 1246 } |
1250 | 1247 |
1251 | 1248 |
1252 template<typename T> | 1249 template<typename T> |
1253 static bool DataViewSetValue( | 1250 static bool DataViewSetValue( |
1254 Isolate* isolate, | 1251 Isolate* isolate, |
1255 Handle<JSDataView> data_view, | 1252 Handle<JSDataView> data_view, |
1256 Handle<Object> byte_offset_obj, | 1253 Handle<Object> byte_offset_obj, |
1257 bool is_little_endian, | 1254 bool is_little_endian, |
1258 T data) { | 1255 T data) { |
1259 size_t byte_offset = 0; | 1256 size_t byte_offset = NumberToSize(isolate, *byte_offset_obj); |
1260 if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) { | |
1261 return false; | |
1262 } | |
1263 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer())); | 1257 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer())); |
1264 | 1258 |
1265 size_t data_view_byte_offset = | 1259 size_t data_view_byte_offset = |
1266 NumberToSize(isolate, data_view->byte_offset()); | 1260 NumberToSize(isolate, data_view->byte_offset()); |
1267 size_t data_view_byte_length = | 1261 size_t data_view_byte_length = |
1268 NumberToSize(isolate, data_view->byte_length()); | 1262 NumberToSize(isolate, data_view->byte_length()); |
1269 if (byte_offset + sizeof(T) > data_view_byte_length || | 1263 if (byte_offset + sizeof(T) > data_view_byte_length || |
1270 byte_offset + sizeof(T) < byte_offset) { // overflow | 1264 byte_offset + sizeof(T) < byte_offset) { // overflow |
1271 return false; | 1265 return false; |
1272 } | 1266 } |
(...skipping 13632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14905 // Handle last resort GC and make sure to allow future allocations | 14899 // Handle last resort GC and make sure to allow future allocations |
14906 // to grow the heap without causing GCs (if possible). | 14900 // to grow the heap without causing GCs (if possible). |
14907 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14901 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14908 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14902 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14909 "Runtime::PerformGC"); | 14903 "Runtime::PerformGC"); |
14910 } | 14904 } |
14911 } | 14905 } |
14912 | 14906 |
14913 | 14907 |
14914 } } // namespace v8::internal | 14908 } } // namespace v8::internal |
OLD | NEW |