Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: test/cctest/test-deoptimization.cc

Issue 68203029: Make number of available threads isolate-dependent and expose it to ResourceConstraints. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/v8.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 private: 71 private:
72 bool always_opt_; 72 bool always_opt_;
73 bool allow_natives_syntax_; 73 bool allow_natives_syntax_;
74 bool use_inlining_; 74 bool use_inlining_;
75 }; 75 };
76 76
77 77
78 // Utility class to set --allow-natives-syntax and --nouse-inlining when 78 // Utility class to set --allow-natives-syntax and --nouse-inlining when
79 // constructed and return to their default state when destroyed. 79 // constructed and return to their default state when destroyed.
80 class AllowNativesSyntaxNoInliningNoConcurrent { 80 class AllowNativesSyntaxNoInlining {
81 public: 81 public:
82 AllowNativesSyntaxNoInliningNoConcurrent() 82 AllowNativesSyntaxNoInlining()
83 : allow_natives_syntax_(i::FLAG_allow_natives_syntax), 83 : allow_natives_syntax_(i::FLAG_allow_natives_syntax),
84 use_inlining_(i::FLAG_use_inlining), 84 use_inlining_(i::FLAG_use_inlining) {
85 concurrent_recompilation_(i::FLAG_concurrent_recompilation) {
86 i::FLAG_allow_natives_syntax = true; 85 i::FLAG_allow_natives_syntax = true;
87 i::FLAG_use_inlining = false; 86 i::FLAG_use_inlining = false;
88 i::FLAG_concurrent_recompilation = false;
89 } 87 }
90 88
91 ~AllowNativesSyntaxNoInliningNoConcurrent() { 89 ~AllowNativesSyntaxNoInlining() {
92 i::FLAG_allow_natives_syntax = allow_natives_syntax_; 90 i::FLAG_allow_natives_syntax = allow_natives_syntax_;
93 i::FLAG_use_inlining = use_inlining_; 91 i::FLAG_use_inlining = use_inlining_;
94 i::FLAG_concurrent_recompilation = concurrent_recompilation_;
95 } 92 }
96 93
97 private: 94 private:
98 bool allow_natives_syntax_; 95 bool allow_natives_syntax_;
99 bool use_inlining_; 96 bool use_inlining_;
100 bool concurrent_recompilation_;
101 }; 97 };
102 98
103 99
104 // Abort any ongoing incremental marking to make sure that all weak global 100 // Abort any ongoing incremental marking to make sure that all weak global
105 // handle callbacks are processed. 101 // handle callbacks are processed.
106 static void NonIncrementalGC() { 102 static void NonIncrementalGC() {
107 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 103 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
108 } 104 }
109 105
110 106
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 330 }
335 NonIncrementalGC(); 331 NonIncrementalGC();
336 332
337 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 333 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
338 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); 334 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value());
339 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 335 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
340 } 336 }
341 337
342 338
343 TEST(DeoptimizeBinaryOperationADDString) { 339 TEST(DeoptimizeBinaryOperationADDString) {
340 i::FLAG_concurrent_recompilation = false;
341 AllowNativesSyntaxNoInlining options;
344 LocalContext env; 342 LocalContext env;
345 v8::HandleScope scope(env->GetIsolate()); 343 v8::HandleScope scope(env->GetIsolate());
346 344
347 const char* f_source = "function f(x, y) { return x + y; };"; 345 const char* f_source = "function f(x, y) { return x + y; };";
348 346
349 { 347 {
350 AllowNativesSyntaxNoInliningNoConcurrent options;
351 // Compile function f and collect to type feedback to insert binary op stub 348 // Compile function f and collect to type feedback to insert binary op stub
352 // call in the optimized code. 349 // call in the optimized code.
353 i::FLAG_prepare_always_opt = true; 350 i::FLAG_prepare_always_opt = true;
354 CompileRun("var count = 0;" 351 CompileRun("var count = 0;"
355 "var result = 0;" 352 "var result = 0;"
356 "var deopt = false;" 353 "var deopt = false;"
357 "function X() { };" 354 "function X() { };"
358 "X.prototype.toString = function () {" 355 "X.prototype.toString = function () {"
359 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" 356 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'"
360 "};"); 357 "};");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 395
399 396
400 static void TestDeoptimizeBinaryOpHelper(LocalContext* env, 397 static void TestDeoptimizeBinaryOpHelper(LocalContext* env,
401 const char* binary_op) { 398 const char* binary_op) {
402 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer; 399 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer;
403 OS::SNPrintF(f_source_buffer, 400 OS::SNPrintF(f_source_buffer,
404 "function f(x, y) { return x %s y; };", 401 "function f(x, y) { return x %s y; };",
405 binary_op); 402 binary_op);
406 char* f_source = f_source_buffer.start(); 403 char* f_source = f_source_buffer.start();
407 404
408 AllowNativesSyntaxNoInliningNoConcurrent options; 405 AllowNativesSyntaxNoInlining options;
409 // Compile function f and collect to type feedback to insert binary op stub 406 // Compile function f and collect to type feedback to insert binary op stub
410 // call in the optimized code. 407 // call in the optimized code.
411 i::FLAG_prepare_always_opt = true; 408 i::FLAG_prepare_always_opt = true;
412 CompileConstructorWithDeoptimizingValueOf(); 409 CompileConstructorWithDeoptimizingValueOf();
413 CompileRun(f_source); 410 CompileRun(f_source);
414 CompileRun("for (var i = 0; i < 5; i++) {" 411 CompileRun("for (var i = 0; i < 5; i++) {"
415 " f(8, new X());" 412 " f(8, new X());"
416 "};"); 413 "};");
417 414
418 // Compile an optimized version of f. 415 // Compile an optimized version of f.
419 i::FLAG_always_opt = true; 416 i::FLAG_always_opt = true;
420 CompileRun(f_source); 417 CompileRun(f_source);
421 CompileRun("f(7, new X());"); 418 CompileRun("f(7, new X());");
422 CHECK(!CcTest::i_isolate()->use_crankshaft() || 419 CHECK(!CcTest::i_isolate()->use_crankshaft() ||
423 GetJSFunction((*env)->Global(), "f")->IsOptimized()); 420 GetJSFunction((*env)->Global(), "f")->IsOptimized());
424 421
425 // Call f and force deoptimization while processing the binary operation. 422 // Call f and force deoptimization while processing the binary operation.
426 CompileRun("deopt = true;" 423 CompileRun("deopt = true;"
427 "var result = f(7, new X());"); 424 "var result = f(7, new X());");
428 NonIncrementalGC(); 425 NonIncrementalGC();
429 CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); 426 CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized());
430 } 427 }
431 428
432 429
433 TEST(DeoptimizeBinaryOperationADD) { 430 TEST(DeoptimizeBinaryOperationADD) {
431 i::FLAG_concurrent_recompilation = false;
434 LocalContext env; 432 LocalContext env;
435 v8::HandleScope scope(env->GetIsolate()); 433 v8::HandleScope scope(env->GetIsolate());
436 434
437 TestDeoptimizeBinaryOpHelper(&env, "+"); 435 TestDeoptimizeBinaryOpHelper(&env, "+");
438 436
439 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 437 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
440 CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value()); 438 CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value());
441 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 439 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
442 } 440 }
443 441
444 442
445 TEST(DeoptimizeBinaryOperationSUB) { 443 TEST(DeoptimizeBinaryOperationSUB) {
444 i::FLAG_concurrent_recompilation = false;
446 LocalContext env; 445 LocalContext env;
447 v8::HandleScope scope(env->GetIsolate()); 446 v8::HandleScope scope(env->GetIsolate());
448 447
449 TestDeoptimizeBinaryOpHelper(&env, "-"); 448 TestDeoptimizeBinaryOpHelper(&env, "-");
450 449
451 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 450 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
452 CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value()); 451 CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value());
453 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 452 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
454 } 453 }
455 454
456 455
457 TEST(DeoptimizeBinaryOperationMUL) { 456 TEST(DeoptimizeBinaryOperationMUL) {
457 i::FLAG_concurrent_recompilation = false;
458 LocalContext env; 458 LocalContext env;
459 v8::HandleScope scope(env->GetIsolate()); 459 v8::HandleScope scope(env->GetIsolate());
460 460
461 TestDeoptimizeBinaryOpHelper(&env, "*"); 461 TestDeoptimizeBinaryOpHelper(&env, "*");
462 462
463 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 463 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
464 CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value()); 464 CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value());
465 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 465 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
466 } 466 }
467 467
468 468
469 TEST(DeoptimizeBinaryOperationDIV) { 469 TEST(DeoptimizeBinaryOperationDIV) {
470 i::FLAG_concurrent_recompilation = false;
470 LocalContext env; 471 LocalContext env;
471 v8::HandleScope scope(env->GetIsolate()); 472 v8::HandleScope scope(env->GetIsolate());
472 473
473 TestDeoptimizeBinaryOpHelper(&env, "/"); 474 TestDeoptimizeBinaryOpHelper(&env, "/");
474 475
475 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 476 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
476 CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value()); 477 CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value());
477 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 478 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
478 } 479 }
479 480
480 481
481 TEST(DeoptimizeBinaryOperationMOD) { 482 TEST(DeoptimizeBinaryOperationMOD) {
483 i::FLAG_concurrent_recompilation = false;
482 LocalContext env; 484 LocalContext env;
483 v8::HandleScope scope(env->GetIsolate()); 485 v8::HandleScope scope(env->GetIsolate());
484 486
485 TestDeoptimizeBinaryOpHelper(&env, "%"); 487 TestDeoptimizeBinaryOpHelper(&env, "%");
486 488
487 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 489 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
488 CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value()); 490 CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value());
489 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 491 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
490 } 492 }
491 493
492 494
493 TEST(DeoptimizeCompare) { 495 TEST(DeoptimizeCompare) {
496 i::FLAG_concurrent_recompilation = false;
494 LocalContext env; 497 LocalContext env;
495 v8::HandleScope scope(env->GetIsolate()); 498 v8::HandleScope scope(env->GetIsolate());
496 499
497 const char* f_source = "function f(x, y) { return x < y; };"; 500 const char* f_source = "function f(x, y) { return x < y; };";
498 501
499 { 502 {
500 AllowNativesSyntaxNoInliningNoConcurrent options; 503 AllowNativesSyntaxNoInlining options;
501 // Compile function f and collect to type feedback to insert compare ic 504 // Compile function f and collect to type feedback to insert compare ic
502 // call in the optimized code. 505 // call in the optimized code.
503 i::FLAG_prepare_always_opt = true; 506 i::FLAG_prepare_always_opt = true;
504 CompileRun("var count = 0;" 507 CompileRun("var count = 0;"
505 "var result = 0;" 508 "var result = 0;"
506 "var deopt = false;" 509 "var deopt = false;"
507 "function X() { };" 510 "function X() { };"
508 "X.prototype.toString = function () {" 511 "X.prototype.toString = function () {"
509 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" 512 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'"
510 "};"); 513 "};");
(...skipping 16 matching lines...) Expand all
527 NonIncrementalGC(); 530 NonIncrementalGC();
528 531
529 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); 532 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized());
530 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 533 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
531 CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue()); 534 CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue());
532 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 535 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
533 } 536 }
534 537
535 538
536 TEST(DeoptimizeLoadICStoreIC) { 539 TEST(DeoptimizeLoadICStoreIC) {
540 i::FLAG_concurrent_recompilation = false;
537 LocalContext env; 541 LocalContext env;
538 v8::HandleScope scope(env->GetIsolate()); 542 v8::HandleScope scope(env->GetIsolate());
539 543
540 // Functions to generate load/store/keyed load/keyed store IC calls. 544 // Functions to generate load/store/keyed load/keyed store IC calls.
541 const char* f1_source = "function f1(x) { return x.y; };"; 545 const char* f1_source = "function f1(x) { return x.y; };";
542 const char* g1_source = "function g1(x) { x.y = 1; };"; 546 const char* g1_source = "function g1(x) { x.y = 1; };";
543 const char* f2_source = "function f2(x, y) { return x[y]; };"; 547 const char* f2_source = "function f2(x, y) { return x[y]; };";
544 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; 548 const char* g2_source = "function g2(x, y) { x[y] = 1; };";
545 549
546 { 550 {
547 AllowNativesSyntaxNoInliningNoConcurrent options; 551 AllowNativesSyntaxNoInlining options;
548 // Compile functions and collect to type feedback to insert ic 552 // Compile functions and collect to type feedback to insert ic
549 // calls in the optimized code. 553 // calls in the optimized code.
550 i::FLAG_prepare_always_opt = true; 554 i::FLAG_prepare_always_opt = true;
551 CompileRun("var count = 0;" 555 CompileRun("var count = 0;"
552 "var result = 0;" 556 "var result = 0;"
553 "var deopt = false;" 557 "var deopt = false;"
554 "function X() { };" 558 "function X() { };"
555 "X.prototype.__defineGetter__('y', function () {" 559 "X.prototype.__defineGetter__('y', function () {"
556 " if (deopt) { count++; %DeoptimizeFunction(f1); };" 560 " if (deopt) { count++; %DeoptimizeFunction(f1); };"
557 " return 13;" 561 " return 13;"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); 611 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized());
608 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); 612 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized());
609 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); 613 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized());
610 CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value()); 614 CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value());
611 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); 615 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value());
612 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 616 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
613 } 617 }
614 618
615 619
616 TEST(DeoptimizeLoadICStoreICNested) { 620 TEST(DeoptimizeLoadICStoreICNested) {
621 i::FLAG_concurrent_recompilation = false;
617 LocalContext env; 622 LocalContext env;
618 v8::HandleScope scope(env->GetIsolate()); 623 v8::HandleScope scope(env->GetIsolate());
619 624
620 // Functions to generate load/store/keyed load/keyed store IC calls. 625 // Functions to generate load/store/keyed load/keyed store IC calls.
621 const char* f1_source = "function f1(x) { return x.y; };"; 626 const char* f1_source = "function f1(x) { return x.y; };";
622 const char* g1_source = "function g1(x) { x.y = 1; };"; 627 const char* g1_source = "function g1(x) { x.y = 1; };";
623 const char* f2_source = "function f2(x, y) { return x[y]; };"; 628 const char* f2_source = "function f2(x, y) { return x[y]; };";
624 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; 629 const char* g2_source = "function g2(x, y) { x[y] = 1; };";
625 630
626 { 631 {
627 AllowNativesSyntaxNoInliningNoConcurrent options; 632 AllowNativesSyntaxNoInlining options;
628 // Compile functions and collect to type feedback to insert ic 633 // Compile functions and collect to type feedback to insert ic
629 // calls in the optimized code. 634 // calls in the optimized code.
630 i::FLAG_prepare_always_opt = true; 635 i::FLAG_prepare_always_opt = true;
631 CompileRun("var count = 0;" 636 CompileRun("var count = 0;"
632 "var result = 0;" 637 "var result = 0;"
633 "var deopt = false;" 638 "var deopt = false;"
634 "function X() { };" 639 "function X() { };"
635 "X.prototype.__defineGetter__('y', function () {" 640 "X.prototype.__defineGetter__('y', function () {"
636 " g1(this);" 641 " g1(this);"
637 " return 13;" 642 " return 13;"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 NonIncrementalGC(); 690 NonIncrementalGC();
686 691
687 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); 692 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized());
688 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); 693 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized());
689 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); 694 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized());
690 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); 695 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized());
691 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 696 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
692 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); 697 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value());
693 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); 698 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
694 } 699 }
OLDNEW
« no previous file with comments | « src/v8.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698