Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: src/handles.cc

Issue 11818025: Continues Latin-1 support. All tests pass with ENABLE_LATIN_1 flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ARM fix Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 ASSERT(script->line_ends()->IsFixedArray()); 416 ASSERT(script->line_ends()->IsFixedArray());
417 } 417 }
418 418
419 419
420 template <typename SourceChar> 420 template <typename SourceChar>
421 static void CalculateLineEnds(Isolate* isolate, 421 static void CalculateLineEnds(Isolate* isolate,
422 List<int>* line_ends, 422 List<int>* line_ends,
423 Vector<const SourceChar> src, 423 Vector<const SourceChar> src,
424 bool with_last_line) { 424 bool with_last_line) {
425 const int src_len = src.length(); 425 const int src_len = src.length();
426 StringSearch<char, SourceChar> search(isolate, CStrVector("\n")); 426 StringSearch<uint8_t, SourceChar> search(isolate, STATIC_ASCII_VECTOR("\n"));
427 427
428 // Find and record line ends. 428 // Find and record line ends.
429 int position = 0; 429 int position = 0;
430 while (position != -1 && position < src_len) { 430 while (position != -1 && position < src_len) {
431 position = search.Search(src, position); 431 position = search.Search(src, position);
432 if (position != -1) { 432 if (position != -1) {
433 line_ends->Add(position); 433 line_ends->Add(position);
434 position++; 434 position++;
435 } else if (with_last_line) { 435 } else if (with_last_line) {
436 // Even if the last line misses a line end, it is counted. 436 // Even if the last line misses a line end, it is counted.
(...skipping 13 matching lines...) Expand all
450 List<int> line_ends(line_count_estimate); 450 List<int> line_ends(line_count_estimate);
451 Isolate* isolate = src->GetIsolate(); 451 Isolate* isolate = src->GetIsolate();
452 { 452 {
453 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid. 453 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid.
454 // Dispatch on type of strings. 454 // Dispatch on type of strings.
455 String::FlatContent content = src->GetFlatContent(); 455 String::FlatContent content = src->GetFlatContent();
456 ASSERT(content.IsFlat()); 456 ASSERT(content.IsFlat());
457 if (content.IsAscii()) { 457 if (content.IsAscii()) {
458 CalculateLineEnds(isolate, 458 CalculateLineEnds(isolate,
459 &line_ends, 459 &line_ends,
460 content.ToAsciiVector(), 460 content.ToOneByteVector(),
461 with_last_line); 461 with_last_line);
462 } else { 462 } else {
463 CalculateLineEnds(isolate, 463 CalculateLineEnds(isolate,
464 &line_ends, 464 &line_ends,
465 content.ToUC16Vector(), 465 content.ToUC16Vector(),
466 with_last_line); 466 with_last_line);
467 } 467 }
468 } 468 }
469 int line_count = line_ends.length(); 469 int line_count = line_ends.length();
470 Handle<FixedArray> array = isolate->factory()->NewFixedArray(line_count); 470 Handle<FixedArray> array = isolate->factory()->NewFixedArray(line_count);
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 data->next = prev_next_; 919 data->next = prev_next_;
920 data->limit = prev_limit_; 920 data->limit = prev_limit_;
921 #ifdef DEBUG 921 #ifdef DEBUG
922 handles_detached_ = true; 922 handles_detached_ = true;
923 #endif 923 #endif
924 return deferred; 924 return deferred;
925 } 925 }
926 926
927 927
928 } } // namespace v8::internal 928 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/extensions/externalize-string-extension.cc ('k') | src/heap.cc » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698