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

Side by Side Diff: test/cctest/test-simd.cc

Issue 2695653005: Revert of Remove SIMD.js from V8. (Closed)
Patch Set: Created 3 years, 10 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 | « test/cctest/test-object.cc ('k') | test/mjsunit/double-equals.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "src/factory.h"
8 #include "src/isolate.h"
9 #include "src/objects.h"
10 // FIXME(mstarzinger, marja): This is weird, but required because of the missing
11 // (disallowed) include: src/factory.h -> src/objects-inl.h
12 #include "src/objects-inl.h"
13 #include "src/ostreams.h"
14 // FIXME(mstarzinger, marja): This is weird, but required because of the missing
15 // (disallowed) include: src/feedback-vector.h ->
16 // src/feedback-vector-inl.h
17 #include "src/feedback-vector-inl.h"
18 #include "test/cctest/cctest.h"
19
20 using namespace v8::internal;
21
22 #define FLOAT_TEST(type, lane_count) \
23 { \
24 float nan = std::numeric_limits<float>::quiet_NaN(); \
25 float lanes[lane_count] = {0}; \
26 Handle<type> a = factory->New##type(lanes); \
27 Handle<type> b = factory->New##type(lanes); \
28 CHECK(a->BitwiseEquals(*b)); \
29 CHECK(a->SameValue(*b)); \
30 CHECK(a->SameValueZero(*b)); \
31 CHECK_EQ(a->Hash(), b->Hash()); \
32 for (int i = 0; i < lane_count; i++) { \
33 a->set_lane(i, -0.0); \
34 CHECK(!a->BitwiseEquals(*b)); \
35 CHECK_NE(a->Hash(), b->Hash()); \
36 CHECK(!a->SameValue(*b)); \
37 CHECK(a->SameValueZero(*b)); \
38 b->set_lane(i, -0.0); \
39 CHECK(a->BitwiseEquals(*b)); \
40 CHECK_EQ(a->Hash(), b->Hash()); \
41 CHECK(a->SameValue(*b)); \
42 CHECK(a->SameValueZero(*b)); \
43 a->set_lane(i, nan); \
44 CHECK(!a->BitwiseEquals(*b)); \
45 CHECK(!a->SameValue(*b)); \
46 CHECK(!a->SameValueZero(*b)); \
47 CHECK_NE(a->Hash(), b->Hash()); \
48 b->set_lane(i, nan); \
49 CHECK(a->BitwiseEquals(*b)); \
50 CHECK_EQ(a->Hash(), b->Hash()); \
51 CHECK(a->SameValue(*b)); \
52 CHECK(a->SameValueZero(*b)); \
53 } \
54 }
55
56 #define INT_TEST(type, lane_count, lane_type) \
57 { \
58 lane_type lanes[lane_count] = {0}; \
59 Handle<type> a = factory->New##type(lanes); \
60 Handle<type> b = factory->New##type(lanes); \
61 CHECK(a->BitwiseEquals(*b)); \
62 CHECK(a->SameValue(*b)); \
63 CHECK(a->SameValueZero(*b)); \
64 CHECK_EQ(a->Hash(), b->Hash()); \
65 for (int i = 0; i < lane_count; i++) { \
66 a->set_lane(i, i + 1); \
67 CHECK(!a->BitwiseEquals(*b)); \
68 CHECK_NE(a->Hash(), b->Hash()); \
69 CHECK(!a->SameValue(*b)); \
70 CHECK(!a->SameValueZero(*b)); \
71 b->set_lane(i, i + 1); \
72 CHECK(a->BitwiseEquals(*b)); \
73 CHECK_EQ(a->Hash(), b->Hash()); \
74 CHECK(a->SameValue(*b)); \
75 CHECK(a->SameValueZero(*b)); \
76 a->set_lane(i, -(i + 1)); \
77 CHECK(!a->BitwiseEquals(*b)); \
78 CHECK_NE(a->Hash(), b->Hash()); \
79 CHECK(!a->SameValue(*b)); \
80 CHECK(!a->SameValueZero(*b)); \
81 b->set_lane(i, -(i + 1)); \
82 CHECK(a->BitwiseEquals(*b)); \
83 CHECK_EQ(a->Hash(), b->Hash()); \
84 CHECK(a->SameValue(*b)); \
85 CHECK(a->SameValueZero(*b)); \
86 } \
87 }
88
89 #define BOOL_TEST(type, lane_count) \
90 { \
91 bool lanes[lane_count] = {false}; \
92 Handle<type> a = factory->New##type(lanes); \
93 Handle<type> b = factory->New##type(lanes); \
94 CHECK(a->BitwiseEquals(*b)); \
95 CHECK(a->SameValue(*b)); \
96 CHECK(a->SameValueZero(*b)); \
97 CHECK_EQ(a->Hash(), b->Hash()); \
98 for (int i = 0; i < lane_count; i++) { \
99 a->set_lane(i, true); \
100 CHECK(!a->BitwiseEquals(*b)); \
101 CHECK_NE(a->Hash(), b->Hash()); \
102 CHECK(!a->SameValue(*b)); \
103 CHECK(!a->SameValueZero(*b)); \
104 b->set_lane(i, true); \
105 CHECK(a->BitwiseEquals(*b)); \
106 CHECK_EQ(a->Hash(), b->Hash()); \
107 CHECK(a->SameValue(*b)); \
108 CHECK(a->SameValueZero(*b)); \
109 } \
110 }
111
112 TEST(SimdTypes) {
113 CcTest::InitializeVM();
114 Isolate* isolate = CcTest::i_isolate();
115 Factory* factory = isolate->factory();
116
117 HandleScope sc(isolate);
118
119 FLOAT_TEST(Float32x4, 4)
120 INT_TEST(Int32x4, 4, int32_t)
121 INT_TEST(Uint32x4, 4, uint32_t)
122 BOOL_TEST(Bool32x4, 4)
123 INT_TEST(Int16x8, 8, int16_t)
124 INT_TEST(Uint16x8, 8, uint16_t)
125 BOOL_TEST(Bool16x8, 8)
126 INT_TEST(Int8x16, 16, int8_t)
127 INT_TEST(Uint8x16, 16, uint8_t)
128 BOOL_TEST(Bool8x16, 16)
129 }
OLDNEW
« no previous file with comments | « test/cctest/test-object.cc ('k') | test/mjsunit/double-equals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698