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

Side by Side Diff: src/heap.cc

Issue 9213002: Fast path for string.replace that replaces a single character by a string. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« no previous file with comments | « no previous file | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 cons_string->set_second(second, mode); 3004 cons_string->set_second(second, mode);
3005 return result; 3005 return result;
3006 } 3006 }
3007 3007
3008 3008
3009 MaybeObject* Heap::AllocateSubString(String* buffer, 3009 MaybeObject* Heap::AllocateSubString(String* buffer,
3010 int start, 3010 int start,
3011 int end, 3011 int end,
3012 PretenureFlag pretenure) { 3012 PretenureFlag pretenure) {
3013 int length = end - start; 3013 int length = end - start;
3014 if (length == 0) { 3014 if (length <= 0) {
3015 return empty_string(); 3015 return empty_string();
3016 } else if (length == 1) { 3016 } else if (length == 1) {
3017 return LookupSingleCharacterStringFromCode(buffer->Get(start)); 3017 return LookupSingleCharacterStringFromCode(buffer->Get(start));
3018 } else if (length == 2) { 3018 } else if (length == 2) {
3019 // Optimization for 2-byte strings often used as keys in a decompression 3019 // Optimization for 2-byte strings often used as keys in a decompression
3020 // dictionary. Check whether we already have the string in the symbol 3020 // dictionary. Check whether we already have the string in the symbol
3021 // table to prevent creation of many unneccesary strings. 3021 // table to prevent creation of many unneccesary strings.
3022 unsigned c1 = buffer->Get(start); 3022 unsigned c1 = buffer->Get(start);
3023 unsigned c2 = buffer->Get(start + 1); 3023 unsigned c2 = buffer->Get(start + 1);
3024 return MakeOrFindTwoCharacterString(this, c1, c2); 3024 return MakeOrFindTwoCharacterString(this, c1, c2);
(...skipping 3629 matching lines...) Expand 10 before | Expand all | Expand 10 after
6654 isolate_->heap()->store_buffer()->Compact(); 6654 isolate_->heap()->store_buffer()->Compact();
6655 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6655 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6656 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6656 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6657 next = chunk->next_chunk(); 6657 next = chunk->next_chunk();
6658 isolate_->memory_allocator()->Free(chunk); 6658 isolate_->memory_allocator()->Free(chunk);
6659 } 6659 }
6660 chunks_queued_for_free_ = NULL; 6660 chunks_queued_for_free_ = NULL;
6661 } 6661 }
6662 6662
6663 } } // namespace v8::internal 6663 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698