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