vendor/v8/src/factory.h in mustang-0.0.1 vs vendor/v8/src/factory.h in mustang-0.1.0

- old
+ new

@@ -27,45 +27,46 @@ #ifndef V8_FACTORY_H_ #define V8_FACTORY_H_ #include "globals.h" +#include "handles.h" #include "heap.h" namespace v8 { namespace internal { // Interface for handle based allocation. -class Factory : public AllStatic { +class Factory { public: // Allocate a new fixed array with undefined entries. - static Handle<FixedArray> NewFixedArray( + Handle<FixedArray> NewFixedArray( int size, PretenureFlag pretenure = NOT_TENURED); // Allocate a new fixed array with non-existing entries (the hole). - static Handle<FixedArray> NewFixedArrayWithHoles( + Handle<FixedArray> NewFixedArrayWithHoles( int size, PretenureFlag pretenure = NOT_TENURED); - static Handle<NumberDictionary> NewNumberDictionary(int at_least_space_for); + Handle<NumberDictionary> NewNumberDictionary(int at_least_space_for); - static Handle<StringDictionary> NewStringDictionary(int at_least_space_for); + Handle<StringDictionary> NewStringDictionary(int at_least_space_for); - static Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors); - static Handle<DeoptimizationInputData> NewDeoptimizationInputData( + Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors); + Handle<DeoptimizationInputData> NewDeoptimizationInputData( int deopt_entry_count, PretenureFlag pretenure); - static Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( + Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( int deopt_entry_count, PretenureFlag pretenure); - static Handle<String> LookupSymbol(Vector<const char> str); - static Handle<String> LookupAsciiSymbol(Vector<const char> str); - static Handle<String> LookupTwoByteSymbol(Vector<const uc16> str); - static Handle<String> LookupAsciiSymbol(const char* str) { + Handle<String> LookupSymbol(Vector<const char> str); + Handle<String> LookupAsciiSymbol(Vector<const char> str); + Handle<String> LookupTwoByteSymbol(Vector<const uc16> str); + Handle<String> LookupAsciiSymbol(const char* str) { return LookupSymbol(CStrVector(str)); } // String creation functions. Most of the string creation functions take @@ -88,343 +89,346 @@ // byte encoded. If the characters are all single-byte characters, // the result will be converted to ASCII, otherwise it will be left as // two byte. // // ASCII strings are pretenured when used as keys in the SourceCodeCache. - static Handle<String> NewStringFromAscii( + Handle<String> NewStringFromAscii( Vector<const char> str, PretenureFlag pretenure = NOT_TENURED); // UTF8 strings are pretenured when used for regexp literal patterns and // flags in the parser. - static Handle<String> NewStringFromUtf8( + Handle<String> NewStringFromUtf8( Vector<const char> str, PretenureFlag pretenure = NOT_TENURED); - static Handle<String> NewStringFromTwoByte( + Handle<String> NewStringFromTwoByte( Vector<const uc16> str, PretenureFlag pretenure = NOT_TENURED); // Allocates and partially initializes an ASCII or TwoByte String. The // characters of the string are uninitialized. Currently used in regexp code // only, where they are pretenured. - static Handle<String> NewRawAsciiString( + Handle<String> NewRawAsciiString( int length, PretenureFlag pretenure = NOT_TENURED); - static Handle<String> NewRawTwoByteString( + Handle<String> NewRawTwoByteString( int length, PretenureFlag pretenure = NOT_TENURED); // Create a new cons string object which consists of a pair of strings. - static Handle<String> NewConsString(Handle<String> first, - Handle<String> second); + Handle<String> NewConsString(Handle<String> first, + Handle<String> second); // Create a new string object which holds a substring of a string. - static Handle<String> NewSubString(Handle<String> str, - int begin, - int end); + Handle<String> NewSubString(Handle<String> str, + int begin, + int end); // Creates a new external String object. There are two String encodings // in the system: ASCII 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. - static Handle<String> NewExternalStringFromAscii( + Handle<String> NewExternalStringFromAscii( ExternalAsciiString::Resource* resource); - static Handle<String> NewExternalStringFromTwoByte( + Handle<String> NewExternalStringFromTwoByte( ExternalTwoByteString::Resource* resource); // Create a global (but otherwise uninitialized) context. - static Handle<Context> NewGlobalContext(); + Handle<Context> NewGlobalContext(); // Create a function context. - static Handle<Context> NewFunctionContext(int length, - Handle<JSFunction> closure); + Handle<Context> NewFunctionContext(int length, + Handle<JSFunction> closure); // Create a 'with' context. - static Handle<Context> NewWithContext(Handle<Context> previous, - Handle<JSObject> extension, - bool is_catch_context); + Handle<Context> NewWithContext(Handle<Context> previous, + Handle<JSObject> extension, + bool is_catch_context); // Return the Symbol matching the passed in string. - static Handle<String> SymbolFromString(Handle<String> value); + Handle<String> SymbolFromString(Handle<String> value); // Allocate a new struct. The struct is pretenured (allocated directly in // the old generation). - static Handle<Struct> NewStruct(InstanceType type); + Handle<Struct> NewStruct(InstanceType type); - static Handle<AccessorInfo> NewAccessorInfo(); + Handle<AccessorInfo> NewAccessorInfo(); - static Handle<Script> NewScript(Handle<String> source); + Handle<Script> NewScript(Handle<String> source); // Proxies are pretenured when allocated by the bootstrapper. - static Handle<Proxy> NewProxy(Address addr, - PretenureFlag pretenure = NOT_TENURED); + Handle<Proxy> NewProxy(Address addr, + PretenureFlag pretenure = NOT_TENURED); // Allocate a new proxy. The proxy is pretenured (allocated directly in // the old generation). - static Handle<Proxy> NewProxy(const AccessorDescriptor* proxy); + Handle<Proxy> NewProxy(const AccessorDescriptor* proxy); - static Handle<ByteArray> NewByteArray(int length, - PretenureFlag pretenure = NOT_TENURED); + Handle<ByteArray> NewByteArray(int length, + PretenureFlag pretenure = NOT_TENURED); - static Handle<PixelArray> NewPixelArray( + Handle<ExternalArray> NewExternalArray( int length, - uint8_t* external_pointer, - PretenureFlag pretenure = NOT_TENURED); - - static Handle<ExternalArray> NewExternalArray( - int length, ExternalArrayType array_type, void* external_pointer, PretenureFlag pretenure = NOT_TENURED); - static Handle<JSGlobalPropertyCell> NewJSGlobalPropertyCell( + Handle<JSGlobalPropertyCell> NewJSGlobalPropertyCell( Handle<Object> value); - static Handle<Map> NewMap(InstanceType type, int instance_size); + Handle<Map> NewMap(InstanceType type, int instance_size); - static Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function); + Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function); - static Handle<Map> CopyMapDropDescriptors(Handle<Map> map); + Handle<Map> CopyMapDropDescriptors(Handle<Map> map); // Copy the map adding more inobject properties if possible without // overflowing the instance size. - static Handle<Map> CopyMap(Handle<Map> map, int extra_inobject_props); + Handle<Map> CopyMap(Handle<Map> map, int extra_inobject_props); - static Handle<Map> CopyMapDropTransitions(Handle<Map> map); + Handle<Map> CopyMapDropTransitions(Handle<Map> map); - static Handle<Map> GetFastElementsMap(Handle<Map> map); + Handle<Map> GetFastElementsMap(Handle<Map> map); - static Handle<Map> GetSlowElementsMap(Handle<Map> map); + Handle<Map> GetSlowElementsMap(Handle<Map> map); - static Handle<Map> GetPixelArrayElementsMap(Handle<Map> map); + Handle<Map> GetExternalArrayElementsMap(Handle<Map> map, + ExternalArrayType array_type, + bool safe_to_add_transition); - static Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array); + Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array); // Numbers (eg, literals) are pretenured by the parser. - static Handle<Object> NewNumber(double value, - PretenureFlag pretenure = NOT_TENURED); + Handle<Object> NewNumber(double value, + PretenureFlag pretenure = NOT_TENURED); - static Handle<Object> NewNumberFromInt(int value); - static Handle<Object> NewNumberFromUint(uint32_t value); + Handle<Object> NewNumberFromInt(int value); + Handle<Object> NewNumberFromUint(uint32_t value); // These objects are used by the api to create env-independent data // structures in the heap. - static Handle<JSObject> NewNeanderObject(); + Handle<JSObject> NewNeanderObject(); - static Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length); + Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length); // JS objects are pretenured when allocated by the bootstrapper and // runtime. - static Handle<JSObject> NewJSObject(Handle<JSFunction> constructor, - PretenureFlag pretenure = NOT_TENURED); + Handle<JSObject> NewJSObject(Handle<JSFunction> constructor, + PretenureFlag pretenure = NOT_TENURED); // Global objects are pretenured. - static Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor); + Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor); // JS objects are pretenured when allocated by the bootstrapper and // runtime. - static Handle<JSObject> NewJSObjectFromMap(Handle<Map> map); + Handle<JSObject> NewJSObjectFromMap(Handle<Map> map); // JS arrays are pretenured when allocated by the parser. - static Handle<JSArray> NewJSArray(int init_length, - PretenureFlag pretenure = NOT_TENURED); + Handle<JSArray> NewJSArray(int capacity, + PretenureFlag pretenure = NOT_TENURED); - static Handle<JSArray> NewJSArrayWithElements( + Handle<JSArray> NewJSArrayWithElements( Handle<FixedArray> elements, PretenureFlag pretenure = NOT_TENURED); - static Handle<JSFunction> NewFunction(Handle<String> name, - Handle<Object> prototype); + Handle<JSFunction> NewFunction(Handle<String> name, + Handle<Object> prototype); - static Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name); + Handle<JSFunction> NewFunctionWithoutPrototype( + Handle<String> name, + StrictModeFlag strict_mode); - static Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global); + Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global); - static Handle<JSFunction> BaseNewFunctionFromSharedFunctionInfo( + Handle<JSFunction> BaseNewFunctionFromSharedFunctionInfo( Handle<SharedFunctionInfo> function_info, Handle<Map> function_map, PretenureFlag pretenure); - static Handle<JSFunction> NewFunctionFromSharedFunctionInfo( + Handle<JSFunction> NewFunctionFromSharedFunctionInfo( Handle<SharedFunctionInfo> function_info, Handle<Context> context, PretenureFlag pretenure = TENURED); - static Handle<Code> NewCode(const CodeDesc& desc, - Code::Flags flags, - Handle<Object> self_reference); + Handle<Code> NewCode(const CodeDesc& desc, + Code::Flags flags, + Handle<Object> self_reference, + bool immovable = false); - static Handle<Code> CopyCode(Handle<Code> code); + Handle<Code> CopyCode(Handle<Code> code); - static Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info); + Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info); - static Handle<Object> ToObject(Handle<Object> object); - static Handle<Object> ToObject(Handle<Object> object, - Handle<Context> global_context); + Handle<Object> ToObject(Handle<Object> object); + Handle<Object> ToObject(Handle<Object> object, + Handle<Context> global_context); // Interface for creating error objects. - static Handle<Object> NewError(const char* maker, const char* type, - Handle<JSArray> args); - static Handle<Object> NewError(const char* maker, const char* type, - Vector< Handle<Object> > args); - static Handle<Object> NewError(const char* type, - Vector< Handle<Object> > args); - static Handle<Object> NewError(Handle<String> message); - static Handle<Object> NewError(const char* constructor, - Handle<String> message); + Handle<Object> NewError(const char* maker, const char* type, + Handle<JSArray> args); + Handle<Object> NewError(const char* maker, const char* type, + Vector< Handle<Object> > args); + Handle<Object> NewError(const char* type, + Vector< Handle<Object> > args); + Handle<Object> NewError(Handle<String> message); + Handle<Object> NewError(const char* constructor, + Handle<String> message); - static Handle<Object> NewTypeError(const char* type, - Vector< Handle<Object> > args); - static Handle<Object> NewTypeError(Handle<String> message); + Handle<Object> NewTypeError(const char* type, + Vector< Handle<Object> > args); + Handle<Object> NewTypeError(Handle<String> message); - static Handle<Object> NewRangeError(const char* type, - Vector< Handle<Object> > args); - static Handle<Object> NewRangeError(Handle<String> message); + Handle<Object> NewRangeError(const char* type, + Vector< Handle<Object> > args); + Handle<Object> NewRangeError(Handle<String> message); - static Handle<Object> NewSyntaxError(const char* type, Handle<JSArray> args); - static Handle<Object> NewSyntaxError(Handle<String> message); + Handle<Object> NewSyntaxError(const char* type, Handle<JSArray> args); + Handle<Object> NewSyntaxError(Handle<String> message); - static Handle<Object> NewReferenceError(const char* type, - Vector< Handle<Object> > args); - static Handle<Object> NewReferenceError(Handle<String> message); + Handle<Object> NewReferenceError(const char* type, + Vector< Handle<Object> > args); + Handle<Object> NewReferenceError(Handle<String> message); - static Handle<Object> NewEvalError(const char* type, - Vector< Handle<Object> > args); + Handle<Object> NewEvalError(const char* type, + Vector< Handle<Object> > args); - static Handle<JSFunction> NewFunction(Handle<String> name, - InstanceType type, - int instance_size, - Handle<Code> code, - bool force_initial_map); + Handle<JSFunction> NewFunction(Handle<String> name, + InstanceType type, + int instance_size, + Handle<Code> code, + bool force_initial_map); - static Handle<JSFunction> NewFunction(Handle<Map> function_map, + Handle<JSFunction> NewFunction(Handle<Map> function_map, Handle<SharedFunctionInfo> shared, Handle<Object> prototype); - static Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name, - InstanceType type, - int instance_size, - Handle<JSObject> prototype, - Handle<Code> code, - bool force_initial_map); + Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name, + InstanceType type, + int instance_size, + Handle<JSObject> prototype, + Handle<Code> code, + bool force_initial_map); - static Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, - Handle<Code> code); + Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, + Handle<Code> code); - static Handle<DescriptorArray> CopyAppendProxyDescriptor( + Handle<DescriptorArray> CopyAppendProxyDescriptor( Handle<DescriptorArray> array, Handle<String> key, Handle<Object> value, PropertyAttributes attributes); - static Handle<String> NumberToString(Handle<Object> number); + Handle<String> NumberToString(Handle<Object> number); enum ApiInstanceType { JavaScriptObject, InnerGlobalObject, OuterGlobalObject }; - static Handle<JSFunction> CreateApiFunction( + Handle<JSFunction> CreateApiFunction( Handle<FunctionTemplateInfo> data, ApiInstanceType type = JavaScriptObject); - static Handle<JSFunction> InstallMembers(Handle<JSFunction> function); + Handle<JSFunction> InstallMembers(Handle<JSFunction> function); // Installs interceptors on the instance. 'desc' is a function template, // and instance is an object instance created by the function of this // function template. - static void ConfigureInstance(Handle<FunctionTemplateInfo> desc, - Handle<JSObject> instance, - bool* pending_exception); + void ConfigureInstance(Handle<FunctionTemplateInfo> desc, + Handle<JSObject> instance, + bool* pending_exception); #define ROOT_ACCESSOR(type, name, camel_name) \ - static inline Handle<type> name() { \ + inline Handle<type> name() { \ return Handle<type>(BitCast<type**>( \ - &Heap::roots_[Heap::k##camel_name##RootIndex])); \ + &isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \ } ROOT_LIST(ROOT_ACCESSOR) #undef ROOT_ACCESSOR_ACCESSOR -#define SYMBOL_ACCESSOR(name, str) \ - static inline Handle<String> name() { \ +#define SYMBOL_ACCESSOR(name, str) \ + inline Handle<String> name() { \ return Handle<String>(BitCast<String**>( \ - &Heap::roots_[Heap::k##name##RootIndex])); \ + &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \ } SYMBOL_LIST(SYMBOL_ACCESSOR) #undef SYMBOL_ACCESSOR - static Handle<String> hidden_symbol() { - return Handle<String>(&Heap::hidden_symbol_); + Handle<String> hidden_symbol() { + return Handle<String>(&isolate()->heap()->hidden_symbol_); } - static Handle<SharedFunctionInfo> NewSharedFunctionInfo( + Handle<SharedFunctionInfo> NewSharedFunctionInfo( Handle<String> name, int number_of_literals, Handle<Code> code, Handle<SerializedScopeInfo> scope_info); - static Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name); + Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name); - static Handle<JSMessageObject> NewJSMessageObject( + Handle<JSMessageObject> NewJSMessageObject( Handle<String> type, Handle<JSArray> arguments, int start_position, int end_position, Handle<Object> script, Handle<Object> stack_trace, Handle<Object> stack_frames); - static Handle<NumberDictionary> DictionaryAtNumberPut( + Handle<NumberDictionary> DictionaryAtNumberPut( Handle<NumberDictionary>, uint32_t key, Handle<Object> value); #ifdef ENABLE_DEBUGGER_SUPPORT - static Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); + Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); #endif // Return a map using the map cache in the global context. // The key the an ordered set of property names. - static Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context, - Handle<FixedArray> keys); + Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context, + Handle<FixedArray> keys); // Creates a new FixedArray that holds the data associated with the // atom regexp and stores it in the regexp. - static void SetRegExpAtomData(Handle<JSRegExp> regexp, - JSRegExp::Type type, - Handle<String> source, - JSRegExp::Flags flags, - Handle<Object> match_pattern); + void SetRegExpAtomData(Handle<JSRegExp> regexp, + JSRegExp::Type type, + Handle<String> source, + JSRegExp::Flags flags, + Handle<Object> match_pattern); // Creates a new FixedArray that holds the data associated with the // irregexp regexp and stores it in the regexp. - static void SetRegExpIrregexpData(Handle<JSRegExp> regexp, - JSRegExp::Type type, - Handle<String> source, - JSRegExp::Flags flags, - int capture_count); + void SetRegExpIrregexpData(Handle<JSRegExp> regexp, + JSRegExp::Type type, + Handle<String> source, + JSRegExp::Flags flags, + int capture_count); private: - static Handle<JSFunction> NewFunctionHelper(Handle<String> name, - Handle<Object> prototype); + Isolate* isolate() { return reinterpret_cast<Isolate*>(this); } - static Handle<JSFunction> NewFunctionWithoutPrototypeHelper( - Handle<String> name); + Handle<JSFunction> NewFunctionHelper(Handle<String> name, + Handle<Object> prototype); - static Handle<DescriptorArray> CopyAppendCallbackDescriptors( + Handle<JSFunction> NewFunctionWithoutPrototypeHelper( + Handle<String> name, + StrictModeFlag strict_mode); + + Handle<DescriptorArray> CopyAppendCallbackDescriptors( Handle<DescriptorArray> array, Handle<Object> descriptors); // Create a new map cache. - static Handle<MapCache> NewMapCache(int at_least_space_for); + Handle<MapCache> NewMapCache(int at_least_space_for); // Update the map cache in the global context with (keys, map) - static Handle<MapCache> AddToMapCache(Handle<Context> context, - Handle<FixedArray> keys, - Handle<Map> map); + Handle<MapCache> AddToMapCache(Handle<Context> context, + Handle<FixedArray> keys, + Handle<Map> map); }; } } // namespace v8::internal