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

Side by Side Diff: src/factory.h

Issue 239243018: Heap::AllocateStringFromOneByte() and major part of its callers handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comment + some cleanup Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/debug.cc ('k') | src/factory.cc » ('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 #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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // - ...FromUtf8 initializes the string from a buffer that is UTF-8 111 // - ...FromUtf8 initializes the string from a buffer that is UTF-8
112 // encoded. If the characters are all single-byte characters, the 112 // encoded. If the characters are all single-byte characters, the
113 // result will be ASCII encoded, otherwise it will converted to two 113 // result will be ASCII encoded, otherwise it will converted to two
114 // byte. 114 // byte.
115 // - ...FromTwoByte initializes the string from a buffer that is two 115 // - ...FromTwoByte initializes the string from a buffer that is two
116 // byte encoded. If the characters are all single-byte characters, 116 // byte encoded. If the characters are all single-byte characters,
117 // the result will be converted to ASCII, otherwise it will be left as 117 // the result will be converted to ASCII, otherwise it will be left as
118 // two byte. 118 // two byte.
119 // 119 //
120 // ASCII strings are pretenured when used as keys in the SourceCodeCache. 120 // ASCII strings are pretenured when used as keys in the SourceCodeCache.
121 Handle<String> NewStringFromOneByte( 121 MUST_USE_RESULT MaybeHandle<String> NewStringFromOneByte(
122 Vector<const uint8_t> str, 122 Vector<const uint8_t> str,
123 PretenureFlag pretenure = NOT_TENURED); 123 PretenureFlag pretenure = NOT_TENURED);
124
125 template<size_t N>
126 inline Handle<String> NewStringFromStaticAscii(
127 const char (&str)[N],
128 PretenureFlag pretenure = NOT_TENURED) {
129 ASSERT(N == StrLength(str) + 1);
130 return NewStringFromOneByte(
131 STATIC_ASCII_VECTOR(str), pretenure).ToHandleChecked();
132 }
133
134 inline Handle<String> NewStringFromAsciiChecked(
135 const char* str,
136 PretenureFlag pretenure = NOT_TENURED) {
137 return NewStringFromOneByte(
138 OneByteVector(str), pretenure).ToHandleChecked();
139 }
140
124 // TODO(dcarney): remove this function. 141 // TODO(dcarney): remove this function.
125 inline Handle<String> NewStringFromAscii( 142 MUST_USE_RESULT inline MaybeHandle<String> NewStringFromAscii(
126 Vector<const char> str, 143 Vector<const char> str,
127 PretenureFlag pretenure = NOT_TENURED) { 144 PretenureFlag pretenure = NOT_TENURED) {
128 return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure); 145 return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure);
129 } 146 }
130 147
131 // UTF8 strings are pretenured when used for regexp literal patterns and 148 // UTF8 strings are pretenured when used for regexp literal patterns and
132 // flags in the parser. 149 // flags in the parser.
133 Handle<String> NewStringFromUtf8( 150 MUST_USE_RESULT MaybeHandle<String> NewStringFromUtf8(
134 Vector<const char> str, 151 Vector<const char> str,
135 PretenureFlag pretenure = NOT_TENURED); 152 PretenureFlag pretenure = NOT_TENURED);
136 153
137 Handle<String> NewStringFromTwoByte( 154 MUST_USE_RESULT MaybeHandle<String> NewStringFromTwoByte(
138 Vector<const uc16> str, 155 Vector<const uc16> str,
139 PretenureFlag pretenure = NOT_TENURED); 156 PretenureFlag pretenure = NOT_TENURED);
140 157
141 // Allocates and partially initializes an ASCII or TwoByte String. The 158 // Allocates and partially initializes an ASCII or TwoByte String. The
142 // characters of the string are uninitialized. Currently used in regexp code 159 // characters of the string are uninitialized. Currently used in regexp code
143 // only, where they are pretenured. 160 // only, where they are pretenured.
144 MUST_USE_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString( 161 MUST_USE_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString(
145 int length, 162 int length,
146 PretenureFlag pretenure = NOT_TENURED); 163 PretenureFlag pretenure = NOT_TENURED);
147 MUST_USE_RESULT MaybeHandle<SeqTwoByteString> NewRawTwoByteString( 164 MUST_USE_RESULT MaybeHandle<SeqTwoByteString> NewRawTwoByteString(
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // the string representation of the number. Otherwise return undefined. 676 // the string representation of the number. Otherwise return undefined.
660 Handle<Object> GetNumberStringCache(Handle<Object> number); 677 Handle<Object> GetNumberStringCache(Handle<Object> number);
661 678
662 // Update the cache with a new number-string pair. 679 // Update the cache with a new number-string pair.
663 void SetNumberStringCache(Handle<Object> number, Handle<String> string); 680 void SetNumberStringCache(Handle<Object> number, Handle<String> string);
664 }; 681 };
665 682
666 } } // namespace v8::internal 683 } } // namespace v8::internal
667 684
668 #endif // V8_FACTORY_H_ 685 #endif // V8_FACTORY_H_
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698