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.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, 1, 1, 1, 1, 2, 3, 4, 11, 12, 13, | 332 int32_t constants[] = {0, 1, 1, 1, 1, 2, 3, 4, 11, 12, 13, |
333 14, 55, -55, -44, -33, -22, -11, 16, 16, 17, 17, | 333 14, 55, -55, -44, -33, -22, -11, 16, 16, 17, 17, |
334 18, 18, 19, 19, 20, 20, 21, 21, 22, 23, 24, | 334 18, 18, 19, 19, 20, 20, 21, 21, 22, 23, 24, |
335 25, 15, 30, 31, 45, 46, 47, 48}; | 335 25, 15, 30, 31, 45, 46, 47, 48}; |
336 | 336 |
337 for (size_t i = 0; i < arraysize(constants); i++) { | 337 for (size_t i = 0; i < arraysize(constants); i++) { |
338 int count_before = T.graph()->NodeCount(); | 338 size_t count_before = T.graph()->NodeCount(); |
339 NodeVector nodes_before(T.main_zone()); | 339 NodeVector nodes_before(T.main_zone()); |
340 T.GetCachedNodes(&nodes_before); | 340 T.GetCachedNodes(&nodes_before); |
341 Node* n = T.Int32Constant(constants[i]); | 341 Node* n = T.Int32Constant(constants[i]); |
342 if (n->id() < count_before) { | 342 if (n->id() < count_before) { |
343 // 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. |
344 CHECK(Contains(&nodes_before, n)); | 344 CHECK(Contains(&nodes_before, n)); |
345 } | 345 } |
346 // Old or new, it should be in the cached set afterwards. | 346 // Old or new, it should be in the cached set afterwards. |
347 CheckGetCachedNodesContains(&T, n); | 347 CheckGetCachedNodesContains(&T, n); |
348 } | 348 } |
349 } | 349 } |
350 | 350 |
351 | 351 |
352 TEST(JSGraph_GetCachedNodes_float64) { | 352 TEST(JSGraph_GetCachedNodes_float64) { |
353 JSConstantCacheTester T; | 353 JSConstantCacheTester T; |
354 | 354 |
355 double constants[] = {0, 11.1, 12.2, 13, 14, 55.5, -55.5, -44.4, | 355 double constants[] = {0, 11.1, 12.2, 13, 14, 55.5, -55.5, -44.4, |
356 -33, -22, -11, 0, 11.1, 11.1, 12.3, 12.3, | 356 -33, -22, -11, 0, 11.1, 11.1, 12.3, 12.3, |
357 11, 11, -33.3, -33.3, -22, -11}; | 357 11, 11, -33.3, -33.3, -22, -11}; |
358 | 358 |
359 for (size_t i = 0; i < arraysize(constants); i++) { | 359 for (size_t i = 0; i < arraysize(constants); i++) { |
360 int count_before = T.graph()->NodeCount(); | 360 size_t count_before = T.graph()->NodeCount(); |
361 NodeVector nodes_before(T.main_zone()); | 361 NodeVector nodes_before(T.main_zone()); |
362 T.GetCachedNodes(&nodes_before); | 362 T.GetCachedNodes(&nodes_before); |
363 Node* n = T.Float64Constant(constants[i]); | 363 Node* n = T.Float64Constant(constants[i]); |
364 if (n->id() < count_before) { | 364 if (n->id() < count_before) { |
365 // An old ID indicates a cached node. It should have been in the set. | 365 // An old ID indicates a cached node. It should have been in the set. |
366 CHECK(Contains(&nodes_before, n)); | 366 CHECK(Contains(&nodes_before, n)); |
367 } | 367 } |
368 // Old or new, it should be in the cached set afterwards. | 368 // Old or new, it should be in the cached set afterwards. |
369 CheckGetCachedNodesContains(&T, n); | 369 CheckGetCachedNodesContains(&T, n); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 | 373 |
374 TEST(JSGraph_GetCachedNodes_int64) { | 374 TEST(JSGraph_GetCachedNodes_int64) { |
375 JSConstantCacheTester T; | 375 JSConstantCacheTester T; |
376 | 376 |
377 int32_t constants[] = {0, 11, 12, 13, 14, 55, -55, -44, -33, | 377 int32_t constants[] = {0, 11, 12, 13, 14, 55, -55, -44, -33, |
378 -22, -11, 16, 16, 17, 17, 18, 18, 19, | 378 -22, -11, 16, 16, 17, 17, 18, 18, 19, |
379 19, 20, 20, 21, 21, 22, 23, 24, 25}; | 379 19, 20, 20, 21, 21, 22, 23, 24, 25}; |
380 | 380 |
381 for (size_t i = 0; i < arraysize(constants); i++) { | 381 for (size_t i = 0; i < arraysize(constants); i++) { |
382 int count_before = T.graph()->NodeCount(); | 382 size_t count_before = T.graph()->NodeCount(); |
383 NodeVector nodes_before(T.main_zone()); | 383 NodeVector nodes_before(T.main_zone()); |
384 T.GetCachedNodes(&nodes_before); | 384 T.GetCachedNodes(&nodes_before); |
385 Node* n = T.Int64Constant(constants[i]); | 385 Node* n = T.Int64Constant(constants[i]); |
386 if (n->id() < count_before) { | 386 if (n->id() < count_before) { |
387 // 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. |
388 CHECK(Contains(&nodes_before, n)); | 388 CHECK(Contains(&nodes_before, n)); |
389 } | 389 } |
390 // Old or new, it should be in the cached set afterwards. | 390 // Old or new, it should be in the cached set afterwards. |
391 CheckGetCachedNodesContains(&T, n); | 391 CheckGetCachedNodesContains(&T, n); |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 | 395 |
396 TEST(JSGraph_GetCachedNodes_number) { | 396 TEST(JSGraph_GetCachedNodes_number) { |
397 JSConstantCacheTester T; | 397 JSConstantCacheTester T; |
398 | 398 |
399 double constants[] = {0, 11.1, 12.2, 13, 14, 55.5, -55.5, -44.4, | 399 double constants[] = {0, 11.1, 12.2, 13, 14, 55.5, -55.5, -44.4, |
400 -33, -22, -11, 0, 11.1, 11.1, 12.3, 12.3, | 400 -33, -22, -11, 0, 11.1, 11.1, 12.3, 12.3, |
401 11, 11, -33.3, -33.3, -22, -11}; | 401 11, 11, -33.3, -33.3, -22, -11}; |
402 | 402 |
403 for (size_t i = 0; i < arraysize(constants); i++) { | 403 for (size_t i = 0; i < arraysize(constants); i++) { |
404 int count_before = T.graph()->NodeCount(); | 404 size_t count_before = T.graph()->NodeCount(); |
405 NodeVector nodes_before(T.main_zone()); | 405 NodeVector nodes_before(T.main_zone()); |
406 T.GetCachedNodes(&nodes_before); | 406 T.GetCachedNodes(&nodes_before); |
407 Node* n = T.Constant(constants[i]); | 407 Node* n = T.Constant(constants[i]); |
408 if (n->id() < count_before) { | 408 if (n->id() < count_before) { |
409 // An old ID indicates a cached node. It should have been in the set. | 409 // An old ID indicates a cached node. It should have been in the set. |
410 CHECK(Contains(&nodes_before, n)); | 410 CHECK(Contains(&nodes_before, n)); |
411 } | 411 } |
412 // Old or new, it should be in the cached set afterwards. | 412 // Old or new, it should be in the cached set afterwards. |
413 CheckGetCachedNodesContains(&T, n); | 413 CheckGetCachedNodesContains(&T, n); |
414 } | 414 } |
415 } | 415 } |
416 | 416 |
417 | 417 |
418 TEST(JSGraph_GetCachedNodes_external) { | 418 TEST(JSGraph_GetCachedNodes_external) { |
419 JSConstantCacheTester T; | 419 JSConstantCacheTester T; |
420 | 420 |
421 ExternalReference constants[] = {ExternalReference::address_of_min_int(), | 421 ExternalReference constants[] = {ExternalReference::address_of_min_int(), |
422 ExternalReference::address_of_min_int(), | 422 ExternalReference::address_of_min_int(), |
423 ExternalReference::address_of_min_int(), | 423 ExternalReference::address_of_min_int(), |
424 ExternalReference::address_of_one_half(), | 424 ExternalReference::address_of_one_half(), |
425 ExternalReference::address_of_one_half(), | 425 ExternalReference::address_of_one_half(), |
426 ExternalReference::address_of_min_int(), | 426 ExternalReference::address_of_min_int(), |
427 ExternalReference::address_of_the_hole_nan(), | 427 ExternalReference::address_of_the_hole_nan(), |
428 ExternalReference::address_of_one_half()}; | 428 ExternalReference::address_of_one_half()}; |
429 | 429 |
430 for (size_t i = 0; i < arraysize(constants); i++) { | 430 for (size_t i = 0; i < arraysize(constants); i++) { |
431 int count_before = T.graph()->NodeCount(); | 431 size_t count_before = T.graph()->NodeCount(); |
432 NodeVector nodes_before(T.main_zone()); | 432 NodeVector nodes_before(T.main_zone()); |
433 T.GetCachedNodes(&nodes_before); | 433 T.GetCachedNodes(&nodes_before); |
434 Node* n = T.ExternalConstant(constants[i]); | 434 Node* n = T.ExternalConstant(constants[i]); |
435 if (n->id() < count_before) { | 435 if (n->id() < count_before) { |
436 // An old ID indicates a cached node. It should have been in the set. | 436 // An old ID indicates a cached node. It should have been in the set. |
437 CHECK(Contains(&nodes_before, n)); | 437 CHECK(Contains(&nodes_before, n)); |
438 } | 438 } |
439 // Old or new, it should be in the cached set afterwards. | 439 // Old or new, it should be in the cached set afterwards. |
440 CheckGetCachedNodesContains(&T, n); | 440 CheckGetCachedNodesContains(&T, n); |
441 } | 441 } |
(...skipping 23 matching lines...) Expand all Loading... |
465 T.Constant(1.11), | 465 T.Constant(1.11), |
466 T.ExternalConstant(ExternalReference::address_of_one_half())}; | 466 T.ExternalConstant(ExternalReference::address_of_one_half())}; |
467 | 467 |
468 NodeVector nodes(T.main_zone()); | 468 NodeVector nodes(T.main_zone()); |
469 T.GetCachedNodes(&nodes); | 469 T.GetCachedNodes(&nodes); |
470 | 470 |
471 for (size_t i = 0; i < arraysize(constants); i++) { | 471 for (size_t i = 0; i < arraysize(constants); i++) { |
472 CHECK(Contains(&nodes, constants[i])); | 472 CHECK(Contains(&nodes, constants[i])); |
473 } | 473 } |
474 } | 474 } |
OLD | NEW |