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 11334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11345 Vector<const SourceChar> src, | 11345 Vector<const SourceChar> src, |
11346 bool include_ending_line) { | 11346 bool include_ending_line) { |
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 (include_ending_line) { | 11355 if (src_len > 0 && cache->IsLineTerminatorSequence(src[src_len - 1], 0)) { |
11356 // Include one character beyond the end of script. The rewriter uses that | 11356 line_ends->Add(src_len - 1); |
11357 // position for the implicit return statement. | 11357 } else if (include_ending_line) { |
| 11358 // Even if the last line misses a line end, it is counted. |
11358 line_ends->Add(src_len); | 11359 line_ends->Add(src_len); |
11359 } else if (src_len > 0 && | |
11360 cache->IsLineTerminatorSequence(src[src_len - 1], 0)) { | |
11361 line_ends->Add(src_len - 1); | |
11362 } | 11360 } |
11363 } | 11361 } |
11364 | 11362 |
11365 | 11363 |
11366 Handle<FixedArray> String::CalculateLineEnds(Handle<String> src, | 11364 Handle<FixedArray> String::CalculateLineEnds(Handle<String> src, |
11367 bool include_ending_line) { | 11365 bool include_ending_line) { |
11368 src = Flatten(src); | 11366 src = Flatten(src); |
11369 // Rough estimate of line count based on a roughly estimated average | 11367 // Rough estimate of line count based on a roughly estimated average |
11370 // length of (unpacked) code. | 11368 // length of (unpacked) code. |
11371 int line_count_estimate = src->length() >> 4; | 11369 int line_count_estimate = src->length() >> 4; |
(...skipping 7913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19285 if (cell->value() != *new_value) { | 19283 if (cell->value() != *new_value) { |
19286 cell->set_value(*new_value); | 19284 cell->set_value(*new_value); |
19287 Isolate* isolate = cell->GetIsolate(); | 19285 Isolate* isolate = cell->GetIsolate(); |
19288 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19286 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19289 isolate, DependentCode::kPropertyCellChangedGroup); | 19287 isolate, DependentCode::kPropertyCellChangedGroup); |
19290 } | 19288 } |
19291 } | 19289 } |
19292 | 19290 |
19293 } // namespace internal | 19291 } // namespace internal |
19294 } // namespace v8 | 19292 } // namespace v8 |
OLD | NEW |