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

Side by Side Diff: src/handles.cc

Issue 5167002: Revert r5846 because of debug mode test failures. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 18 matching lines...) Expand all
29 29
30 #include "accessors.h" 30 #include "accessors.h"
31 #include "api.h" 31 #include "api.h"
32 #include "arguments.h" 32 #include "arguments.h"
33 #include "bootstrapper.h" 33 #include "bootstrapper.h"
34 #include "compiler.h" 34 #include "compiler.h"
35 #include "debug.h" 35 #include "debug.h"
36 #include "execution.h" 36 #include "execution.h"
37 #include "global-handles.h" 37 #include "global-handles.h"
38 #include "natives.h" 38 #include "natives.h"
39 #include "string-search.h"
40 #include "runtime.h" 39 #include "runtime.h"
41 #include "stub-cache.h" 40 #include "stub-cache.h"
42 41
43 namespace v8 { 42 namespace v8 {
44 namespace internal { 43 namespace internal {
45 44
46 45
47 v8::ImplementationUtilities::HandleScopeData HandleScope::current_ = 46 v8::ImplementationUtilities::HandleScopeData HandleScope::current_ =
48 { NULL, NULL, 0 }; 47 { NULL, NULL, 0 };
49 48
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 501
503 if (*array != Heap::empty_fixed_array()) { 502 if (*array != Heap::empty_fixed_array()) {
504 array->set_map(Heap::fixed_cow_array_map()); 503 array->set_map(Heap::fixed_cow_array_map());
505 } 504 }
506 505
507 script->set_line_ends(*array); 506 script->set_line_ends(*array);
508 ASSERT(script->line_ends()->IsFixedArray()); 507 ASSERT(script->line_ends()->IsFixedArray());
509 } 508 }
510 509
511 510
512 template <typename SourceChar> 511 Handle<FixedArray> CalculateLineEnds(Handle<String> src,
513 static Handle<FixedArray> CalculateLineEnds(Vector<const SourceChar> src, 512 bool with_imaginary_last_new_line) {
514 bool with_last_line) { 513 const int src_len = src->length();
515 const int src_len = src.length(); 514 Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n"));
516 StringSearch<char, SourceChar> search(CStrVector("\n"));
517 515
518 // Pass 1: Identify line count. 516 // Pass 1: Identify line count.
519 int line_count = 0; 517 int line_count = 0;
520 int position = 0; 518 int position = 0;
521 while (position != -1 && position < src_len) { 519 while (position != -1 && position < src_len) {
522 position = search.Search(src, position); 520 position = Runtime::StringMatch(src, new_line, position);
523 if (position != -1) { 521 if (position != -1) {
524 position++; 522 position++;
523 }
524 if (position != -1) {
525 line_count++; 525 line_count++;
526 } else if (with_last_line) { 526 } else if (with_imaginary_last_new_line) {
527 // Even if the last line misses a line end, it is counted. 527 // Even if the last line misses a line end, it is counted.
528 line_count++; 528 line_count++;
529 } 529 }
530 } 530 }
531 531
532 // Pass 2: Fill in line ends positions 532 // Pass 2: Fill in line ends positions
533 Handle<FixedArray> array = Factory::NewFixedArray(line_count); 533 Handle<FixedArray> array = Factory::NewFixedArray(line_count);
534 int array_index = 0; 534 int array_index = 0;
535 position = 0; 535 position = 0;
536 while (position != -1 && position < src_len) { 536 while (position != -1 && position < src_len) {
537 position = search.Search(src, position); 537 position = Runtime::StringMatch(src, new_line, position);
538 if (position != -1) { 538 if (position != -1) {
539 array->set(array_index++, Smi::FromInt(position++)); 539 array->set(array_index++, Smi::FromInt(position++));
540 } else if (with_last_line) { 540 } else if (with_imaginary_last_new_line) {
541 // If the script does not end with a line ending add the final end 541 // If the script does not end with a line ending add the final end
542 // position as just past the last line ending. 542 // position as just past the last line ending.
543 array->set(array_index++, Smi::FromInt(src_len)); 543 array->set(array_index++, Smi::FromInt(src_len));
544 } 544 }
545 } 545 }
546 ASSERT(array_index == line_count); 546 ASSERT(array_index == line_count);
547 547
548 return array; 548 return array;
549 } 549 }
550 550
551 Handle<FixedArray> CalculateLineEnds(Handle<String> src,
552 bool with_last_line) {
553 if (!src->IsFlat()) FlattenString(src);
554 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid
555 // Extract flattened substring of cons string before determining asciiness.
556 String* seq_src = *src;
557 if (seq_src->IsConsString()) seq_src = ConsString::cast(seq_src)->first();
558 // Dispatch on type of strings.
559 if (seq_src->IsAsciiRepresentation()) {
560 return CalculateLineEnds(seq_src->ToAsciiVector(), with_last_line);
561 }
562 return CalculateLineEnds(seq_src->ToUC16Vector(), with_last_line);
563 }
564
565 551
566 // Convert code position into line number. 552 // Convert code position into line number.
567 int GetScriptLineNumber(Handle<Script> script, int code_pos) { 553 int GetScriptLineNumber(Handle<Script> script, int code_pos) {
568 InitScriptLineEnds(script); 554 InitScriptLineEnds(script);
569 AssertNoAllocation no_allocation; 555 AssertNoAllocation no_allocation;
570 FixedArray* line_ends_array = FixedArray::cast(script->line_ends()); 556 FixedArray* line_ends_array = FixedArray::cast(script->line_ends());
571 const int line_ends_len = line_ends_array->length(); 557 const int line_ends_len = line_ends_array->length();
572 558
573 if (!line_ends_len) 559 if (!line_ends_len)
574 return -1; 560 return -1;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 868
883 OptimizedObjectForAddingMultipleProperties:: 869 OptimizedObjectForAddingMultipleProperties::
884 ~OptimizedObjectForAddingMultipleProperties() { 870 ~OptimizedObjectForAddingMultipleProperties() {
885 // Reoptimize the object to allow fast property access. 871 // Reoptimize the object to allow fast property access.
886 if (has_been_transformed_) { 872 if (has_been_transformed_) {
887 TransformToFastProperties(object_, unused_property_fields_); 873 TransformToFastProperties(object_, unused_property_fields_);
888 } 874 }
889 } 875 }
890 876
891 } } // namespace v8::internal 877 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698