| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |