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 5148002: Store script's line ends in copy-on-write fixed array. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address problems with empty fixed array 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 | « src/accessors.cc ('k') | 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 Handle<FixedArray> empty = Factory::NewFixedArray(0); 492 Handle<FixedArray> empty = Factory::NewFixedArray(0);
493 script->set_line_ends(*empty); 493 script->set_line_ends(*empty);
494 ASSERT(script->line_ends()->IsFixedArray()); 494 ASSERT(script->line_ends()->IsFixedArray());
495 return; 495 return;
496 } 496 }
497 497
498 Handle<String> src(String::cast(script->source())); 498 Handle<String> src(String::cast(script->source()));
499 499
500 Handle<FixedArray> array = CalculateLineEnds(src, true); 500 Handle<FixedArray> array = CalculateLineEnds(src, true);
501 501
502 if (*array != Heap::empty_fixed_array()) {
503 array->set_map(Heap::fixed_cow_array_map());
504 }
505
502 script->set_line_ends(*array); 506 script->set_line_ends(*array);
503 ASSERT(script->line_ends()->IsFixedArray()); 507 ASSERT(script->line_ends()->IsFixedArray());
504 } 508 }
505 509
506 510
507 Handle<FixedArray> CalculateLineEnds(Handle<String> src, 511 Handle<FixedArray> CalculateLineEnds(Handle<String> src,
508 bool with_imaginary_last_new_line) { 512 bool with_imaginary_last_new_line) {
509 const int src_len = src->length(); 513 const int src_len = src->length();
510 Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n")); 514 Handle<String> new_line = Factory::NewStringFromAscii(CStrVector("\n"));
511 515
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 868
865 OptimizedObjectForAddingMultipleProperties:: 869 OptimizedObjectForAddingMultipleProperties::
866 ~OptimizedObjectForAddingMultipleProperties() { 870 ~OptimizedObjectForAddingMultipleProperties() {
867 // Reoptimize the object to allow fast property access. 871 // Reoptimize the object to allow fast property access.
868 if (has_been_transformed_) { 872 if (has_been_transformed_) {
869 TransformToFastProperties(object_, unused_property_fields_); 873 TransformToFastProperties(object_, unused_property_fields_);
870 } 874 }
871 } 875 }
872 876
873 } } // namespace v8::internal 877 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698