OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 6803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6814 start_position = shared->start_position(); | 6814 start_position = shared->start_position(); |
6815 } | 6815 } |
6816 if (start_position <= position && | 6816 if (start_position <= position && |
6817 position <= shared->end_position()) { | 6817 position <= shared->end_position()) { |
6818 // If there is no candidate or this function is within the current | 6818 // If there is no candidate or this function is within the current |
6819 // candidate this is the new candidate. | 6819 // candidate this is the new candidate. |
6820 if (target.is_null()) { | 6820 if (target.is_null()) { |
6821 target_start_position = start_position; | 6821 target_start_position = start_position; |
6822 target = shared; | 6822 target = shared; |
6823 } else { | 6823 } else { |
6824 if (target_start_position < start_position && | 6824 if (target_start_position == start_position && |
6825 shared->end_position() < target->end_position()) { | 6825 shared->end_position() == target->end_position()) { |
| 6826 // If a top-level function contain only one function |
| 6827 // declartion the source for the top-level and the function is |
| 6828 // the same. In that case prefer the non top-level function. |
| 6829 if (!shared->is_toplevel()) { |
| 6830 target_start_position = start_position; |
| 6831 target = shared; |
| 6832 } |
| 6833 } else if (target_start_position <= start_position && |
| 6834 shared->end_position() <= target->end_position()) { |
| 6835 // This containment check includes equality as a function inside |
| 6836 // a top-level function can share either start or end position |
| 6837 // with the top-level function. |
6826 target_start_position = start_position; | 6838 target_start_position = start_position; |
6827 target = shared; | 6839 target = shared; |
6828 } | 6840 } |
6829 } | 6841 } |
6830 } | 6842 } |
6831 | 6843 |
6832 // Keep track of the last function in the script. | 6844 // Keep track of the last function in the script. |
6833 if (last.is_null() || | 6845 if (last.is_null() || |
6834 shared->end_position() > last->start_position()) { | 6846 shared->end_position() > last->start_position()) { |
6835 last = shared; | 6847 last = shared; |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7697 } else { | 7709 } else { |
7698 // Handle last resort GC and make sure to allow future allocations | 7710 // Handle last resort GC and make sure to allow future allocations |
7699 // to grow the heap without causing GCs (if possible). | 7711 // to grow the heap without causing GCs (if possible). |
7700 Counters::gc_last_resort_from_js.Increment(); | 7712 Counters::gc_last_resort_from_js.Increment(); |
7701 Heap::CollectAllGarbage(false); | 7713 Heap::CollectAllGarbage(false); |
7702 } | 7714 } |
7703 } | 7715 } |
7704 | 7716 |
7705 | 7717 |
7706 } } // namespace v8::internal | 7718 } } // namespace v8::internal |
OLD | NEW |