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

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

Issue 1298603002: [runtime] Unify and fix the strict equality comparison. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
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/v8.h" 5 #include "src/v8.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/runtime/runtime-utils.h" 10 #include "src/runtime/runtime-utils.h"
(...skipping 30 matching lines...) Expand all
41 return static_cast<int16_t>(DoubleToInt32(number)); 41 return static_cast<int16_t>(DoubleToInt32(number));
42 } 42 }
43 43
44 44
45 template <> 45 template <>
46 int8_t ConvertNumber<int8_t>(double number) { 46 int8_t ConvertNumber<int8_t>(double number) {
47 return static_cast<int8_t>(DoubleToInt32(number)); 47 return static_cast<int8_t>(DoubleToInt32(number));
48 } 48 }
49 49
50 50
51 bool Equals(Float32x4* a, Float32x4* b) {
52 for (int i = 0; i < 4; i++) {
53 if (a->get_lane(i) != b->get_lane(i)) return false;
54 }
55 return true;
56 }
57
58
59 // TODO(bbudge): Make this consistent with SIMD instruction results. 51 // TODO(bbudge): Make this consistent with SIMD instruction results.
60 inline float RecipApprox(float a) { return 1.0f / a; } 52 inline float RecipApprox(float a) { return 1.0f / a; }
61 53
62 54
63 // TODO(bbudge): Make this consistent with SIMD instruction results. 55 // TODO(bbudge): Make this consistent with SIMD instruction results.
64 inline float RecipSqrtApprox(float a) { return 1.0f / std::sqrt(a); } 56 inline float RecipSqrtApprox(float a) { return 1.0f / std::sqrt(a); }
65 57
66 58
67 // Saturating addition for int16_t and int8_t. 59 // Saturating addition for int16_t and int8_t.
68 template <typename T> 60 template <typename T>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 133
142 RUNTIME_FUNCTION(Runtime_SimdToObject) { 134 RUNTIME_FUNCTION(Runtime_SimdToObject) {
143 HandleScope scope(isolate); 135 HandleScope scope(isolate);
144 DCHECK(args.length() == 1); 136 DCHECK(args.length() == 1);
145 CONVERT_ARG_HANDLE_CHECKED(Simd128Value, value, 0); 137 CONVERT_ARG_HANDLE_CHECKED(Simd128Value, value, 0);
146 return *Object::ToObject(isolate, value).ToHandleChecked(); 138 return *Object::ToObject(isolate, value).ToHandleChecked();
147 } 139 }
148 140
149 141
150 RUNTIME_FUNCTION(Runtime_SimdEquals) { 142 RUNTIME_FUNCTION(Runtime_SimdEquals) {
151 HandleScope scope(isolate); 143 SealHandleScope scope(isolate);
152 DCHECK(args.length() == 2); 144 DCHECK_EQ(2, args.length());
153 CONVERT_ARG_HANDLE_CHECKED(Simd128Value, a, 0); 145 CONVERT_ARG_CHECKED(Simd128Value, x, 0);
154 bool result = false; 146 CONVERT_ARG_CHECKED(Simd128Value, y, 1);
155 // args[1] is of unknown type. 147 return Smi::FromInt(x->Equals(y) ? EQUAL : NOT_EQUAL);
156 if (args[1]->IsSimd128Value()) {
157 Simd128Value* b = Simd128Value::cast(args[1]);
158 if (a->map() == b->map()) {
159 if (a->IsFloat32x4()) {
160 result = Equals(Float32x4::cast(*a), Float32x4::cast(b));
161 } else {
162 result = a->BitwiseEquals(b);
163 }
164 }
165 }
166 return Smi::FromInt(result ? EQUAL : NOT_EQUAL);
167 } 148 }
168 149
169 150
170 RUNTIME_FUNCTION(Runtime_SimdSameValue) { 151 RUNTIME_FUNCTION(Runtime_SimdSameValue) {
171 HandleScope scope(isolate); 152 HandleScope scope(isolate);
172 DCHECK(args.length() == 2); 153 DCHECK(args.length() == 2);
173 CONVERT_ARG_HANDLE_CHECKED(Simd128Value, a, 0); 154 CONVERT_ARG_HANDLE_CHECKED(Simd128Value, a, 0);
174 bool result = false; 155 bool result = false;
175 // args[1] is of unknown type. 156 // args[1] is of unknown type.
176 if (args[1]->IsSimd128Value()) { 157 if (args[1]->IsSimd128Value()) {
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 811
831 RUNTIME_FUNCTION(Runtime_Int8x16UnsignedExtractLane) { 812 RUNTIME_FUNCTION(Runtime_Int8x16UnsignedExtractLane) {
832 HandleScope scope(isolate); 813 HandleScope scope(isolate);
833 DCHECK(args.length() == 2); 814 DCHECK(args.length() == 2);
834 CONVERT_ARG_HANDLE_CHECKED(Int8x16, a, 0); 815 CONVERT_ARG_HANDLE_CHECKED(Int8x16, a, 0);
835 CONVERT_SIMD_LANE_ARG_CHECKED(lane, 1, 16); 816 CONVERT_SIMD_LANE_ARG_CHECKED(lane, 1, 16);
836 return *isolate->factory()->NewNumber(bit_cast<uint8_t>(a->get_lane(lane))); 817 return *isolate->factory()->NewNumber(bit_cast<uint8_t>(a->get_lane(lane)));
837 } 818 }
838 } // namespace internal 819 } // namespace internal
839 } // namespace v8 820 } // namespace v8
OLDNEW
« src/api.cc ('K') | « src/runtime/runtime-object.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698