| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 "morphing_call = builder();"); | 354 "morphing_call = builder();"); |
| 355 | 355 |
| 356 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 356 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 357 *v8::Local<v8::Function>::Cast(CcTest::global() | 357 *v8::Local<v8::Function>::Cast(CcTest::global() |
| 358 ->Get(context, v8_str("morphing_call")) | 358 ->Get(context, v8_str("morphing_call")) |
| 359 .ToLocalChecked()))); | 359 .ToLocalChecked()))); |
| 360 | 360 |
| 361 // If we are compiling lazily then it should not be compiled, and so no | 361 // If we are compiling lazily then it should not be compiled, and so no |
| 362 // feedback vector allocated yet. | 362 // feedback vector allocated yet. |
| 363 CHECK(!f->shared()->is_compiled()); | 363 CHECK(!f->shared()->is_compiled()); |
| 364 CHECK(f->feedback_vector()->is_empty()); | |
| 365 | 364 |
| 366 CompileRun("morphing_call();"); | 365 CompileRun("morphing_call();"); |
| 367 | 366 |
| 368 // Now a feedback vector is allocated. | 367 // Now a feedback vector is allocated. |
| 369 CHECK(f->shared()->is_compiled()); | 368 CHECK(f->shared()->is_compiled()); |
| 370 CHECK(!f->feedback_vector()->is_empty()); | 369 CHECK(!f->feedback_vector()->is_empty()); |
| 371 } | 370 } |
| 372 | 371 |
| 373 // Test that optimized code for different closures is actually shared. | 372 // Test that optimized code for different closures is actually shared. |
| 374 TEST(OptimizedCodeSharing1) { | 373 TEST(OptimizedCodeSharing1) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 CompileRun("foo()"); | 666 CompileRun("foo()"); |
| 668 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); | 667 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
| 669 CompileRun("bar()"); | 668 CompileRun("bar()"); |
| 670 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); | 669 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
| 671 CompileRun("foo(); foo()"); | 670 CompileRun("foo(); foo()"); |
| 672 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); | 671 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); |
| 673 CompileRun("%BaselineFunctionOnNextCall(foo);"); | 672 CompileRun("%BaselineFunctionOnNextCall(foo);"); |
| 674 CompileRun("foo();"); | 673 CompileRun("foo();"); |
| 675 CHECK_EQ(5, foo->feedback_vector()->invocation_count()); | 674 CHECK_EQ(5, foo->feedback_vector()->invocation_count()); |
| 676 } | 675 } |
| OLD | NEW |