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

Side by Side Diff: src/objects.cc

Issue 2489273002: Fast-path in SlowFlatten for ConsStrings with empty first part (Closed)
Patch Set: Ensure string length does not change in test Created 4 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
« no previous file with comments | « no previous file | test/cctest/test-strings.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 (c0 == 'F' || c0 == 'H' || c0 == 'M' || c0 == 'N' || c0 == 'R' || 2208 (c0 == 'F' || c0 == 'H' || c0 == 'M' || c0 == 'N' || c0 == 'R' ||
2209 c0 == 'S' || c0 == 'X')) { 2209 c0 == 'S' || c0 == 'X')) {
2210 return true; // An MP3File, an M. 2210 return true; // An MP3File, an M.
2211 } 2211 }
2212 return false; 2212 return false;
2213 } 2213 }
2214 2214
2215 2215
2216 Handle<String> String::SlowFlatten(Handle<ConsString> cons, 2216 Handle<String> String::SlowFlatten(Handle<ConsString> cons,
2217 PretenureFlag pretenure) { 2217 PretenureFlag pretenure) {
2218 DCHECK(cons->second()->length() != 0);
2219
2220 // TurboFan can create cons strings with empty first parts.
2221 if (cons->first()->length() == 0) return handle(cons->second());
2222
2218 DCHECK(AllowHeapAllocation::IsAllowed()); 2223 DCHECK(AllowHeapAllocation::IsAllowed());
2219 DCHECK(cons->second()->length() != 0);
2220 Isolate* isolate = cons->GetIsolate(); 2224 Isolate* isolate = cons->GetIsolate();
2221 int length = cons->length(); 2225 int length = cons->length();
2222 PretenureFlag tenure = isolate->heap()->InNewSpace(*cons) ? pretenure 2226 PretenureFlag tenure = isolate->heap()->InNewSpace(*cons) ? pretenure
2223 : TENURED; 2227 : TENURED;
2224 Handle<SeqString> result; 2228 Handle<SeqString> result;
2225 if (cons->IsOneByteRepresentation()) { 2229 if (cons->IsOneByteRepresentation()) {
2226 Handle<SeqOneByteString> flat = isolate->factory()->NewRawOneByteString( 2230 Handle<SeqOneByteString> flat = isolate->factory()->NewRawOneByteString(
2227 length, tenure).ToHandleChecked(); 2231 length, tenure).ToHandleChecked();
2228 DisallowHeapAllocation no_gc; 2232 DisallowHeapAllocation no_gc;
2229 WriteToFlat(*cons, flat->GetChars(), 0, length); 2233 WriteToFlat(*cons, flat->GetChars(), 0, length);
(...skipping 18073 matching lines...) Expand 10 before | Expand all | Expand 10 after
20303 // Check if the accessor uses a cached property. 20307 // Check if the accessor uses a cached property.
20304 if (!fti->cached_property_name()->IsTheHole(isolate)) { 20308 if (!fti->cached_property_name()->IsTheHole(isolate)) {
20305 return handle(Name::cast(fti->cached_property_name())); 20309 return handle(Name::cast(fti->cached_property_name()));
20306 } 20310 }
20307 } 20311 }
20308 return MaybeHandle<Name>(); 20312 return MaybeHandle<Name>();
20309 } 20313 }
20310 20314
20311 } // namespace internal 20315 } // namespace internal
20312 } // namespace v8 20316 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698