OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/base/macros.h" | 8 #include "src/base/macros.h" |
9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 return *result; \ | 581 return *result; \ |
582 } | 582 } |
583 | 583 |
584 #define SIMD_MAX_FUNCTION(type, lane_type, lane_count) \ | 584 #define SIMD_MAX_FUNCTION(type, lane_type, lane_count) \ |
585 RUNTIME_FUNCTION(Runtime_##type##Max) { \ | 585 RUNTIME_FUNCTION(Runtime_##type##Max) { \ |
586 HandleScope scope(isolate); \ | 586 HandleScope scope(isolate); \ |
587 SIMD_BINARY_OP(type, lane_type, lane_count, Max, result); \ | 587 SIMD_BINARY_OP(type, lane_type, lane_count, Max, result); \ |
588 return *result; \ | 588 return *result; \ |
589 } | 589 } |
590 | 590 |
591 | |
591 SIMD_NUMERIC_TYPES(SIMD_NEG_FUNCTION) | 592 SIMD_NUMERIC_TYPES(SIMD_NEG_FUNCTION) |
592 SIMD_NUMERIC_TYPES(SIMD_ADD_FUNCTION) | 593 SIMD_NUMERIC_TYPES(SIMD_ADD_FUNCTION) |
593 SIMD_NUMERIC_TYPES(SIMD_SUB_FUNCTION) | 594 SIMD_NUMERIC_TYPES(SIMD_SUB_FUNCTION) |
594 SIMD_NUMERIC_TYPES(SIMD_MUL_FUNCTION) | 595 SIMD_NUMERIC_TYPES(SIMD_MUL_FUNCTION) |
595 SIMD_NUMERIC_TYPES(SIMD_MIN_FUNCTION) | 596 SIMD_NUMERIC_TYPES(SIMD_MIN_FUNCTION) |
596 SIMD_NUMERIC_TYPES(SIMD_MAX_FUNCTION) | 597 SIMD_NUMERIC_TYPES(SIMD_MAX_FUNCTION) |
597 | 598 |
598 //------------------------------------------------------------------- | 599 //------------------------------------------------------------------- |
599 | 600 |
600 // Relational functions. | 601 // Relational functions. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 } | 811 } |
811 | 812 |
812 | 813 |
813 RUNTIME_FUNCTION(Runtime_Int8x16UnsignedExtractLane) { | 814 RUNTIME_FUNCTION(Runtime_Int8x16UnsignedExtractLane) { |
814 HandleScope scope(isolate); | 815 HandleScope scope(isolate); |
815 DCHECK(args.length() == 2); | 816 DCHECK(args.length() == 2); |
816 CONVERT_ARG_HANDLE_CHECKED(Int8x16, a, 0); | 817 CONVERT_ARG_HANDLE_CHECKED(Int8x16, a, 0); |
817 CONVERT_SIMD_LANE_ARG_CHECKED(lane, 1, 16); | 818 CONVERT_SIMD_LANE_ARG_CHECKED(lane, 1, 16); |
818 return *isolate->factory()->NewNumber(bit_cast<uint8_t>(a->get_lane(lane))); | 819 return *isolate->factory()->NewNumber(bit_cast<uint8_t>(a->get_lane(lane))); |
819 } | 820 } |
821 | |
822 | |
823 //------------------------------------------------------------------- | |
824 | |
825 // Load functions. | |
826 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \ | |
827 FUNCTION(Float32x4, float, 4) \ | |
828 FUNCTION(Int32x4, int32_t, 4) | |
829 | |
830 | |
831 // Common Load Functions | |
832 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \ | |
833 static const int kLaneCount = lane_count; \ | |
834 lane_type lanes[kLaneCount] = {0}; \ | |
835 Handle<type> result; \ | |
836 DCHECK(args.length() == 2); \ | |
837 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray_obj, 0); \ | |
838 CONVERT_INT32_ARG_CHECKED(index, 1) \ | |
839 Handle<JSTypedArray> tarray(JSTypedArray::cast(*tarray_obj)); \ | |
bbudge
2015/08/21 22:32:42
I don't think this line is necessary (CONVERT_ARG_
gdeepti
2015/08/21 22:49:40
Done.
| |
840 size_t bpe = tarray->element_size(); \ | |
841 uint32_t bytes = count * sizeof(lane_type); \ | |
842 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ | |
843 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \ | |
844 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ | |
845 uint8_t* tarray_base = \ | |
846 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ | |
847 tarray_offset; \ | |
848 memcpy(lanes, tarray_base + (index)*bpe, bytes); \ | |
849 result = isolate->factory()->New##type(lanes); | |
850 | |
851 | |
852 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \ | |
853 RUNTIME_FUNCTION(Runtime_##type##Load) { \ | |
854 HandleScope scope(isolate); \ | |
855 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \ | |
856 return *result; \ | |
857 } | |
858 | |
859 | |
860 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \ | |
861 RUNTIME_FUNCTION(Runtime_##type##Load1) { \ | |
862 HandleScope scope(isolate); \ | |
863 SIMD_LOAD(type, lane_type, lane_count, 1, result); \ | |
864 return *result; \ | |
865 } | |
866 | |
867 | |
868 #define SIMD_LOAD2_FUNCTION(type, lane_type, lane_count) \ | |
869 RUNTIME_FUNCTION(Runtime_##type##Load2) { \ | |
870 HandleScope scope(isolate); \ | |
871 SIMD_LOAD(type, lane_type, lane_count, 2, result); \ | |
872 return *result; \ | |
873 } | |
874 | |
875 | |
876 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \ | |
877 RUNTIME_FUNCTION(Runtime_##type##Load3) { \ | |
878 HandleScope scope(isolate); \ | |
879 SIMD_LOAD(type, lane_type, lane_count, 3, result); \ | |
880 return *result; \ | |
881 } | |
882 | |
883 | |
884 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION) | |
885 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION) | |
886 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION) | |
887 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) | |
888 | |
889 //------------------------------------------------------------------- | |
890 | |
820 } // namespace internal | 891 } // namespace internal |
821 } // namespace v8 | 892 } // namespace v8 |
OLD | NEW |