| 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 4748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4759 Isolate* isolate = CcTest::i_isolate(); | 4759 Isolate* isolate = CcTest::i_isolate(); |
| 4760 v8::internal::Heap* heap = CcTest::heap(); | 4760 v8::internal::Heap* heap = CcTest::heap(); |
| 4761 | 4761 |
| 4762 if (!isolate->use_crankshaft()) return; | 4762 if (!isolate->use_crankshaft()) return; |
| 4763 HandleScope outer_scope(heap->isolate()); | 4763 HandleScope outer_scope(heap->isolate()); |
| 4764 Handle<Code> code; | 4764 Handle<Code> code; |
| 4765 { | 4765 { |
| 4766 LocalContext context; | 4766 LocalContext context; |
| 4767 HandleScope scope(heap->isolate()); | 4767 HandleScope scope(heap->isolate()); |
| 4768 | 4768 |
| 4769 CompileRun("bar = (function() {" | 4769 CompileRun( |
| 4770 " function bar() {" | 4770 "bar = (function() {" |
| 4771 " return foo(1);" | 4771 " function bar() {" |
| 4772 " };" | 4772 " return foo(1);" |
| 4773 " var foo = function(x) { with (x) { return 1 + x; } };" | 4773 " };" |
| 4774 " bar(foo);" | 4774 " var foo = function(x) { with (x) { return 1 + x; } };" |
| 4775 " bar(foo);" | 4775 " %NeverOptimizeFunction(foo);" |
| 4776 " bar(foo);" | 4776 " bar(foo);" |
| 4777 " %OptimizeFunctionOnNextCall(bar);" | 4777 " bar(foo);" |
| 4778 " bar(foo);" | 4778 " bar(foo);" |
| 4779 " return bar;})();"); | 4779 " %OptimizeFunctionOnNextCall(bar);" |
| 4780 " bar(foo);" |
| 4781 " return bar;})();"); |
| 4780 | 4782 |
| 4781 Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 4783 Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4782 *v8::Local<v8::Function>::Cast(CcTest::global() | 4784 *v8::Local<v8::Function>::Cast(CcTest::global() |
| 4783 ->Get(context.local(), v8_str("bar")) | 4785 ->Get(context.local(), v8_str("bar")) |
| 4784 .ToLocalChecked()))); | 4786 .ToLocalChecked()))); |
| 4785 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 4787 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
| 4786 } | 4788 } |
| 4787 | 4789 |
| 4788 // Now make sure that a gc should get rid of the function | 4790 // Now make sure that a gc should get rid of the function |
| 4789 for (int i = 0; i < 4; i++) { | 4791 for (int i = 0; i < 4; i++) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4802 Isolate* isolate = CcTest::i_isolate(); | 4804 Isolate* isolate = CcTest::i_isolate(); |
| 4803 v8::internal::Heap* heap = CcTest::heap(); | 4805 v8::internal::Heap* heap = CcTest::heap(); |
| 4804 | 4806 |
| 4805 if (!isolate->use_crankshaft()) return; | 4807 if (!isolate->use_crankshaft()) return; |
| 4806 HandleScope outer_scope(heap->isolate()); | 4808 HandleScope outer_scope(heap->isolate()); |
| 4807 Handle<Code> code; | 4809 Handle<Code> code; |
| 4808 { | 4810 { |
| 4809 LocalContext context; | 4811 LocalContext context; |
| 4810 HandleScope scope(heap->isolate()); | 4812 HandleScope scope(heap->isolate()); |
| 4811 | 4813 |
| 4812 CompileRun("function bar() {" | 4814 CompileRun( |
| 4813 " return foo(1);" | 4815 "function bar() {" |
| 4814 "};" | 4816 " return foo(1);" |
| 4815 "function foo(x) { with (x) { return 1 + x; } };" | 4817 "};" |
| 4816 "bar();" | 4818 "function foo(x) { with (x) { return 1 + x; } };" |
| 4817 "bar();" | 4819 "%NeverOptimizeFunction(foo);" |
| 4818 "bar();" | 4820 "bar();" |
| 4819 "%OptimizeFunctionOnNextCall(bar);" | 4821 "bar();" |
| 4820 "bar();"); | 4822 "bar();" |
| 4823 "%OptimizeFunctionOnNextCall(bar);" |
| 4824 "bar();"); |
| 4821 | 4825 |
| 4822 Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 4826 Handle<JSFunction> bar = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 4823 *v8::Local<v8::Function>::Cast(CcTest::global() | 4827 *v8::Local<v8::Function>::Cast(CcTest::global() |
| 4824 ->Get(context.local(), v8_str("bar")) | 4828 ->Get(context.local(), v8_str("bar")) |
| 4825 .ToLocalChecked()))); | 4829 .ToLocalChecked()))); |
| 4826 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 4830 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
| 4827 } | 4831 } |
| 4828 | 4832 |
| 4829 // Now make sure that a gc should get rid of the function | 4833 // Now make sure that a gc should get rid of the function |
| 4830 for (int i = 0; i < 4; i++) { | 4834 for (int i = 0; i < 4; i++) { |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6453 isolate->IncrementJsCallsFromApiCounter(); | 6457 isolate->IncrementJsCallsFromApiCounter(); |
| 6454 isolate->IncrementJsCallsFromApiCounter(); | 6458 isolate->IncrementJsCallsFromApiCounter(); |
| 6455 isolate->IncrementJsCallsFromApiCounter(); | 6459 isolate->IncrementJsCallsFromApiCounter(); |
| 6456 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 6460 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); |
| 6457 CheckDoubleEquals(2, calls_per_ms); | 6461 CheckDoubleEquals(2, calls_per_ms); |
| 6458 } | 6462 } |
| 6459 | 6463 |
| 6460 | 6464 |
| 6461 } // namespace internal | 6465 } // namespace internal |
| 6462 } // namespace v8 | 6466 } // namespace v8 |
| OLD | NEW |