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 "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 CheckGetCachedNodesContains(&T, T.NullConstant()); | 322 CheckGetCachedNodesContains(&T, T.NullConstant()); |
323 CheckGetCachedNodesContains(&T, T.ZeroConstant()); | 323 CheckGetCachedNodesContains(&T, T.ZeroConstant()); |
324 CheckGetCachedNodesContains(&T, T.OneConstant()); | 324 CheckGetCachedNodesContains(&T, T.OneConstant()); |
325 CheckGetCachedNodesContains(&T, T.NaNConstant()); | 325 CheckGetCachedNodesContains(&T, T.NaNConstant()); |
326 } | 326 } |
327 | 327 |
328 | 328 |
329 TEST(JSGraph_GetCachedNodes_int32) { | 329 TEST(JSGraph_GetCachedNodes_int32) { |
330 JSConstantCacheTester T; | 330 JSConstantCacheTester T; |
331 | 331 |
332 int32_t constants[] = {0, 11, 12, 13, 14, 55, -55, -44, -33, -22, -11, | 332 int32_t constants[] = {0, 1, 1, 1, 1, 2, 3, 4, 11, 12, 13, |
333 0, 11, 11, 12, 12, 11, 11, -33, -33, -22, -11}; | 333 14, 55, -55, -44, -33, -22, -11, 16, 16, 17, 17, |
| 334 18, 18, 19, 19, 20, 20, 21, 21, 22, 23, 24, |
| 335 25, 15, 30, 31, 45, 46, 47, 48}; |
334 | 336 |
335 for (size_t i = 0; i < arraysize(constants); i++) { | 337 for (size_t i = 0; i < arraysize(constants); i++) { |
336 int count_before = T.graph()->NodeCount(); | 338 int count_before = T.graph()->NodeCount(); |
337 NodeVector nodes_before(T.main_zone()); | 339 NodeVector nodes_before(T.main_zone()); |
338 T.GetCachedNodes(&nodes_before); | 340 T.GetCachedNodes(&nodes_before); |
339 Node* n = T.Int32Constant(constants[i]); | 341 Node* n = T.Int32Constant(constants[i]); |
340 if (n->id() < count_before) { | 342 if (n->id() < count_before) { |
341 // An old ID indicates a cached node. It should have been in the set. | 343 // An old ID indicates a cached node. It should have been in the set. |
342 CHECK(Contains(&nodes_before, n)); | 344 CHECK(Contains(&nodes_before, n)); |
343 } | 345 } |
(...skipping 21 matching lines...) Expand all Loading... |
365 } | 367 } |
366 // Old or new, it should be in the cached set afterwards. | 368 // Old or new, it should be in the cached set afterwards. |
367 CheckGetCachedNodesContains(&T, n); | 369 CheckGetCachedNodesContains(&T, n); |
368 } | 370 } |
369 } | 371 } |
370 | 372 |
371 | 373 |
372 TEST(JSGraph_GetCachedNodes_int64) { | 374 TEST(JSGraph_GetCachedNodes_int64) { |
373 JSConstantCacheTester T; | 375 JSConstantCacheTester T; |
374 | 376 |
375 int32_t constants[] = {0, 11, 12, 13, 14, 55, -55, -44, -33, -22, -11, | 377 int32_t constants[] = {0, 11, 12, 13, 14, 55, -55, -44, -33, |
376 0, 11, 11, 12, 12, 11, 11, -33, -33, -22, -11}; | 378 -22, -11, 16, 16, 17, 17, 18, 18, 19, |
| 379 19, 20, 20, 21, 21, 22, 23, 24, 25}; |
377 | 380 |
378 for (size_t i = 0; i < arraysize(constants); i++) { | 381 for (size_t i = 0; i < arraysize(constants); i++) { |
379 int count_before = T.graph()->NodeCount(); | 382 int count_before = T.graph()->NodeCount(); |
380 NodeVector nodes_before(T.main_zone()); | 383 NodeVector nodes_before(T.main_zone()); |
381 T.GetCachedNodes(&nodes_before); | 384 T.GetCachedNodes(&nodes_before); |
382 Node* n = T.Int64Constant(constants[i]); | 385 Node* n = T.Int64Constant(constants[i]); |
383 if (n->id() < count_before) { | 386 if (n->id() < count_before) { |
384 // An old ID indicates a cached node. It should have been in the set. | 387 // An old ID indicates a cached node. It should have been in the set. |
385 CHECK(Contains(&nodes_before, n)); | 388 CHECK(Contains(&nodes_before, n)); |
386 } | 389 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 T.Constant(1.11), | 465 T.Constant(1.11), |
463 T.ExternalConstant(ExternalReference::address_of_one_half())}; | 466 T.ExternalConstant(ExternalReference::address_of_one_half())}; |
464 | 467 |
465 NodeVector nodes(T.main_zone()); | 468 NodeVector nodes(T.main_zone()); |
466 T.GetCachedNodes(&nodes); | 469 T.GetCachedNodes(&nodes); |
467 | 470 |
468 for (size_t i = 0; i < arraysize(constants); i++) { | 471 for (size_t i = 0; i < arraysize(constants); i++) { |
469 CHECK(Contains(&nodes, constants[i])); | 472 CHECK(Contains(&nodes, constants[i])); |
470 } | 473 } |
471 } | 474 } |
OLD | NEW |