| 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 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 | 7 |
| 8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
| 9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } else { | 253 } else { |
| 254 CHECK_EQ(NumberToI32(is_signed), new_input->opcode()); | 254 CHECK_EQ(NumberToI32(is_signed), new_input->opcode()); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 | 258 |
| 259 // A helper class for testing lowering of bitwise shift operators. | 259 // A helper class for testing lowering of bitwise shift operators. |
| 260 class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { | 260 class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { |
| 261 public: | 261 public: |
| 262 static const int kNumberOps = 6; | 262 static const int kNumberOps = 6; |
| 263 Operator** ops; | 263 Operator* ops[kNumberOps]; |
| 264 bool* signedness; | 264 bool signedness[kNumberOps]; |
| 265 | 265 |
| 266 JSBitwiseShiftTypedLoweringTester() { | 266 JSBitwiseShiftTypedLoweringTester() { |
| 267 Operator* o[] = {javascript.ShiftLeft(), machine.Word32Shl(), | 267 int i = 0; |
| 268 javascript.ShiftRight(), machine.Word32Sar(), | 268 set(i++, javascript.ShiftLeft(), true); |
| 269 javascript.ShiftRightLogical(), machine.Word32Shr()}; | 269 set(i++, machine.Word32Shl(), false); |
| 270 set(i++, javascript.ShiftRight(), true); |
| 271 set(i++, machine.Word32Sar(), false); |
| 272 set(i++, javascript.ShiftRightLogical(), false); |
| 273 set(i++, machine.Word32Shr(), false); |
| 274 } |
| 270 | 275 |
| 271 ops = static_cast<Operator**>(malloc(sizeof(o))); | 276 private: |
| 272 memcpy(ops, o, sizeof(o)); | 277 void set(int idx, Operator* op, bool s) { |
| 273 | 278 ops[idx] = op; |
| 274 // Expected signedness of left and right conversions above. | 279 signedness[idx] = s; |
| 275 bool s[] = {true, false, true, false, false, false}; | |
| 276 | |
| 277 signedness = static_cast<bool*>(malloc(sizeof(s))); | |
| 278 memcpy(signedness, s, sizeof(s)); | |
| 279 } | 280 } |
| 280 }; | 281 }; |
| 281 | 282 |
| 282 | 283 |
| 283 TEST(Int32BitwiseShifts) { | 284 TEST(Int32BitwiseShifts) { |
| 284 JSBitwiseShiftTypedLoweringTester R; | 285 JSBitwiseShiftTypedLoweringTester R; |
| 285 | 286 |
| 286 Type* types[] = { | 287 Type* types[] = { |
| 287 Type::SignedSmall(), Type::UnsignedSmall(), Type::OtherSigned32(), | 288 Type::SignedSmall(), Type::UnsignedSmall(), Type::OtherSigned32(), |
| 288 Type::Unsigned32(), Type::Signed32(), Type::MinusZero(), | 289 Type::Unsigned32(), Type::Signed32(), Type::MinusZero(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 312 } | 313 } |
| 313 } | 314 } |
| 314 } | 315 } |
| 315 } | 316 } |
| 316 | 317 |
| 317 | 318 |
| 318 // A helper class for testing lowering of bitwise operators. | 319 // A helper class for testing lowering of bitwise operators. |
| 319 class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { | 320 class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { |
| 320 public: | 321 public: |
| 321 static const int kNumberOps = 6; | 322 static const int kNumberOps = 6; |
| 322 Operator** ops; | 323 Operator* ops[kNumberOps]; |
| 323 bool* signedness; | 324 bool signedness[kNumberOps]; |
| 324 | 325 |
| 325 JSBitwiseTypedLoweringTester() { | 326 JSBitwiseTypedLoweringTester() { |
| 326 Operator* o[] = {javascript.BitwiseOr(), machine.Word32Or(), | 327 int i = 0; |
| 327 javascript.BitwiseXor(), machine.Word32Xor(), | 328 set(i++, javascript.BitwiseOr(), true); |
| 328 javascript.BitwiseAnd(), machine.Word32And()}; | 329 set(i++, machine.Word32Or(), true); |
| 330 set(i++, javascript.BitwiseXor(), true); |
| 331 set(i++, machine.Word32Xor(), true); |
| 332 set(i++, javascript.BitwiseAnd(), true); |
| 333 set(i++, machine.Word32And(), true); |
| 334 } |
| 329 | 335 |
| 330 ops = static_cast<Operator**>(malloc(sizeof(o))); | 336 private: |
| 331 memcpy(ops, o, sizeof(o)); | 337 void set(int idx, Operator* op, bool s) { |
| 332 | 338 ops[idx] = op; |
| 333 // Expected signedness of left and right conversions above. | 339 signedness[idx] = s; |
| 334 bool s[] = {true, true, true, true, true, true}; | |
| 335 | |
| 336 signedness = static_cast<bool*>(malloc(sizeof(s))); | |
| 337 memcpy(signedness, s, sizeof(s)); | |
| 338 } | 340 } |
| 339 }; | 341 }; |
| 340 | 342 |
| 341 | 343 |
| 342 TEST(Int32BitwiseBinops) { | 344 TEST(Int32BitwiseBinops) { |
| 343 JSBitwiseTypedLoweringTester R; | 345 JSBitwiseTypedLoweringTester R; |
| 344 | 346 |
| 345 Type* types[] = { | 347 Type* types[] = { |
| 346 Type::SignedSmall(), Type::UnsignedSmall(), Type::OtherSigned32(), | 348 Type::SignedSmall(), Type::UnsignedSmall(), Type::OtherSigned32(), |
| 347 Type::Unsigned32(), Type::Signed32(), Type::MinusZero(), | 349 Type::Unsigned32(), Type::Signed32(), Type::MinusZero(), |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 CHECK_EQ(p1, r->InputAt(0)); | 1338 CHECK_EQ(p1, r->InputAt(0)); |
| 1337 CHECK_EQ(p0, r->InputAt(1)); | 1339 CHECK_EQ(p0, r->InputAt(1)); |
| 1338 } else { | 1340 } else { |
| 1339 CHECK_EQ(p0, r->InputAt(0)); | 1341 CHECK_EQ(p0, r->InputAt(0)); |
| 1340 CHECK_EQ(p1, r->InputAt(1)); | 1342 CHECK_EQ(p1, r->InputAt(1)); |
| 1341 } | 1343 } |
| 1342 } | 1344 } |
| 1343 } | 1345 } |
| 1344 } | 1346 } |
| 1345 } | 1347 } |
| OLD | NEW |