| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // call in the optimized code. | 406 // call in the optimized code. |
| 407 i::FLAG_prepare_always_opt = true; | 407 i::FLAG_prepare_always_opt = true; |
| 408 CompileConstructorWithDeoptimizingValueOf(); | 408 CompileConstructorWithDeoptimizingValueOf(); |
| 409 CompileRun(f_source); | 409 CompileRun(f_source); |
| 410 CompileRun("for (var i = 0; i < 5; i++) {" | 410 CompileRun("for (var i = 0; i < 5; i++) {" |
| 411 " f(8, new X());" | 411 " f(8, new X());" |
| 412 "};"); | 412 "};"); |
| 413 | 413 |
| 414 // Compile an optimized version of f. | 414 // Compile an optimized version of f. |
| 415 i::FLAG_always_opt = true; | 415 i::FLAG_always_opt = true; |
| 416 // Be deterministic. |
| 417 i::FLAG_concurrent_crankshaft = false; |
| 416 CompileRun(f_source); | 418 CompileRun(f_source); |
| 417 CompileRun("f(7, new X());"); | 419 CompileRun("f(7, new X());"); |
| 418 CHECK(!i::V8::UseCrankshaft() || | 420 CHECK(!i::V8::UseCrankshaft() || |
| 419 GetJSFunction((*env)->Global(), "f")->IsOptimized()); | 421 GetJSFunction((*env)->Global(), "f")->IsOptimized()); |
| 420 | 422 |
| 421 // Call f and force deoptimization while processing the binary operation. | 423 // Call f and force deoptimization while processing the binary operation. |
| 422 CompileRun("deopt = true;" | 424 CompileRun("deopt = true;" |
| 423 "var result = f(7, new X());"); | 425 "var result = f(7, new X());"); |
| 424 NonIncrementalGC(); | 426 NonIncrementalGC(); |
| 425 CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); | 427 CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 "X.prototype.toString = function () {" | 506 "X.prototype.toString = function () {" |
| 505 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" | 507 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" |
| 506 "};"); | 508 "};"); |
| 507 CompileRun(f_source); | 509 CompileRun(f_source); |
| 508 CompileRun("for (var i = 0; i < 5; i++) {" | 510 CompileRun("for (var i = 0; i < 5; i++) {" |
| 509 " f('a', new X());" | 511 " f('a', new X());" |
| 510 "};"); | 512 "};"); |
| 511 | 513 |
| 512 // Compile an optimized version of f. | 514 // Compile an optimized version of f. |
| 513 i::FLAG_always_opt = true; | 515 i::FLAG_always_opt = true; |
| 516 // Be deterministic. |
| 517 i::FLAG_concurrent_crankshaft = false; |
| 518 |
| 514 CompileRun(f_source); | 519 CompileRun(f_source); |
| 515 CompileRun("f('a', new X());"); | 520 CompileRun("f('a', new X());"); |
| 516 CHECK(!i::V8::UseCrankshaft() || | 521 CHECK(!i::V8::UseCrankshaft() || |
| 517 GetJSFunction(env->Global(), "f")->IsOptimized()); | 522 GetJSFunction(env->Global(), "f")->IsOptimized()); |
| 518 | 523 |
| 519 // Call f and force deoptimization while processing the comparison. | 524 // Call f and force deoptimization while processing the comparison. |
| 520 CompileRun("deopt = true;" | 525 CompileRun("deopt = true;" |
| 521 "var result = f('a', new X());"); | 526 "var result = f('a', new X());"); |
| 522 } | 527 } |
| 523 NonIncrementalGC(); | 528 NonIncrementalGC(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 CompileRun(g2_source); | 573 CompileRun(g2_source); |
| 569 CompileRun("for (var i = 0; i < 5; i++) {" | 574 CompileRun("for (var i = 0; i < 5; i++) {" |
| 570 " f1(new X());" | 575 " f1(new X());" |
| 571 " g1(new X());" | 576 " g1(new X());" |
| 572 " f2(new X(), 'z');" | 577 " f2(new X(), 'z');" |
| 573 " g2(new X(), 'z');" | 578 " g2(new X(), 'z');" |
| 574 "};"); | 579 "};"); |
| 575 | 580 |
| 576 // Compile an optimized version of the functions. | 581 // Compile an optimized version of the functions. |
| 577 i::FLAG_always_opt = true; | 582 i::FLAG_always_opt = true; |
| 583 // Be deterministic. |
| 584 i::FLAG_concurrent_crankshaft = false; |
| 578 CompileRun(f1_source); | 585 CompileRun(f1_source); |
| 579 CompileRun(g1_source); | 586 CompileRun(g1_source); |
| 580 CompileRun(f2_source); | 587 CompileRun(f2_source); |
| 581 CompileRun(g2_source); | 588 CompileRun(g2_source); |
| 582 CompileRun("f1(new X());"); | 589 CompileRun("f1(new X());"); |
| 583 CompileRun("g1(new X());"); | 590 CompileRun("g1(new X());"); |
| 584 CompileRun("f2(new X(), 'z');"); | 591 CompileRun("f2(new X(), 'z');"); |
| 585 CompileRun("g2(new X(), 'z');"); | 592 CompileRun("g2(new X(), 'z');"); |
| 586 if (i::V8::UseCrankshaft()) { | 593 if (i::V8::UseCrankshaft()) { |
| 587 CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); | 594 CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 CompileRun(g2_source); | 659 CompileRun(g2_source); |
| 653 CompileRun("for (var i = 0; i < 5; i++) {" | 660 CompileRun("for (var i = 0; i < 5; i++) {" |
| 654 " f1(new X());" | 661 " f1(new X());" |
| 655 " g1(new X());" | 662 " g1(new X());" |
| 656 " f2(new X(), 'z');" | 663 " f2(new X(), 'z');" |
| 657 " g2(new X(), 'z');" | 664 " g2(new X(), 'z');" |
| 658 "};"); | 665 "};"); |
| 659 | 666 |
| 660 // Compile an optimized version of the functions. | 667 // Compile an optimized version of the functions. |
| 661 i::FLAG_always_opt = true; | 668 i::FLAG_always_opt = true; |
| 669 // Be deterministic. |
| 670 i::FLAG_concurrent_crankshaft = false; |
| 671 |
| 662 CompileRun(f1_source); | 672 CompileRun(f1_source); |
| 663 CompileRun(g1_source); | 673 CompileRun(g1_source); |
| 664 CompileRun(f2_source); | 674 CompileRun(f2_source); |
| 665 CompileRun(g2_source); | 675 CompileRun(g2_source); |
| 666 CompileRun("f1(new X());"); | 676 CompileRun("f1(new X());"); |
| 667 CompileRun("g1(new X());"); | 677 CompileRun("g1(new X());"); |
| 668 CompileRun("f2(new X(), 'z');"); | 678 CompileRun("f2(new X(), 'z');"); |
| 669 CompileRun("g2(new X(), 'z');"); | 679 CompileRun("g2(new X(), 'z');"); |
| 670 if (i::V8::UseCrankshaft()) { | 680 if (i::V8::UseCrankshaft()) { |
| 671 CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); | 681 CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); |
| 672 CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); | 682 CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); |
| 673 CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); | 683 CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); |
| 674 CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); | 684 CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); |
| 675 } | 685 } |
| 676 | 686 |
| 677 // Call functions and force deoptimization while processing the ics. | 687 // Call functions and force deoptimization while processing the ics. |
| 678 CompileRun("deopt = true;" | 688 CompileRun("deopt = true;" |
| 679 "var result = f1(new X());"); | 689 "var result = f1(new X());"); |
| 680 } | 690 } |
| 681 NonIncrementalGC(); | 691 NonIncrementalGC(); |
| 682 | 692 |
| 683 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); | 693 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
| 684 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); | 694 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
| 685 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); | 695 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
| 686 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); | 696 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
| 687 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 697 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
| 688 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); | 698 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
| 689 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 699 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
| 690 } | 700 } |
| OLD | NEW |