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

Side by Side Diff: src/factory.cc

Issue 2760413002: Minor optimization to v8::internal::Factory::InternalizeOneByteString.
Patch Set: . Created 3 years, 9 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
« no previous file with comments | « no previous file | src/objects.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return info; 264 return info;
265 } 265 }
266 266
267 267
268 // Internalized strings are created in the old generation (data space). 268 // Internalized strings are created in the old generation (data space).
269 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) { 269 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) {
270 Utf8StringKey key(string, isolate()->heap()->HashSeed()); 270 Utf8StringKey key(string, isolate()->heap()->HashSeed());
271 return InternalizeStringWithKey(&key); 271 return InternalizeStringWithKey(&key);
272 } 272 }
273 273
274 namespace {
275
276 class OneByteStringKeyExpectingSequential final : public OneByteStringKey {
277 using OneByteStringKey::OneByteStringKey;
278
279 bool IsMatch(Object* string) final {
280 if (V8_LIKELY(StringShape(String::cast(string)).IsSequentialOneByte())) {
281 SeqOneByteString* seq_one_byte = SeqOneByteString::cast(string);
282 return seq_one_byte->length() == string_.length() &&
283 memcmp(seq_one_byte->GetChars(), string_.start(),
284 string_.length()) == 0;
285 }
286 return OneByteStringKey::IsMatch(string);
287 }
288 };
289
290 } // namespace
274 291
275 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) { 292 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) {
276 OneByteStringKey key(string, isolate()->heap()->HashSeed()); 293 OneByteStringKeyExpectingSequential key(string,
294 isolate()->heap()->HashSeed());
277 return InternalizeStringWithKey(&key); 295 return InternalizeStringWithKey(&key);
278 } 296 }
279 297
280 298
281 Handle<String> Factory::InternalizeOneByteString( 299 Handle<String> Factory::InternalizeOneByteString(
282 Handle<SeqOneByteString> string, int from, int length) { 300 Handle<SeqOneByteString> string, int from, int length) {
283 SeqOneByteSubStringKey key(string, from, length); 301 SeqOneByteSubStringKey key(string, from, length);
284 return InternalizeStringWithKey(&key); 302 return InternalizeStringWithKey(&key);
285 } 303 }
286 304
(...skipping 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 Handle<AccessorInfo> prototype = 2903 Handle<AccessorInfo> prototype =
2886 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); 2904 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs);
2887 Descriptor d = Descriptor::AccessorConstant( 2905 Descriptor d = Descriptor::AccessorConstant(
2888 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); 2906 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs);
2889 map->AppendDescriptor(&d); 2907 map->AppendDescriptor(&d);
2890 } 2908 }
2891 } 2909 }
2892 2910
2893 } // namespace internal 2911 } // namespace internal
2894 } // namespace v8 2912 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698