| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 32 #include "handles.h" | 32 #include "handles.h" |
| 33 #include "heap.h" | 33 #include "heap.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 // Interface for handle based allocation. | 38 // Interface for handle based allocation. |
| 39 | 39 |
| 40 class Factory { | 40 class Factory { |
| 41 public: | 41 public: |
| 42 // Allocate a new fixed array with undefined entries. | 42 // Allocate a new uninitialized fixed array. |
| 43 Handle<FixedArray> NewFixedArray( | 43 Handle<FixedArray> NewFixedArray( |
| 44 int size, | 44 int size, |
| 45 PretenureFlag pretenure = NOT_TENURED); | 45 PretenureFlag pretenure = NOT_TENURED); |
| 46 | 46 |
| 47 // Allocate a new fixed array with non-existing entries (the hole). | 47 // Allocate a new fixed array with non-existing entries (the hole). |
| 48 Handle<FixedArray> NewFixedArrayWithHoles( | 48 Handle<FixedArray> NewFixedArrayWithHoles( |
| 49 int size, | 49 int size, |
| 50 PretenureFlag pretenure = NOT_TENURED); | 50 PretenureFlag pretenure = NOT_TENURED); |
| 51 | 51 |
| 52 // Allocate a new uninitialized fixed double array. |
| 53 Handle<FixedArray> NewFixedDoubleArray( |
| 54 int size, |
| 55 PretenureFlag pretenure = NOT_TENURED); |
| 56 |
| 52 Handle<NumberDictionary> NewNumberDictionary(int at_least_space_for); | 57 Handle<NumberDictionary> NewNumberDictionary(int at_least_space_for); |
| 53 | 58 |
| 54 Handle<StringDictionary> NewStringDictionary(int at_least_space_for); | 59 Handle<StringDictionary> NewStringDictionary(int at_least_space_for); |
| 55 | 60 |
| 56 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors); | 61 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors); |
| 57 Handle<DeoptimizationInputData> NewDeoptimizationInputData( | 62 Handle<DeoptimizationInputData> NewDeoptimizationInputData( |
| 58 int deopt_entry_count, | 63 int deopt_entry_count, |
| 59 PretenureFlag pretenure); | 64 PretenureFlag pretenure); |
| 60 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( | 65 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( |
| 61 int deopt_entry_count, | 66 int deopt_entry_count, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 Vector<const char> str, | 110 Vector<const char> str, |
| 106 PretenureFlag pretenure = NOT_TENURED); | 111 PretenureFlag pretenure = NOT_TENURED); |
| 107 | 112 |
| 108 Handle<String> NewStringFromTwoByte( | 113 Handle<String> NewStringFromTwoByte( |
| 109 Vector<const uc16> str, | 114 Vector<const uc16> str, |
| 110 PretenureFlag pretenure = NOT_TENURED); | 115 PretenureFlag pretenure = NOT_TENURED); |
| 111 | 116 |
| 112 // Allocates and partially initializes an ASCII or TwoByte String. The | 117 // Allocates and partially initializes an ASCII or TwoByte String. The |
| 113 // characters of the string are uninitialized. Currently used in regexp code | 118 // characters of the string are uninitialized. Currently used in regexp code |
| 114 // only, where they are pretenured. | 119 // only, where they are pretenured. |
| 115 Handle<String> NewRawAsciiString( | 120 Handle<SeqAsciiString> NewRawAsciiString( |
| 116 int length, | 121 int length, |
| 117 PretenureFlag pretenure = NOT_TENURED); | 122 PretenureFlag pretenure = NOT_TENURED); |
| 118 Handle<String> NewRawTwoByteString( | 123 Handle<SeqTwoByteString> NewRawTwoByteString( |
| 119 int length, | 124 int length, |
| 120 PretenureFlag pretenure = NOT_TENURED); | 125 PretenureFlag pretenure = NOT_TENURED); |
| 121 | 126 |
| 122 // Create a new cons string object which consists of a pair of strings. | 127 // Create a new cons string object which consists of a pair of strings. |
| 123 Handle<String> NewConsString(Handle<String> first, | 128 Handle<String> NewConsString(Handle<String> first, |
| 124 Handle<String> second); | 129 Handle<String> second); |
| 125 | 130 |
| 126 // Create a new string object which holds a substring of a string. | 131 // Create a new string object which holds a substring of a string. |
| 127 Handle<String> NewSubString(Handle<String> str, | 132 Handle<String> NewSubString(Handle<String> str, |
| 128 int begin, | 133 int begin, |
| 129 int end); | 134 int end); |
| 130 | 135 |
| 136 // Create a new string object which holds a proper substring of a string. |
| 137 Handle<String> NewProperSubString(Handle<String> str, |
| 138 int begin, |
| 139 int end); |
| 140 |
| 131 // Creates a new external String object. There are two String encodings | 141 // Creates a new external String object. There are two String encodings |
| 132 // in the system: ASCII and two byte. Unlike other String types, it does | 142 // in the system: ASCII and two byte. Unlike other String types, it does |
| 133 // not make sense to have a UTF-8 factory function for external strings, | 143 // not make sense to have a UTF-8 factory function for external strings, |
| 134 // because we cannot change the underlying buffer. | 144 // because we cannot change the underlying buffer. |
| 135 Handle<String> NewExternalStringFromAscii( | 145 Handle<String> NewExternalStringFromAscii( |
| 136 ExternalAsciiString::Resource* resource); | 146 ExternalAsciiString::Resource* resource); |
| 137 Handle<String> NewExternalStringFromTwoByte( | 147 Handle<String> NewExternalStringFromTwoByte( |
| 138 ExternalTwoByteString::Resource* resource); | 148 ExternalTwoByteString::Resource* resource); |
| 139 | 149 |
| 140 // Create a global (but otherwise uninitialized) context. | 150 // Create a global (but otherwise uninitialized) context. |
| 141 Handle<Context> NewGlobalContext(); | 151 Handle<Context> NewGlobalContext(); |
| 142 | 152 |
| 143 // Create a function context. | 153 // Create a function context. |
| 144 Handle<Context> NewFunctionContext(int length, | 154 Handle<Context> NewFunctionContext(int length, |
| 145 Handle<JSFunction> closure); | 155 Handle<JSFunction> function); |
| 156 |
| 157 // Create a catch context. |
| 158 Handle<Context> NewCatchContext(Handle<JSFunction> function, |
| 159 Handle<Context> previous, |
| 160 Handle<String> name, |
| 161 Handle<Object> thrown_object); |
| 146 | 162 |
| 147 // Create a 'with' context. | 163 // Create a 'with' context. |
| 148 Handle<Context> NewWithContext(Handle<Context> previous, | 164 Handle<Context> NewWithContext(Handle<JSFunction> function, |
| 149 Handle<JSObject> extension, | 165 Handle<Context> previous, |
| 150 bool is_catch_context); | 166 Handle<JSObject> extension); |
| 151 | 167 |
| 152 // Return the Symbol matching the passed in string. | 168 // Return the Symbol matching the passed in string. |
| 153 Handle<String> SymbolFromString(Handle<String> value); | 169 Handle<String> SymbolFromString(Handle<String> value); |
| 154 | 170 |
| 155 // Allocate a new struct. The struct is pretenured (allocated directly in | 171 // Allocate a new struct. The struct is pretenured (allocated directly in |
| 156 // the old generation). | 172 // the old generation). |
| 157 Handle<Struct> NewStruct(InstanceType type); | 173 Handle<Struct> NewStruct(InstanceType type); |
| 158 | 174 |
| 159 Handle<AccessorInfo> NewAccessorInfo(); | 175 Handle<AccessorInfo> NewAccessorInfo(); |
| 160 | 176 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 // Update the map cache in the global context with (keys, map) | 449 // Update the map cache in the global context with (keys, map) |
| 434 Handle<MapCache> AddToMapCache(Handle<Context> context, | 450 Handle<MapCache> AddToMapCache(Handle<Context> context, |
| 435 Handle<FixedArray> keys, | 451 Handle<FixedArray> keys, |
| 436 Handle<Map> map); | 452 Handle<Map> map); |
| 437 }; | 453 }; |
| 438 | 454 |
| 439 | 455 |
| 440 } } // namespace v8::internal | 456 } } // namespace v8::internal |
| 441 | 457 |
| 442 #endif // V8_FACTORY_H_ | 458 #endif // V8_FACTORY_H_ |
| OLD | NEW |