Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: src/runtime/runtime-simd.cc

Issue 1302133002: [simd.js] Add SIMD load functions for Phase 1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Bill's comment Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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; \
bbudge 2015/08/21 23:33:24 nit: move Handle declaration and combine with last
gdeepti 2015/08/25 19:10:33 Done.
836 DCHECK(args.length() == 2); \
837 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \
838 CONVERT_INT32_ARG_CHECKED(index, 1) \
839 size_t bpe = tarray->element_size(); \
840 uint32_t bytes = count * sizeof(lane_type); \
841 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
842 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
843 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
844 uint8_t* tarray_base = \
845 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
846 tarray_offset; \
847 memcpy(lanes, tarray_base + (index)*bpe, bytes); \
bbudge 2015/08/21 23:33:24 nit: spaces around '*' and remove parentheses.
gdeepti 2015/08/25 19:10:33 Done.
848 result = isolate->factory()->New##type(lanes);
849
850
851 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
852 RUNTIME_FUNCTION(Runtime_##type##Load) { \
853 HandleScope scope(isolate); \
854 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \
855 return *result; \
856 }
857
858
859 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \
860 RUNTIME_FUNCTION(Runtime_##type##Load1) { \
861 HandleScope scope(isolate); \
862 SIMD_LOAD(type, lane_type, lane_count, 1, result); \
863 return *result; \
864 }
865
866
867 #define SIMD_LOAD2_FUNCTION(type, lane_type, lane_count) \
868 RUNTIME_FUNCTION(Runtime_##type##Load2) { \
869 HandleScope scope(isolate); \
870 SIMD_LOAD(type, lane_type, lane_count, 2, result); \
871 return *result; \
872 }
873
874
875 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \
876 RUNTIME_FUNCTION(Runtime_##type##Load3) { \
877 HandleScope scope(isolate); \
878 SIMD_LOAD(type, lane_type, lane_count, 3, result); \
879 return *result; \
880 }
881
882
883 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION)
884 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION)
885 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION)
886 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION)
887
888 //-------------------------------------------------------------------
889
820 } // namespace internal 890 } // namespace internal
821 } // namespace v8 891 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698