| 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 "isolate.h" | 8 #include "isolate.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // Create a new boxed value. | 75 // Create a new boxed value. |
| 76 Handle<Box> NewBox(Handle<Object> value); | 76 Handle<Box> NewBox(Handle<Object> value); |
| 77 | 77 |
| 78 // Create a pre-tenured empty AccessorPair. | 78 // Create a pre-tenured empty AccessorPair. |
| 79 Handle<AccessorPair> NewAccessorPair(); | 79 Handle<AccessorPair> NewAccessorPair(); |
| 80 | 80 |
| 81 // Create an empty TypeFeedbackInfo. | 81 // Create an empty TypeFeedbackInfo. |
| 82 Handle<TypeFeedbackInfo> NewTypeFeedbackInfo(); | 82 Handle<TypeFeedbackInfo> NewTypeFeedbackInfo(); |
| 83 | 83 |
| 84 // Finds the internalized copy for string in the string table. |
| 85 // If not found, a new string is added to the table and returned. |
| 84 Handle<String> InternalizeUtf8String(Vector<const char> str); | 86 Handle<String> InternalizeUtf8String(Vector<const char> str); |
| 85 Handle<String> InternalizeUtf8String(const char* str) { | 87 Handle<String> InternalizeUtf8String(const char* str) { |
| 86 return InternalizeUtf8String(CStrVector(str)); | 88 return InternalizeUtf8String(CStrVector(str)); |
| 87 } | 89 } |
| 88 Handle<String> InternalizeString(Handle<String> str); | 90 Handle<String> InternalizeString(Handle<String> str); |
| 89 Handle<String> InternalizeOneByteString(Vector<const uint8_t> str); | 91 Handle<String> InternalizeOneByteString(Vector<const uint8_t> str); |
| 90 Handle<String> InternalizeOneByteString( | 92 Handle<String> InternalizeOneByteString( |
| 91 Handle<SeqOneByteString>, int from, int length); | 93 Handle<SeqOneByteString>, int from, int length); |
| 92 | 94 |
| 93 Handle<String> InternalizeTwoByteString(Vector<const uc16> str); | 95 Handle<String> InternalizeTwoByteString(Vector<const uc16> str); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Allocates and partially initializes an ASCII or TwoByte String. The | 160 // Allocates and partially initializes an ASCII or TwoByte String. The |
| 159 // characters of the string are uninitialized. Currently used in regexp code | 161 // characters of the string are uninitialized. Currently used in regexp code |
| 160 // only, where they are pretenured. | 162 // only, where they are pretenured. |
| 161 MUST_USE_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString( | 163 MUST_USE_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString( |
| 162 int length, | 164 int length, |
| 163 PretenureFlag pretenure = NOT_TENURED); | 165 PretenureFlag pretenure = NOT_TENURED); |
| 164 MUST_USE_RESULT MaybeHandle<SeqTwoByteString> NewRawTwoByteString( | 166 MUST_USE_RESULT MaybeHandle<SeqTwoByteString> NewRawTwoByteString( |
| 165 int length, | 167 int length, |
| 166 PretenureFlag pretenure = NOT_TENURED); | 168 PretenureFlag pretenure = NOT_TENURED); |
| 167 | 169 |
| 168 Handle<String> LookupSingleCharacterStringFromCode(uint32_t index); | 170 // Creates a single character string where the character has given code. |
| 171 // A cache is used for ASCII codes. |
| 172 Handle<String> LookupSingleCharacterStringFromCode(uint32_t code); |
| 169 | 173 |
| 170 // Create a new cons string object which consists of a pair of strings. | 174 // Create a new cons string object which consists of a pair of strings. |
| 171 MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left, | 175 MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left, |
| 172 Handle<String> right); | 176 Handle<String> right); |
| 173 | 177 |
| 174 Handle<ConsString> NewRawConsString(String::Encoding encoding); | 178 Handle<ConsString> NewRawConsString(String::Encoding encoding); |
| 175 | 179 |
| 176 // Create a new sequential string containing the concatenation of the inputs. | 180 // Create a new sequential string containing the concatenation of the inputs. |
| 177 Handle<String> NewFlatConcatString(Handle<String> first, | 181 Handle<String> NewFlatConcatString(Handle<String> first, |
| 178 Handle<String> second); | 182 Handle<String> second); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 #undef STRUCT_MAP_ACCESSOR | 572 #undef STRUCT_MAP_ACCESSOR |
| 569 | 573 |
| 570 #define STRING_ACCESSOR(name, str) \ | 574 #define STRING_ACCESSOR(name, str) \ |
| 571 inline Handle<String> name() { \ | 575 inline Handle<String> name() { \ |
| 572 return Handle<String>(BitCast<String**>( \ | 576 return Handle<String>(BitCast<String**>( \ |
| 573 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \ | 577 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \ |
| 574 } | 578 } |
| 575 INTERNALIZED_STRING_LIST(STRING_ACCESSOR) | 579 INTERNALIZED_STRING_LIST(STRING_ACCESSOR) |
| 576 #undef STRING_ACCESSOR | 580 #undef STRING_ACCESSOR |
| 577 | 581 |
| 582 inline void set_string_table(Handle<StringTable> table) { |
| 583 isolate()->heap()->set_string_table(*table); |
| 584 } |
| 585 |
| 578 Handle<String> hidden_string() { | 586 Handle<String> hidden_string() { |
| 579 return Handle<String>(&isolate()->heap()->hidden_string_); | 587 return Handle<String>(&isolate()->heap()->hidden_string_); |
| 580 } | 588 } |
| 581 | 589 |
| 582 // Allocates a new SharedFunctionInfo object. | 590 // Allocates a new SharedFunctionInfo object. |
| 583 Handle<SharedFunctionInfo> NewSharedFunctionInfo( | 591 Handle<SharedFunctionInfo> NewSharedFunctionInfo( |
| 584 Handle<String> name, | 592 Handle<String> name, |
| 585 int number_of_literals, | 593 int number_of_literals, |
| 586 bool is_generator, | 594 bool is_generator, |
| 587 Handle<Code> code, | 595 Handle<Code> code, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // the string representation of the number. Otherwise return undefined. | 689 // the string representation of the number. Otherwise return undefined. |
| 682 Handle<Object> GetNumberStringCache(Handle<Object> number); | 690 Handle<Object> GetNumberStringCache(Handle<Object> number); |
| 683 | 691 |
| 684 // Update the cache with a new number-string pair. | 692 // Update the cache with a new number-string pair. |
| 685 void SetNumberStringCache(Handle<Object> number, Handle<String> string); | 693 void SetNumberStringCache(Handle<Object> number, Handle<String> string); |
| 686 }; | 694 }; |
| 687 | 695 |
| 688 } } // namespace v8::internal | 696 } } // namespace v8::internal |
| 689 | 697 |
| 690 #endif // V8_FACTORY_H_ | 698 #endif // V8_FACTORY_H_ |
| OLD | NEW |