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

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

Issue 21156009: Re-revert "Flush parallel recompilation queues on context dispose notification" (r15883). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months 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/runtime.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 AllowNativesSyntaxNoInliningNoParallel { 80 class AllowNativesSyntaxNoInlining {
81 public: 81 public:
82 AllowNativesSyntaxNoInliningNoParallel() 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 parallel_recompilation_(i::FLAG_parallel_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_parallel_recompilation = false;
89 } 87 }
90 88
91 ~AllowNativesSyntaxNoInliningNoParallel() { 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_parallel_recompilation = parallel_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 parallel_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 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); 103 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
108 } 104 }
109 105
110 106
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 336 }
341 337
342 338
343 TEST(DeoptimizeBinaryOperationADDString) { 339 TEST(DeoptimizeBinaryOperationADDString) {
344 LocalContext env; 340 LocalContext env;
345 v8::HandleScope scope(env->GetIsolate()); 341 v8::HandleScope scope(env->GetIsolate());
346 342
347 const char* f_source = "function f(x, y) { return x + y; };"; 343 const char* f_source = "function f(x, y) { return x + y; };";
348 344
349 { 345 {
350 AllowNativesSyntaxNoInliningNoParallel options; 346 AllowNativesSyntaxNoInlining options;
351 // Compile function f and collect to type feedback to insert binary op stub 347 // Compile function f and collect to type feedback to insert binary op stub
352 // call in the optimized code. 348 // call in the optimized code.
353 i::FLAG_prepare_always_opt = true; 349 i::FLAG_prepare_always_opt = true;
354 CompileRun("var count = 0;" 350 CompileRun("var count = 0;"
355 "var result = 0;" 351 "var result = 0;"
356 "var deopt = false;" 352 "var deopt = false;"
357 "function X() { };" 353 "function X() { };"
358 "X.prototype.toString = function () {" 354 "X.prototype.toString = function () {"
359 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" 355 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'"
360 "};"); 356 "};");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 394
399 395
400 static void TestDeoptimizeBinaryOpHelper(LocalContext* env, 396 static void TestDeoptimizeBinaryOpHelper(LocalContext* env,
401 const char* binary_op) { 397 const char* binary_op) {
402 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer; 398 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer;
403 OS::SNPrintF(f_source_buffer, 399 OS::SNPrintF(f_source_buffer,
404 "function f(x, y) { return x %s y; };", 400 "function f(x, y) { return x %s y; };",
405 binary_op); 401 binary_op);
406 char* f_source = f_source_buffer.start(); 402 char* f_source = f_source_buffer.start();
407 403
408 AllowNativesSyntaxNoInliningNoParallel options; 404 AllowNativesSyntaxNoInlining options;
409 // Compile function f and collect to type feedback to insert binary op stub 405 // Compile function f and collect to type feedback to insert binary op stub
410 // call in the optimized code. 406 // call in the optimized code.
411 i::FLAG_prepare_always_opt = true; 407 i::FLAG_prepare_always_opt = true;
412 CompileConstructorWithDeoptimizingValueOf(); 408 CompileConstructorWithDeoptimizingValueOf();
413 CompileRun(f_source); 409 CompileRun(f_source);
414 CompileRun("for (var i = 0; i < 5; i++) {" 410 CompileRun("for (var i = 0; i < 5; i++) {"
415 " f(8, new X());" 411 " f(8, new X());"
416 "};"); 412 "};");
417 413
418 // Compile an optimized version of f. 414 // Compile an optimized version of f.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 486 }
491 487
492 488
493 TEST(DeoptimizeCompare) { 489 TEST(DeoptimizeCompare) {
494 LocalContext env; 490 LocalContext env;
495 v8::HandleScope scope(env->GetIsolate()); 491 v8::HandleScope scope(env->GetIsolate());
496 492
497 const char* f_source = "function f(x, y) { return x < y; };"; 493 const char* f_source = "function f(x, y) { return x < y; };";
498 494
499 { 495 {
500 AllowNativesSyntaxNoInliningNoParallel options; 496 AllowNativesSyntaxNoInlining options;
501 // Compile function f and collect to type feedback to insert compare ic 497 // Compile function f and collect to type feedback to insert compare ic
502 // call in the optimized code. 498 // call in the optimized code.
503 i::FLAG_prepare_always_opt = true; 499 i::FLAG_prepare_always_opt = true;
504 CompileRun("var count = 0;" 500 CompileRun("var count = 0;"
505 "var result = 0;" 501 "var result = 0;"
506 "var deopt = false;" 502 "var deopt = false;"
507 "function X() { };" 503 "function X() { };"
508 "X.prototype.toString = function () {" 504 "X.prototype.toString = function () {"
509 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" 505 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'"
510 "};"); 506 "};");
(...skipping 26 matching lines...) Expand all
537 LocalContext env; 533 LocalContext env;
538 v8::HandleScope scope(env->GetIsolate()); 534 v8::HandleScope scope(env->GetIsolate());
539 535
540 // Functions to generate load/store/keyed load/keyed store IC calls. 536 // Functions to generate load/store/keyed load/keyed store IC calls.
541 const char* f1_source = "function f1(x) { return x.y; };"; 537 const char* f1_source = "function f1(x) { return x.y; };";
542 const char* g1_source = "function g1(x) { x.y = 1; };"; 538 const char* g1_source = "function g1(x) { x.y = 1; };";
543 const char* f2_source = "function f2(x, y) { return x[y]; };"; 539 const char* f2_source = "function f2(x, y) { return x[y]; };";
544 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; 540 const char* g2_source = "function g2(x, y) { x[y] = 1; };";
545 541
546 { 542 {
547 AllowNativesSyntaxNoInliningNoParallel options; 543 AllowNativesSyntaxNoInlining options;
548 // Compile functions and collect to type feedback to insert ic 544 // Compile functions and collect to type feedback to insert ic
549 // calls in the optimized code. 545 // calls in the optimized code.
550 i::FLAG_prepare_always_opt = true; 546 i::FLAG_prepare_always_opt = true;
551 CompileRun("var count = 0;" 547 CompileRun("var count = 0;"
552 "var result = 0;" 548 "var result = 0;"
553 "var deopt = false;" 549 "var deopt = false;"
554 "function X() { };" 550 "function X() { };"
555 "X.prototype.__defineGetter__('y', function () {" 551 "X.prototype.__defineGetter__('y', function () {"
556 " if (deopt) { count++; %DeoptimizeFunction(f1); };" 552 " if (deopt) { count++; %DeoptimizeFunction(f1); };"
557 " return 13;" 553 " return 13;"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 LocalContext env; 613 LocalContext env;
618 v8::HandleScope scope(env->GetIsolate()); 614 v8::HandleScope scope(env->GetIsolate());
619 615
620 // Functions to generate load/store/keyed load/keyed store IC calls. 616 // Functions to generate load/store/keyed load/keyed store IC calls.
621 const char* f1_source = "function f1(x) { return x.y; };"; 617 const char* f1_source = "function f1(x) { return x.y; };";
622 const char* g1_source = "function g1(x) { x.y = 1; };"; 618 const char* g1_source = "function g1(x) { x.y = 1; };";
623 const char* f2_source = "function f2(x, y) { return x[y]; };"; 619 const char* f2_source = "function f2(x, y) { return x[y]; };";
624 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; 620 const char* g2_source = "function g2(x, y) { x[y] = 1; };";
625 621
626 { 622 {
627 AllowNativesSyntaxNoInliningNoParallel options; 623 AllowNativesSyntaxNoInlining options;
628 // Compile functions and collect to type feedback to insert ic 624 // Compile functions and collect to type feedback to insert ic
629 // calls in the optimized code. 625 // calls in the optimized code.
630 i::FLAG_prepare_always_opt = true; 626 i::FLAG_prepare_always_opt = true;
631 CompileRun("var count = 0;" 627 CompileRun("var count = 0;"
632 "var result = 0;" 628 "var result = 0;"
633 "var deopt = false;" 629 "var deopt = false;"
634 "function X() { };" 630 "function X() { };"
635 "X.prototype.__defineGetter__('y', function () {" 631 "X.prototype.__defineGetter__('y', function () {"
636 " g1(this);" 632 " g1(this);"
637 " return 13;" 633 " return 13;"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 NonIncrementalGC(); 681 NonIncrementalGC();
686 682
687 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); 683 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized());
688 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); 684 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized());
689 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); 685 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized());
690 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); 686 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized());
691 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); 687 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value());
692 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); 688 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value());
693 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); 689 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current()));
694 } 690 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698