OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 using namespace v8::internal; | 9 using namespace v8::internal; |
10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
(...skipping 23 matching lines...) Expand all Loading... |
34 " a = a | 0; b = b | 0;" | 34 " a = a | 0; b = b | 0;" |
35 " return x[a] + y[b];" | 35 " return x[a] + y[b];" |
36 " }" | 36 " }" |
37 " return f;" | 37 " return f;" |
38 "})()"; | 38 "})()"; |
39 EmbeddedVector<char, 1024> source_buffer; | 39 EmbeddedVector<char, 1024> source_buffer; |
40 SNPrintF(source_buffer, source, array_type, arraysize(kValues), | 40 SNPrintF(source_buffer, source, array_type, arraysize(kValues), |
41 values_buffer.start(), array_type, arraysize(kValues), | 41 values_buffer.start(), array_type, arraysize(kValues), |
42 values_buffer.start(), array_type, array_type); | 42 values_buffer.start(), array_type, array_type); |
43 | 43 |
44 FunctionTester T( | 44 FunctionTester T(source_buffer.start(), |
45 source_buffer.start(), | 45 CompilationInfo::kFunctionContextSpecializing | |
46 CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled); | 46 CompilationInfo::kTypingEnabled); |
47 for (size_t i = 0; i < arraysize(kValues); ++i) { | 47 for (size_t i = 0; i < arraysize(kValues); ++i) { |
48 for (size_t j = 0; j < arraysize(kValues); ++j) { | 48 for (size_t j = 0; j < arraysize(kValues); ++j) { |
49 volatile U value_a = static_cast<U>(kValues[i]); | 49 volatile U value_a = static_cast<U>(kValues[i]); |
50 volatile U value_b = static_cast<U>(kValues[j]); | 50 volatile U value_b = static_cast<U>(kValues[j]); |
51 double expected = | 51 double expected = |
52 static_cast<double>(value_a) + static_cast<double>(value_b); | 52 static_cast<double>(value_a) + static_cast<double>(value_b); |
53 T.CheckCall(T.Val(expected), T.Val(static_cast<double>(i)), | 53 T.CheckCall(T.Val(expected), T.Val(static_cast<double>(i)), |
54 T.Val(static_cast<double>(j))); | 54 T.Val(static_cast<double>(j))); |
55 } | 55 } |
56 } | 56 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 " x[a] = t;" | 102 " x[a] = t;" |
103 " return x[a] + y[b];" | 103 " return x[a] + y[b];" |
104 " }" | 104 " }" |
105 " return f;" | 105 " return f;" |
106 "})()"; | 106 "})()"; |
107 EmbeddedVector<char, 2048> source_buffer; | 107 EmbeddedVector<char, 2048> source_buffer; |
108 SNPrintF(source_buffer, source, array_type, arraysize(kValues), | 108 SNPrintF(source_buffer, source, array_type, arraysize(kValues), |
109 values_buffer.start(), array_type, arraysize(kValues), | 109 values_buffer.start(), array_type, arraysize(kValues), |
110 values_buffer.start(), array_type, array_type); | 110 values_buffer.start(), array_type, array_type); |
111 | 111 |
112 FunctionTester T( | 112 FunctionTester T(source_buffer.start(), |
113 source_buffer.start(), | 113 CompilationInfo::kFunctionContextSpecializing | |
114 CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled); | 114 CompilationInfo::kTypingEnabled); |
115 for (size_t i = 0; i < arraysize(kValues); ++i) { | 115 for (size_t i = 0; i < arraysize(kValues); ++i) { |
116 for (size_t j = 0; j < arraysize(kValues); ++j) { | 116 for (size_t j = 0; j < arraysize(kValues); ++j) { |
117 volatile U value_a = static_cast<U>(kValues[i]); | 117 volatile U value_a = static_cast<U>(kValues[i]); |
118 volatile U value_b = static_cast<U>(kValues[j]); | 118 volatile U value_b = static_cast<U>(kValues[j]); |
119 double expected = | 119 double expected = |
120 static_cast<double>(value_a) + static_cast<double>(value_b); | 120 static_cast<double>(value_a) + static_cast<double>(value_b); |
121 T.CheckCall(T.Val(expected), T.Val(static_cast<double>(i)), | 121 T.CheckCall(T.Val(expected), T.Val(static_cast<double>(i)), |
122 T.Val(static_cast<double>(j))); | 122 T.Val(static_cast<double>(j))); |
123 } | 123 } |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 TEST(TypedArrayStore) { | 128 TEST(TypedArrayStore) { |
129 FLAG_typed_array_max_size_in_heap = 256; | 129 FLAG_typed_array_max_size_in_heap = 256; |
130 TypedArrayStoreHelper<int8_t>("Int8"); | 130 TypedArrayStoreHelper<int8_t>("Int8"); |
131 TypedArrayStoreHelper<uint8_t>("Uint8"); | 131 TypedArrayStoreHelper<uint8_t>("Uint8"); |
132 TypedArrayStoreHelper<int16_t>("Int16"); | 132 TypedArrayStoreHelper<int16_t>("Int16"); |
133 TypedArrayStoreHelper<uint16_t>("Uint16"); | 133 TypedArrayStoreHelper<uint16_t>("Uint16"); |
134 TypedArrayStoreHelper<int32_t>("Int32"); | 134 TypedArrayStoreHelper<int32_t>("Int32"); |
135 TypedArrayStoreHelper<uint32_t>("Uint32"); | 135 TypedArrayStoreHelper<uint32_t>("Uint32"); |
136 TypedArrayStoreHelper<float>("Float32"); | 136 TypedArrayStoreHelper<float>("Float32"); |
137 TypedArrayStoreHelper<double>("Float64"); | 137 TypedArrayStoreHelper<double>("Float64"); |
138 // TODO(mstarzinger): Add tests for ClampedUint8. | 138 // TODO(mstarzinger): Add tests for ClampedUint8. |
139 } | 139 } |
OLD | NEW |