OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 11336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11347 const int src_len = src.length(); | 11347 const int src_len = src.length(); |
11348 UnicodeCache* cache = isolate->unicode_cache(); | 11348 UnicodeCache* cache = isolate->unicode_cache(); |
11349 for (int i = 0; i < src_len - 1; i++) { | 11349 for (int i = 0; i < src_len - 1; i++) { |
11350 SourceChar current = src[i]; | 11350 SourceChar current = src[i]; |
11351 SourceChar next = src[i + 1]; | 11351 SourceChar next = src[i + 1]; |
11352 if (cache->IsLineTerminatorSequence(current, next)) line_ends->Add(i); | 11352 if (cache->IsLineTerminatorSequence(current, next)) line_ends->Add(i); |
11353 } | 11353 } |
11354 | 11354 |
11355 if (src_len > 0 && cache->IsLineTerminatorSequence(src[src_len - 1], 0)) { | 11355 if (src_len > 0 && cache->IsLineTerminatorSequence(src[src_len - 1], 0)) { |
11356 line_ends->Add(src_len - 1); | 11356 line_ends->Add(src_len - 1); |
11357 } else if (include_ending_line) { | 11357 } |
11358 // Even if the last line misses a line end, it is counted. | 11358 if (include_ending_line) { |
| 11359 // Include one character beyond the end of script. The rewriter uses that |
| 11360 // position for the implicit return statement. |
11359 line_ends->Add(src_len); | 11361 line_ends->Add(src_len); |
11360 } | 11362 } |
11361 } | 11363 } |
11362 | 11364 |
11363 | 11365 |
11364 Handle<FixedArray> String::CalculateLineEnds(Handle<String> src, | 11366 Handle<FixedArray> String::CalculateLineEnds(Handle<String> src, |
11365 bool include_ending_line) { | 11367 bool include_ending_line) { |
11366 src = Flatten(src); | 11368 src = Flatten(src); |
11367 // Rough estimate of line count based on a roughly estimated average | 11369 // Rough estimate of line count based on a roughly estimated average |
11368 // length of (unpacked) code. | 11370 // length of (unpacked) code. |
(...skipping 7914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19283 if (cell->value() != *new_value) { | 19285 if (cell->value() != *new_value) { |
19284 cell->set_value(*new_value); | 19286 cell->set_value(*new_value); |
19285 Isolate* isolate = cell->GetIsolate(); | 19287 Isolate* isolate = cell->GetIsolate(); |
19286 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19288 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19287 isolate, DependentCode::kPropertyCellChangedGroup); | 19289 isolate, DependentCode::kPropertyCellChangedGroup); |
19288 } | 19290 } |
19289 } | 19291 } |
19290 | 19292 |
19291 } // namespace internal | 19293 } // namespace internal |
19292 } // namespace v8 | 19294 } // namespace v8 |
OLD | NEW |