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 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 STATIC_ASCII_VECTOR(str), pretenure).ToHandleChecked(); | 115 STATIC_ASCII_VECTOR(str), pretenure).ToHandleChecked(); |
116 } | 116 } |
117 | 117 |
118 inline Handle<String> NewStringFromAsciiChecked( | 118 inline Handle<String> NewStringFromAsciiChecked( |
119 const char* str, | 119 const char* str, |
120 PretenureFlag pretenure = NOT_TENURED) { | 120 PretenureFlag pretenure = NOT_TENURED) { |
121 return NewStringFromOneByte( | 121 return NewStringFromOneByte( |
122 OneByteVector(str), pretenure).ToHandleChecked(); | 122 OneByteVector(str), pretenure).ToHandleChecked(); |
123 } | 123 } |
124 | 124 |
| 125 |
| 126 // Allocates and fully initializes a String. There are two String |
| 127 // encodings: ASCII and two byte. One should choose between the three string |
| 128 // allocation functions based on the encoding of the string buffer used to |
| 129 // initialized the string. |
| 130 // - ...FromAscii initializes the string from a buffer that is ASCII |
| 131 // encoded (it does not check that the buffer is ASCII encoded) and the |
| 132 // result will be ASCII encoded. |
| 133 // - ...FromUTF8 initializes the string from a buffer that is UTF-8 |
| 134 // encoded. If the characters are all single-byte characters, the |
| 135 // result will be ASCII encoded, otherwise it will converted to two |
| 136 // byte. |
| 137 // - ...FromTwoByte initializes the string from a buffer that is two-byte |
| 138 // encoded. If the characters are all single-byte characters, the |
| 139 // result will be converted to ASCII, otherwise it will be left as |
| 140 // two-byte. |
| 141 |
125 // TODO(dcarney): remove this function. | 142 // TODO(dcarney): remove this function. |
126 MUST_USE_RESULT inline MaybeHandle<String> NewStringFromAscii( | 143 MUST_USE_RESULT inline MaybeHandle<String> NewStringFromAscii( |
127 Vector<const char> str, | 144 Vector<const char> str, |
128 PretenureFlag pretenure = NOT_TENURED) { | 145 PretenureFlag pretenure = NOT_TENURED) { |
129 return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure); | 146 return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure); |
130 } | 147 } |
131 | 148 |
132 // UTF8 strings are pretenured when used for regexp literal patterns and | 149 // UTF8 strings are pretenured when used for regexp literal patterns and |
133 // flags in the parser. | 150 // flags in the parser. |
134 MUST_USE_RESULT MaybeHandle<String> NewStringFromUtf8( | 151 MUST_USE_RESULT MaybeHandle<String> NewStringFromUtf8( |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 PretenureFlag pretenure = TENURED); | 712 PretenureFlag pretenure = TENURED); |
696 | 713 |
697 Handle<JSFunction> NewFunction(Handle<Map> map, | 714 Handle<JSFunction> NewFunction(Handle<Map> map, |
698 Handle<String> name, | 715 Handle<String> name, |
699 MaybeHandle<Code> maybe_code); | 716 MaybeHandle<Code> maybe_code); |
700 }; | 717 }; |
701 | 718 |
702 } } // namespace v8::internal | 719 } } // namespace v8::internal |
703 | 720 |
704 #endif // V8_FACTORY_H_ | 721 #endif // V8_FACTORY_H_ |
OLD | NEW |