| 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 <sstream> |      5 #include <sstream> | 
|      6  |      6  | 
|      7 #include "src/v8.h" |      7 #include "src/v8.h" | 
|      8  |      8  | 
|      9 #include "src/accessors.h" |      9 #include "src/accessors.h" | 
|     10 #include "src/allocation-site-scopes.h" |     10 #include "src/allocation-site-scopes.h" | 
| (...skipping 8746 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   8757 } |   8757 } | 
|   8758  |   8758  | 
|   8759  |   8759  | 
|   8760  |   8760  | 
|   8761 template <typename SourceChar> |   8761 template <typename SourceChar> | 
|   8762 static void CalculateLineEndsImpl(Isolate* isolate, |   8762 static void CalculateLineEndsImpl(Isolate* isolate, | 
|   8763                                   List<int>* line_ends, |   8763                                   List<int>* line_ends, | 
|   8764                                   Vector<const SourceChar> src, |   8764                                   Vector<const SourceChar> src, | 
|   8765                                   bool include_ending_line) { |   8765                                   bool include_ending_line) { | 
|   8766   const int src_len = src.length(); |   8766   const int src_len = src.length(); | 
|   8767   StringSearch<uint8_t, SourceChar> search(isolate, STATIC_CHAR_VECTOR("\n")); |   8767   UnicodeCache* cache = isolate->unicode_cache(); | 
 |   8768   for (int i = 0; i < src_len - 1; i++) { | 
 |   8769     SourceChar current = src[i]; | 
 |   8770     SourceChar next = src[i + 1]; | 
 |   8771     if (cache->IsLineTerminatorSequence(current, next)) line_ends->Add(i); | 
 |   8772   } | 
|   8768  |   8773  | 
|   8769   // Find and record line ends. |   8774   if (src_len > 0 && cache->IsLineTerminatorSequence(src[src_len - 1], 0)) { | 
|   8770   int position = 0; |   8775     line_ends->Add(src_len - 1); | 
|   8771   while (position != -1 && position < src_len) { |   8776   } else if (include_ending_line) { | 
|   8772     position = search.Search(src, position); |   8777     // Even if the last line misses a line end, it is counted. | 
|   8773     if (position != -1) { |   8778     line_ends->Add(src_len); | 
|   8774       line_ends->Add(position); |  | 
|   8775       position++; |  | 
|   8776     } else if (include_ending_line) { |  | 
|   8777       // Even if the last line misses a line end, it is counted. |  | 
|   8778       line_ends->Add(src_len); |  | 
|   8779       return; |  | 
|   8780     } |  | 
|   8781   } |   8779   } | 
|   8782 } |   8780 } | 
|   8783  |   8781  | 
|   8784  |   8782  | 
|   8785 Handle<FixedArray> String::CalculateLineEnds(Handle<String> src, |   8783 Handle<FixedArray> String::CalculateLineEnds(Handle<String> src, | 
|   8786                                              bool include_ending_line) { |   8784                                              bool include_ending_line) { | 
|   8787   src = Flatten(src); |   8785   src = Flatten(src); | 
|   8788   // Rough estimate of line count based on a roughly estimated average |   8786   // Rough estimate of line count based on a roughly estimated average | 
|   8789   // length of (unpacked) code. |   8787   // length of (unpacked) code. | 
|   8790   int line_count_estimate = src->length() >> 4; |   8788   int line_count_estimate = src->length() >> 4; | 
| (...skipping 8042 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  16833   Handle<DependentCode> codes = |  16831   Handle<DependentCode> codes = | 
|  16834       DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |  16832       DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 
|  16835                             DependentCode::kPropertyCellChangedGroup, |  16833                             DependentCode::kPropertyCellChangedGroup, | 
|  16836                             info->object_wrapper()); |  16834                             info->object_wrapper()); | 
|  16837   if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |  16835   if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 
|  16838   info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |  16836   info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 
|  16839       cell, info->zone()); |  16837       cell, info->zone()); | 
|  16840 } |  16838 } | 
|  16841  |  16839  | 
|  16842 } }  // namespace v8::internal |  16840 } }  // namespace v8::internal | 
| OLD | NEW |