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

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 comments 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
« src/harmony-simd.js ('K') | « 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_MEMORY_OP_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 RUNTIME_ASSERT(index >= 0); \
bbudge 2015/08/20 23:05:25 Combine this with the one below, i.e. index >= 0 &
gdeepti 2015/08/21 21:07:50 Done.
840 Handle<JSTypedArray> tarray(JSTypedArray::cast(*tarray_obj)); \
841 size_t bpe = tarray->element_size(); \
842 uint32_t bytes = count * sizeof(lane_type); \
843 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
844 RUNTIME_ASSERT(index* bpe + bytes <= byte_length); \
bbudge 2015/08/20 23:05:26 nit: space after 'index'
gdeepti 2015/08/21 21:07:50 Done.
845 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
846 uint8_t* tarray_base = \
847 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
848 tarray_offset; \
849 memcpy(lanes, tarray_base + (index)*bpe, bytes); \
850 result = isolate->factory()->New##type(lanes);
851
852
853 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
854 RUNTIME_FUNCTION(Runtime_##type##Load) { \
855 HandleScope scope(isolate); \
856 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \
857 return *result; \
858 }
859
860
861 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \
862 RUNTIME_FUNCTION(Runtime_##type##Load1) { \
863 HandleScope scope(isolate); \
864 SIMD_LOAD(type, lane_type, lane_count, 1, result); \
865 return *result; \
866 }
867
868
869 #define SIMD_LOAD2_FUNCTION(type, lane_type, lane_count) \
870 RUNTIME_FUNCTION(Runtime_##type##Load2) { \
871 HandleScope scope(isolate); \
872 SIMD_LOAD(type, lane_type, lane_count, 2, result); \
873 return *result; \
874 }
875
876
877 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \
878 RUNTIME_FUNCTION(Runtime_##type##Load3) { \
879 HandleScope scope(isolate); \
880 SIMD_LOAD(type, lane_type, lane_count, 3, result); \
881 return *result; \
882 }
883
884
885 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION)
886 SIMD_MEMORY_OP_TYPES(SIMD_LOAD1_FUNCTION)
887 SIMD_MEMORY_OP_TYPES(SIMD_LOAD2_FUNCTION)
888 SIMD_MEMORY_OP_TYPES(SIMD_LOAD3_FUNCTION)
889
890 //-------------------------------------------------------------------
891
820 } // namespace internal 892 } // namespace internal
821 } // namespace v8 893 } // namespace v8
OLDNEW
« src/harmony-simd.js ('K') | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698