HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Nougat 7.0
|
7.0.0_r31
下载
查看原文件
收藏
根目录
external
v8
src
factory.h
// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_FACTORY_H_ #define V8_FACTORY_H_ #include "src/isolate.h" #include "src/messages.h" #include "src/type-feedback-vector.h" namespace v8 { namespace internal { // Interface for handle based allocation. class Factory final { public: Handle
NewOddball(Handle
map, const char* to_string, Handle
to_number, const char* type_of, byte kind); // Allocates a fixed array initialized with undefined values. Handle
NewFixedArray( int size, PretenureFlag pretenure = NOT_TENURED); // Allocate a new fixed array with non-existing entries (the hole). Handle
NewFixedArrayWithHoles( int size, PretenureFlag pretenure = NOT_TENURED); // Allocates an uninitialized fixed array. It must be filled by the caller. Handle
NewUninitializedFixedArray(int size); // Allocate a new uninitialized fixed double array. // The function returns a pre-allocated empty fixed array for capacity = 0, // so the return type must be the general fixed array class. Handle
NewFixedDoubleArray( int size, PretenureFlag pretenure = NOT_TENURED); // Allocate a new fixed double array with hole values. Handle
NewFixedDoubleArrayWithHoles( int size, PretenureFlag pretenure = NOT_TENURED); Handle
NewOrderedHashSet(); Handle
NewOrderedHashMap(); // Create a new boxed value. Handle
NewBox(Handle
value); // Create a new PrototypeInfo struct. Handle
NewPrototypeInfo(); // Create a new SloppyBlockWithEvalContextExtension struct. Handle
NewSloppyBlockWithEvalContextExtension(Handle
scope_info, Handle
extension); // Create a pre-tenured empty AccessorPair. Handle
NewAccessorPair(); // Create an empty TypeFeedbackInfo. Handle
NewTypeFeedbackInfo(); // Finds the internalized copy for string in the string table. // If not found, a new string is added to the table and returned. Handle
InternalizeUtf8String(Vector
str); Handle
InternalizeUtf8String(const char* str) { return InternalizeUtf8String(CStrVector(str)); } Handle
InternalizeString(Handle
str); Handle
InternalizeOneByteString(Vector
str); Handle
InternalizeOneByteString( Handle
, int from, int length); Handle
InternalizeTwoByteString(Vector
str); template
Handle
InternalizeStringWithKey(StringTableKey* key); Handle
InternalizeName(Handle
name); // String creation functions. Most of the string creation functions take // a Heap::PretenureFlag argument to optionally request that they be // allocated in the old generation. The pretenure flag defaults to // DONT_TENURE. // // Creates a new String object. There are two String encodings: one-byte and // two-byte. One should choose between the three string factory functions // based on the encoding of the string buffer that the string is // initialized from. // - ...FromOneByte initializes the string from a buffer that is Latin1 // encoded (it does not check that the buffer is Latin1 encoded) and // the result will be Latin1 encoded. // - ...FromUtf8 initializes the string from a buffer that is UTF-8 // encoded. If the characters are all ASCII characters, the result // will be Latin1 encoded, otherwise it will converted to two-byte. // - ...FromTwoByte initializes the string from a buffer that is two-byte // encoded. If the characters are all Latin1 characters, the result // will be converted to Latin1, otherwise it will be left as two-byte. // // One-byte strings are pretenured when used as keys in the SourceCodeCache. MUST_USE_RESULT MaybeHandle
NewStringFromOneByte( Vector
str, PretenureFlag pretenure = NOT_TENURED); template
inline Handle
NewStringFromStaticChars( const char (&str)[N], PretenureFlag pretenure = NOT_TENURED) { DCHECK(N == StrLength(str) + 1); return NewStringFromOneByte(STATIC_CHAR_VECTOR(str), pretenure) .ToHandleChecked(); } inline Handle
NewStringFromAsciiChecked( const char* str, PretenureFlag pretenure = NOT_TENURED) { return NewStringFromOneByte( OneByteVector(str), pretenure).ToHandleChecked(); } // Allocates and fully initializes a String. There are two String encodings: // one-byte and two-byte. One should choose between the threestring // allocation functions based on the encoding of the string buffer used to // initialized the string. // - ...FromOneByte initializes the string from a buffer that is Latin1 // encoded (it does not check that the buffer is Latin1 encoded) and the // result will be Latin1 encoded. // - ...FromUTF8 initializes the string from a buffer that is UTF-8 // encoded. If the characters are all ASCII characters, the result // will be Latin1 encoded, otherwise it will converted to two-byte. // - ...FromTwoByte initializes the string from a buffer that is two-byte // encoded. If the characters are all Latin1 characters, the // result will be converted to Latin1, otherwise it will be left as // two-byte. // TODO(dcarney): remove this function. MUST_USE_RESULT inline MaybeHandle
NewStringFromAscii( Vector
str, PretenureFlag pretenure = NOT_TENURED) { return NewStringFromOneByte(Vector
::cast(str), pretenure); } // UTF8 strings are pretenured when used for regexp literal patterns and // flags in the parser. MUST_USE_RESULT MaybeHandle
NewStringFromUtf8( Vector
str, PretenureFlag pretenure = NOT_TENURED); MUST_USE_RESULT MaybeHandle
NewStringFromTwoByte( Vector
str, PretenureFlag pretenure = NOT_TENURED); // Allocates an internalized string in old space based on the character // stream. Handle
NewInternalizedStringFromUtf8(Vector
str, int chars, uint32_t hash_field); Handle
NewOneByteInternalizedString(Vector
str, uint32_t hash_field); Handle
NewOneByteInternalizedSubString( Handle
string, int offset, int length, uint32_t hash_field); Handle
NewTwoByteInternalizedString(Vector
str, uint32_t hash_field); Handle
NewInternalizedStringImpl(Handle
string, int chars, uint32_t hash_field); // Compute the matching internalized string map for a string if possible. // Empty handle is returned if string is in new space or not flattened. MUST_USE_RESULT MaybeHandle
InternalizedStringMapForString( Handle
string); // Allocates and partially initializes an one-byte or two-byte String. The // characters of the string are uninitialized. Currently used in regexp code // only, where they are pretenured. MUST_USE_RESULT MaybeHandle
NewRawOneByteString( int length, PretenureFlag pretenure = NOT_TENURED); MUST_USE_RESULT MaybeHandle
NewRawTwoByteString( int length, PretenureFlag pretenure = NOT_TENURED); // Creates a single character string where the character has given code. // A cache is used for Latin1 codes. Handle
LookupSingleCharacterStringFromCode(uint32_t code); // Create a new cons string object which consists of a pair of strings. MUST_USE_RESULT MaybeHandle
NewConsString(Handle
left, Handle
right); // Create a new string object which holds a proper substring of a string. Handle
NewProperSubString(Handle
str, int begin, int end); // Create a new string object which holds a substring of a string. Handle
NewSubString(Handle
str, int begin, int end) { if (begin == 0 && end == str->length()) return str; return NewProperSubString(str, begin, end); } // Creates a new external String object. There are two String encodings // in the system: one-byte and two-byte. Unlike other String types, it does // not make sense to have a UTF-8 factory function for external strings, // because we cannot change the underlying buffer. Note that these strings // are backed by a string resource that resides outside the V8 heap. MUST_USE_RESULT MaybeHandle
NewExternalStringFromOneByte( const ExternalOneByteString::Resource* resource); MUST_USE_RESULT MaybeHandle
NewExternalStringFromTwoByte( const ExternalTwoByteString::Resource* resource); // Create a symbol. Handle
NewSymbol(); Handle
NewPrivateSymbol(); // Create a global (but otherwise uninitialized) context. Handle
NewNativeContext(); // Create a script context. Handle
NewScriptContext(Handle
function, Handle
scope_info); // Create an empty script context table. Handle
NewScriptContextTable(); // Create a module context. Handle
NewModuleContext(Handle
scope_info); // Create a function context. Handle
NewFunctionContext(int length, Handle
function); // Create a catch context. Handle
NewCatchContext(Handle
function, Handle
previous, Handle
name, Handle
thrown_object); // Create a 'with' context. Handle
NewWithContext(Handle
function, Handle
previous, Handle
extension); // Create a block context. Handle
NewBlockContext(Handle
function, Handle
previous, Handle
scope_info); // Allocate a new struct. The struct is pretenured (allocated directly in // the old generation). Handle
NewStruct(InstanceType type); Handle
NewCodeCache(); Handle
NewAliasedArgumentsEntry( int aliased_context_slot); Handle
NewExecutableAccessorInfo(); Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册