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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 AllowNativesSyntaxNoInlining { | 80 class AllowNativesSyntaxNoInliningNoParallel { |
81 public: | 81 public: |
82 AllowNativesSyntaxNoInlining() | 82 AllowNativesSyntaxNoInliningNoParallel() |
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) { |
85 i::FLAG_allow_natives_syntax = true; | 86 i::FLAG_allow_natives_syntax = true; |
86 i::FLAG_use_inlining = false; | 87 i::FLAG_use_inlining = false; |
| 88 i::FLAG_parallel_recompilation = false; |
87 } | 89 } |
88 | 90 |
89 ~AllowNativesSyntaxNoInlining() { | 91 ~AllowNativesSyntaxNoInliningNoParallel() { |
90 i::FLAG_allow_natives_syntax = allow_natives_syntax_; | 92 i::FLAG_allow_natives_syntax = allow_natives_syntax_; |
91 i::FLAG_use_inlining = use_inlining_; | 93 i::FLAG_use_inlining = use_inlining_; |
| 94 i::FLAG_parallel_recompilation = parallel_recompilation_; |
92 } | 95 } |
93 | 96 |
94 private: | 97 private: |
95 bool allow_natives_syntax_; | 98 bool allow_natives_syntax_; |
96 bool use_inlining_; | 99 bool use_inlining_; |
| 100 bool parallel_recompilation_; |
97 }; | 101 }; |
98 | 102 |
99 | 103 |
100 // Abort any ongoing incremental marking to make sure that all weak global | 104 // Abort any ongoing incremental marking to make sure that all weak global |
101 // handle callbacks are processed. | 105 // handle callbacks are processed. |
102 static void NonIncrementalGC() { | 106 static void NonIncrementalGC() { |
103 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 107 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
104 } | 108 } |
105 | 109 |
106 | 110 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 340 } |
337 | 341 |
338 | 342 |
339 TEST(DeoptimizeBinaryOperationADDString) { | 343 TEST(DeoptimizeBinaryOperationADDString) { |
340 LocalContext env; | 344 LocalContext env; |
341 v8::HandleScope scope(env->GetIsolate()); | 345 v8::HandleScope scope(env->GetIsolate()); |
342 | 346 |
343 const char* f_source = "function f(x, y) { return x + y; };"; | 347 const char* f_source = "function f(x, y) { return x + y; };"; |
344 | 348 |
345 { | 349 { |
346 AllowNativesSyntaxNoInlining options; | 350 AllowNativesSyntaxNoInliningNoParallel options; |
347 // Compile function f and collect to type feedback to insert binary op stub | 351 // Compile function f and collect to type feedback to insert binary op stub |
348 // call in the optimized code. | 352 // call in the optimized code. |
349 i::FLAG_prepare_always_opt = true; | 353 i::FLAG_prepare_always_opt = true; |
350 CompileRun("var count = 0;" | 354 CompileRun("var count = 0;" |
351 "var result = 0;" | 355 "var result = 0;" |
352 "var deopt = false;" | 356 "var deopt = false;" |
353 "function X() { };" | 357 "function X() { };" |
354 "X.prototype.toString = function () {" | 358 "X.prototype.toString = function () {" |
355 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" | 359 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" |
356 "};"); | 360 "};"); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 398 |
395 | 399 |
396 static void TestDeoptimizeBinaryOpHelper(LocalContext* env, | 400 static void TestDeoptimizeBinaryOpHelper(LocalContext* env, |
397 const char* binary_op) { | 401 const char* binary_op) { |
398 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer; | 402 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer; |
399 OS::SNPrintF(f_source_buffer, | 403 OS::SNPrintF(f_source_buffer, |
400 "function f(x, y) { return x %s y; };", | 404 "function f(x, y) { return x %s y; };", |
401 binary_op); | 405 binary_op); |
402 char* f_source = f_source_buffer.start(); | 406 char* f_source = f_source_buffer.start(); |
403 | 407 |
404 AllowNativesSyntaxNoInlining options; | 408 AllowNativesSyntaxNoInliningNoParallel options; |
405 // Compile function f and collect to type feedback to insert binary op stub | 409 // Compile function f and collect to type feedback to insert binary op stub |
406 // call in the optimized code. | 410 // call in the optimized code. |
407 i::FLAG_prepare_always_opt = true; | 411 i::FLAG_prepare_always_opt = true; |
408 CompileConstructorWithDeoptimizingValueOf(); | 412 CompileConstructorWithDeoptimizingValueOf(); |
409 CompileRun(f_source); | 413 CompileRun(f_source); |
410 CompileRun("for (var i = 0; i < 5; i++) {" | 414 CompileRun("for (var i = 0; i < 5; i++) {" |
411 " f(8, new X());" | 415 " f(8, new X());" |
412 "};"); | 416 "};"); |
413 | 417 |
414 // Compile an optimized version of f. | 418 // Compile an optimized version of f. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 } | 490 } |
487 | 491 |
488 | 492 |
489 TEST(DeoptimizeCompare) { | 493 TEST(DeoptimizeCompare) { |
490 LocalContext env; | 494 LocalContext env; |
491 v8::HandleScope scope(env->GetIsolate()); | 495 v8::HandleScope scope(env->GetIsolate()); |
492 | 496 |
493 const char* f_source = "function f(x, y) { return x < y; };"; | 497 const char* f_source = "function f(x, y) { return x < y; };"; |
494 | 498 |
495 { | 499 { |
496 AllowNativesSyntaxNoInlining options; | 500 AllowNativesSyntaxNoInliningNoParallel options; |
497 // Compile function f and collect to type feedback to insert compare ic | 501 // Compile function f and collect to type feedback to insert compare ic |
498 // call in the optimized code. | 502 // call in the optimized code. |
499 i::FLAG_prepare_always_opt = true; | 503 i::FLAG_prepare_always_opt = true; |
500 CompileRun("var count = 0;" | 504 CompileRun("var count = 0;" |
501 "var result = 0;" | 505 "var result = 0;" |
502 "var deopt = false;" | 506 "var deopt = false;" |
503 "function X() { };" | 507 "function X() { };" |
504 "X.prototype.toString = function () {" | 508 "X.prototype.toString = function () {" |
505 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" | 509 " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" |
506 "};"); | 510 "};"); |
(...skipping 26 matching lines...) Expand all Loading... |
533 LocalContext env; | 537 LocalContext env; |
534 v8::HandleScope scope(env->GetIsolate()); | 538 v8::HandleScope scope(env->GetIsolate()); |
535 | 539 |
536 // Functions to generate load/store/keyed load/keyed store IC calls. | 540 // Functions to generate load/store/keyed load/keyed store IC calls. |
537 const char* f1_source = "function f1(x) { return x.y; };"; | 541 const char* f1_source = "function f1(x) { return x.y; };"; |
538 const char* g1_source = "function g1(x) { x.y = 1; };"; | 542 const char* g1_source = "function g1(x) { x.y = 1; };"; |
539 const char* f2_source = "function f2(x, y) { return x[y]; };"; | 543 const char* f2_source = "function f2(x, y) { return x[y]; };"; |
540 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; | 544 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
541 | 545 |
542 { | 546 { |
543 AllowNativesSyntaxNoInlining options; | 547 AllowNativesSyntaxNoInliningNoParallel options; |
544 // Compile functions and collect to type feedback to insert ic | 548 // Compile functions and collect to type feedback to insert ic |
545 // calls in the optimized code. | 549 // calls in the optimized code. |
546 i::FLAG_prepare_always_opt = true; | 550 i::FLAG_prepare_always_opt = true; |
547 CompileRun("var count = 0;" | 551 CompileRun("var count = 0;" |
548 "var result = 0;" | 552 "var result = 0;" |
549 "var deopt = false;" | 553 "var deopt = false;" |
550 "function X() { };" | 554 "function X() { };" |
551 "X.prototype.__defineGetter__('y', function () {" | 555 "X.prototype.__defineGetter__('y', function () {" |
552 " if (deopt) { count++; %DeoptimizeFunction(f1); };" | 556 " if (deopt) { count++; %DeoptimizeFunction(f1); };" |
553 " return 13;" | 557 " return 13;" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 LocalContext env; | 617 LocalContext env; |
614 v8::HandleScope scope(env->GetIsolate()); | 618 v8::HandleScope scope(env->GetIsolate()); |
615 | 619 |
616 // Functions to generate load/store/keyed load/keyed store IC calls. | 620 // Functions to generate load/store/keyed load/keyed store IC calls. |
617 const char* f1_source = "function f1(x) { return x.y; };"; | 621 const char* f1_source = "function f1(x) { return x.y; };"; |
618 const char* g1_source = "function g1(x) { x.y = 1; };"; | 622 const char* g1_source = "function g1(x) { x.y = 1; };"; |
619 const char* f2_source = "function f2(x, y) { return x[y]; };"; | 623 const char* f2_source = "function f2(x, y) { return x[y]; };"; |
620 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; | 624 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
621 | 625 |
622 { | 626 { |
623 AllowNativesSyntaxNoInlining options; | 627 AllowNativesSyntaxNoInliningNoParallel options; |
624 // Compile functions and collect to type feedback to insert ic | 628 // Compile functions and collect to type feedback to insert ic |
625 // calls in the optimized code. | 629 // calls in the optimized code. |
626 i::FLAG_prepare_always_opt = true; | 630 i::FLAG_prepare_always_opt = true; |
627 CompileRun("var count = 0;" | 631 CompileRun("var count = 0;" |
628 "var result = 0;" | 632 "var result = 0;" |
629 "var deopt = false;" | 633 "var deopt = false;" |
630 "function X() { };" | 634 "function X() { };" |
631 "X.prototype.__defineGetter__('y', function () {" | 635 "X.prototype.__defineGetter__('y', function () {" |
632 " g1(this);" | 636 " g1(this);" |
633 " return 13;" | 637 " return 13;" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 NonIncrementalGC(); | 685 NonIncrementalGC(); |
682 | 686 |
683 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); | 687 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
684 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); | 688 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
685 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); | 689 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
686 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); | 690 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
687 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 691 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
688 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); | 692 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
689 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 693 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
690 } | 694 } |
OLD | NEW |