OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 4129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4140 // source for this function is found. | 4140 // source for this function is found. |
4141 int Code::SourcePosition(Address pc) { | 4141 int Code::SourcePosition(Address pc) { |
4142 int distance = kMaxInt; | 4142 int distance = kMaxInt; |
4143 int position = kNoPosition; // Initially no position found. | 4143 int position = kNoPosition; // Initially no position found. |
4144 // Run through all the relocation info to find the best matching source | 4144 // Run through all the relocation info to find the best matching source |
4145 // position. All the code needs to be considered as the sequence of the | 4145 // position. All the code needs to be considered as the sequence of the |
4146 // instructions in the code does not necessarily follow the same order as the | 4146 // instructions in the code does not necessarily follow the same order as the |
4147 // source. | 4147 // source. |
4148 RelocIterator it(this, RelocInfo::kPositionMask); | 4148 RelocIterator it(this, RelocInfo::kPositionMask); |
4149 while (!it.done()) { | 4149 while (!it.done()) { |
4150 if (it.rinfo()->pc() < pc && (pc - it.rinfo()->pc()) < distance) { | 4150 // Only look at positions after the current pc. |
4151 position = it.rinfo()->data(); | 4151 if (it.rinfo()->pc() < pc) { |
4152 distance = pc - it.rinfo()->pc(); | 4152 // Get position and distance. |
| 4153 int dist = pc - it.rinfo()->pc(); |
| 4154 int pos = it.rinfo()->data(); |
| 4155 // If this position is closer than the current candidate or if it has the |
| 4156 // same distance as the current candidate and the position is higher then |
| 4157 // this position is the new candidate. |
| 4158 if ((dist < distance) || |
| 4159 (dist == distance && pos > position)) { |
| 4160 position = pos; |
| 4161 distance = dist; |
| 4162 } |
4153 } | 4163 } |
4154 it.next(); | 4164 it.next(); |
4155 } | 4165 } |
4156 return position; | 4166 return position; |
4157 } | 4167 } |
4158 | 4168 |
4159 | 4169 |
4160 // Same as Code::SourcePosition above except it only looks for statement | 4170 // Same as Code::SourcePosition above except it only looks for statement |
4161 // positions. | 4171 // positions. |
4162 int Code::SourceStatementPosition(Address pc) { | 4172 int Code::SourceStatementPosition(Address pc) { |
(...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6278 // No break point. | 6288 // No break point. |
6279 if (break_point_objects()->IsUndefined()) return 0; | 6289 if (break_point_objects()->IsUndefined()) return 0; |
6280 // Single beak point. | 6290 // Single beak point. |
6281 if (!break_point_objects()->IsFixedArray()) return 1; | 6291 if (!break_point_objects()->IsFixedArray()) return 1; |
6282 // Multiple break points. | 6292 // Multiple break points. |
6283 return FixedArray::cast(break_point_objects())->length(); | 6293 return FixedArray::cast(break_point_objects())->length(); |
6284 } | 6294 } |
6285 | 6295 |
6286 | 6296 |
6287 } } // namespace v8::internal | 6297 } } // namespace v8::internal |
OLD | NEW |