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 9063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9074 // for the requested break point is found. | 9074 // for the requested break point is found. |
9075 // NOTE: This might reqire several heap iterations. If the SharedFunctionInfo | 9075 // NOTE: This might reqire several heap iterations. If the SharedFunctionInfo |
9076 // which is found is not compiled it is compiled and the heap is iterated | 9076 // which is found is not compiled it is compiled and the heap is iterated |
9077 // again as the compilation might create inner functions from the newly | 9077 // again as the compilation might create inner functions from the newly |
9078 // compiled function and the actual requested break point might be in one of | 9078 // compiled function and the actual requested break point might be in one of |
9079 // these functions. | 9079 // these functions. |
9080 bool done = false; | 9080 bool done = false; |
9081 // The current candidate for the source position: | 9081 // The current candidate for the source position: |
9082 int target_start_position = RelocInfo::kNoPosition; | 9082 int target_start_position = RelocInfo::kNoPosition; |
9083 Handle<SharedFunctionInfo> target; | 9083 Handle<SharedFunctionInfo> target; |
9084 // The current candidate for the last function in script: | |
9085 Handle<SharedFunctionInfo> last; | |
9086 while (!done) { | 9084 while (!done) { |
9087 HeapIterator iterator; | 9085 HeapIterator iterator; |
9088 for (HeapObject* obj = iterator.next(); | 9086 for (HeapObject* obj = iterator.next(); |
9089 obj != NULL; obj = iterator.next()) { | 9087 obj != NULL; obj = iterator.next()) { |
9090 if (obj->IsSharedFunctionInfo()) { | 9088 if (obj->IsSharedFunctionInfo()) { |
9091 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(obj)); | 9089 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(obj)); |
9092 if (shared->script() == *script) { | 9090 if (shared->script() == *script) { |
9093 // If the SharedFunctionInfo found has the requested script data and | 9091 // If the SharedFunctionInfo found has the requested script data and |
9094 // contains the source position it is a candidate. | 9092 // contains the source position it is a candidate. |
9095 int start_position = shared->function_token_position(); | 9093 int start_position = shared->function_token_position(); |
(...skipping 20 matching lines...) Expand all Loading... |
9116 } else if (target_start_position <= start_position && | 9114 } else if (target_start_position <= start_position && |
9117 shared->end_position() <= target->end_position()) { | 9115 shared->end_position() <= target->end_position()) { |
9118 // This containment check includes equality as a function inside | 9116 // This containment check includes equality as a function inside |
9119 // a top-level function can share either start or end position | 9117 // a top-level function can share either start or end position |
9120 // with the top-level function. | 9118 // with the top-level function. |
9121 target_start_position = start_position; | 9119 target_start_position = start_position; |
9122 target = shared; | 9120 target = shared; |
9123 } | 9121 } |
9124 } | 9122 } |
9125 } | 9123 } |
9126 | |
9127 // Keep track of the last function in the script. | |
9128 if (last.is_null() || | |
9129 shared->end_position() > last->start_position()) { | |
9130 last = shared; | |
9131 } | |
9132 } | 9124 } |
9133 } | 9125 } |
9134 } | 9126 } |
9135 | 9127 |
9136 // Make sure some candidate is selected. | |
9137 if (target.is_null()) { | 9128 if (target.is_null()) { |
9138 if (!last.is_null()) { | 9129 return Heap::undefined_value(); |
9139 // Position after the last function - use last. | |
9140 target = last; | |
9141 } else { | |
9142 // Unable to find function - possibly script without any function. | |
9143 return Heap::undefined_value(); | |
9144 } | |
9145 } | 9130 } |
9146 | 9131 |
9147 // If the candidate found is compiled we are done. NOTE: when lazy | 9132 // If the candidate found is compiled we are done. NOTE: when lazy |
9148 // compilation of inner functions is introduced some additional checking | 9133 // compilation of inner functions is introduced some additional checking |
9149 // needs to be done here to compile inner functions. | 9134 // needs to be done here to compile inner functions. |
9150 done = target->is_compiled(); | 9135 done = target->is_compiled(); |
9151 if (!done) { | 9136 if (!done) { |
9152 // If the candidate is not compiled compile it to reveal any inner | 9137 // If the candidate is not compiled compile it to reveal any inner |
9153 // functions which might contain the requested source position. | 9138 // functions which might contain the requested source position. |
9154 CompileLazyShared(target, KEEP_EXCEPTION); | 9139 CompileLazyShared(target, KEEP_EXCEPTION); |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10394 } else { | 10379 } else { |
10395 // Handle last resort GC and make sure to allow future allocations | 10380 // Handle last resort GC and make sure to allow future allocations |
10396 // to grow the heap without causing GCs (if possible). | 10381 // to grow the heap without causing GCs (if possible). |
10397 Counters::gc_last_resort_from_js.Increment(); | 10382 Counters::gc_last_resort_from_js.Increment(); |
10398 Heap::CollectAllGarbage(false); | 10383 Heap::CollectAllGarbage(false); |
10399 } | 10384 } |
10400 } | 10385 } |
10401 | 10386 |
10402 | 10387 |
10403 } } // namespace v8::internal | 10388 } } // namespace v8::internal |
OLD | NEW |