OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/factory.h" | 8 #include "src/factory.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
11 #include "src/runtime/runtime.h" | 11 #include "src/runtime/runtime.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { | 16 RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { |
17 SealHandleScope shs(isolate); | 17 SealHandleScope shs(isolate); |
18 DCHECK(args.length() == 1); | 18 DCHECK(args.length() == 1); |
19 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); | 19 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); |
20 return holder->byte_length(); | 20 return holder->byte_length(); |
21 } | 21 } |
22 | 22 |
23 | 23 |
24 RUNTIME_FUNCTION(Runtime_ArrayBufferSliceImpl) { | 24 RUNTIME_FUNCTION(Runtime_ArrayBufferSliceImpl) { |
25 HandleScope scope(isolate); | 25 HandleScope scope(isolate); |
26 DCHECK(args.length() == 3); | 26 DCHECK(args.length() == 4); |
27 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); | 27 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); |
28 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); | 28 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); |
29 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); | 29 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); |
| 30 CONVERT_NUMBER_ARG_HANDLE_CHECKED(new_length, 3); |
30 RUNTIME_ASSERT(!source.is_identical_to(target)); | 31 RUNTIME_ASSERT(!source.is_identical_to(target)); |
31 size_t start = 0; | 32 size_t start = 0, target_length = 0; |
32 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); | 33 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); |
33 size_t target_length = NumberToSize(isolate, target->byte_length()); | 34 RUNTIME_ASSERT(TryNumberToSize(isolate, *new_length, &target_length)); |
| 35 RUNTIME_ASSERT(NumberToSize(isolate, target->byte_length()) >= target_length); |
34 | 36 |
35 if (target_length == 0) return isolate->heap()->undefined_value(); | 37 if (target_length == 0) return isolate->heap()->undefined_value(); |
36 | 38 |
37 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); | 39 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); |
38 RUNTIME_ASSERT(start <= source_byte_length); | 40 RUNTIME_ASSERT(start <= source_byte_length); |
39 RUNTIME_ASSERT(source_byte_length - start >= target_length); | 41 RUNTIME_ASSERT(source_byte_length - start >= target_length); |
40 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); | 42 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); |
41 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); | 43 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); |
42 CopyBytes(target_data, source_data + start, target_length); | 44 CopyBytes(target_data, source_data + start, target_length); |
43 return isolate->heap()->undefined_value(); | 45 return isolate->heap()->undefined_value(); |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 DATA_VIEW_SETTER(Uint16, uint16_t) | 662 DATA_VIEW_SETTER(Uint16, uint16_t) |
661 DATA_VIEW_SETTER(Int16, int16_t) | 663 DATA_VIEW_SETTER(Int16, int16_t) |
662 DATA_VIEW_SETTER(Uint32, uint32_t) | 664 DATA_VIEW_SETTER(Uint32, uint32_t) |
663 DATA_VIEW_SETTER(Int32, int32_t) | 665 DATA_VIEW_SETTER(Int32, int32_t) |
664 DATA_VIEW_SETTER(Float32, float) | 666 DATA_VIEW_SETTER(Float32, float) |
665 DATA_VIEW_SETTER(Float64, double) | 667 DATA_VIEW_SETTER(Float64, double) |
666 | 668 |
667 #undef DATA_VIEW_SETTER | 669 #undef DATA_VIEW_SETTER |
668 } // namespace internal | 670 } // namespace internal |
669 } // namespace v8 | 671 } // namespace v8 |
OLD | NEW |