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 #ifndef V8_FACTORY_H_ | 5 #ifndef V8_FACTORY_H_ |
6 #define V8_FACTORY_H_ | 6 #define V8_FACTORY_H_ |
7 | 7 |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/type-feedback-vector.h" | 10 #include "src/type-feedback-vector.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // Create an empty TypeFeedbackInfo. | 64 // Create an empty TypeFeedbackInfo. |
65 Handle<TypeFeedbackInfo> NewTypeFeedbackInfo(); | 65 Handle<TypeFeedbackInfo> NewTypeFeedbackInfo(); |
66 | 66 |
67 // Finds the internalized copy for string in the string table. | 67 // Finds the internalized copy for string in the string table. |
68 // If not found, a new string is added to the table and returned. | 68 // If not found, a new string is added to the table and returned. |
69 Handle<String> InternalizeUtf8String(Vector<const char> str); | 69 Handle<String> InternalizeUtf8String(Vector<const char> str); |
70 Handle<String> InternalizeUtf8String(const char* str) { | 70 Handle<String> InternalizeUtf8String(const char* str) { |
71 return InternalizeUtf8String(CStrVector(str)); | 71 return InternalizeUtf8String(CStrVector(str)); |
72 } | 72 } |
73 Handle<String> InternalizeString(Handle<String> str); | 73 |
74 Handle<String> InternalizeOneByteString(Vector<const uint8_t> str); | 74 Handle<String> InternalizeOneByteString(Vector<const uint8_t> str); |
75 Handle<String> InternalizeOneByteString( | 75 Handle<String> InternalizeOneByteString( |
76 Handle<SeqOneByteString>, int from, int length); | 76 Handle<SeqOneByteString>, int from, int length); |
77 | 77 |
78 Handle<String> InternalizeTwoByteString(Vector<const uc16> str); | 78 Handle<String> InternalizeTwoByteString(Vector<const uc16> str); |
79 | 79 |
80 template<class StringTableKey> | 80 template<class StringTableKey> |
81 Handle<String> InternalizeStringWithKey(StringTableKey* key); | 81 Handle<String> InternalizeStringWithKey(StringTableKey* key); |
82 | 82 |
83 Handle<Name> InternalizeName(Handle<Name> name); | 83 // Internalized strings are created in the old generation (data space). |
| 84 Handle<String> InternalizeString(Handle<String> string) { |
| 85 if (string->IsInternalizedString()) return string; |
| 86 return StringTable::LookupString(isolate(), string); |
| 87 } |
84 | 88 |
| 89 Handle<Name> InternalizeName(Handle<Name> name) { |
| 90 if (name->IsUniqueName()) return name; |
| 91 return StringTable::LookupString(isolate(), Handle<String>::cast(name)); |
| 92 } |
85 | 93 |
86 // String creation functions. Most of the string creation functions take | 94 // String creation functions. Most of the string creation functions take |
87 // a Heap::PretenureFlag argument to optionally request that they be | 95 // a Heap::PretenureFlag argument to optionally request that they be |
88 // allocated in the old generation. The pretenure flag defaults to | 96 // allocated in the old generation. The pretenure flag defaults to |
89 // DONT_TENURE. | 97 // DONT_TENURE. |
90 // | 98 // |
91 // Creates a new String object. There are two String encodings: one-byte and | 99 // Creates a new String object. There are two String encodings: one-byte and |
92 // two-byte. One should choose between the three string factory functions | 100 // two-byte. One should choose between the three string factory functions |
93 // based on the encoding of the string buffer that the string is | 101 // based on the encoding of the string buffer that the string is |
94 // initialized from. | 102 // initialized from. |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 // Create a JSArray with no elements and no length. | 709 // Create a JSArray with no elements and no length. |
702 Handle<JSArray> NewJSArray(ElementsKind elements_kind, | 710 Handle<JSArray> NewJSArray(ElementsKind elements_kind, |
703 Strength strength = Strength::WEAK, | 711 Strength strength = Strength::WEAK, |
704 PretenureFlag pretenure = NOT_TENURED); | 712 PretenureFlag pretenure = NOT_TENURED); |
705 }; | 713 }; |
706 | 714 |
707 } // namespace internal | 715 } // namespace internal |
708 } // namespace v8 | 716 } // namespace v8 |
709 | 717 |
710 #endif // V8_FACTORY_H_ | 718 #endif // V8_FACTORY_H_ |
OLD | NEW |