danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_FACTORY_H_ |
| 29 | #define V8_FACTORY_H_ |
| 30 | |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 31 | #include "globals.h" |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 32 | #include "handles.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 33 | #include "heap.h" |
| 34 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 35 | namespace v8 { |
| 36 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 38 | // Interface for handle based allocation. |
| 39 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 40 | class Factory { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 41 | public: |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 42 | // Allocate a new boxed value. |
| 43 | Handle<Box> NewBox( |
| 44 | Handle<Object> value, |
| 45 | PretenureFlag pretenure = NOT_TENURED); |
| 46 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 47 | // Allocate a new uninitialized fixed array. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 48 | Handle<FixedArray> NewFixedArray( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 49 | int size, |
| 50 | PretenureFlag pretenure = NOT_TENURED); |
| 51 | |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 52 | // Allocate a new fixed array with non-existing entries (the hole). |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 53 | Handle<FixedArray> NewFixedArrayWithHoles( |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 54 | int size, |
| 55 | PretenureFlag pretenure = NOT_TENURED); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 56 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 57 | // Allocate a new uninitialized fixed double array. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 58 | Handle<FixedDoubleArray> NewFixedDoubleArray( |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 59 | int size, |
| 60 | PretenureFlag pretenure = NOT_TENURED); |
| 61 | |
mstarzinger@chromium.org | a2e1a40 | 2013-10-15 08:25:05 +0000 | [diff] [blame] | 62 | Handle<ConstantPoolArray> NewConstantPoolArray( |
| 63 | int number_of_int64_entries, |
| 64 | int number_of_ptr_entries, |
| 65 | int number_of_int32_entries); |
| 66 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 67 | Handle<SeededNumberDictionary> NewSeededNumberDictionary( |
| 68 | int at_least_space_for); |
| 69 | |
| 70 | Handle<UnseededNumberDictionary> NewUnseededNumberDictionary( |
| 71 | int at_least_space_for); |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 72 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 73 | Handle<NameDictionary> NewNameDictionary(int at_least_space_for); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 74 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 75 | Handle<ObjectHashSet> NewObjectHashSet(int at_least_space_for); |
| 76 | |
vegorov@chromium.org | 7943d46 | 2011-08-01 11:41:52 +0000 | [diff] [blame] | 77 | Handle<ObjectHashTable> NewObjectHashTable(int at_least_space_for); |
| 78 | |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 79 | Handle<WeakHashTable> NewWeakHashTable(int at_least_space_for); |
| 80 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 81 | Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors, |
| 82 | int slack = 0); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 83 | Handle<DeoptimizationInputData> NewDeoptimizationInputData( |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 84 | int deopt_entry_count, |
| 85 | PretenureFlag pretenure); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 86 | Handle<DeoptimizationOutputData> NewDeoptimizationOutputData( |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 87 | int deopt_entry_count, |
| 88 | PretenureFlag pretenure); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 89 | // Allocates a pre-tenured empty AccessorPair. |
| 90 | Handle<AccessorPair> NewAccessorPair(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 91 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 92 | Handle<TypeFeedbackInfo> NewTypeFeedbackInfo(); |
| 93 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 94 | Handle<String> InternalizeUtf8String(Vector<const char> str); |
| 95 | Handle<String> InternalizeUtf8String(const char* str) { |
| 96 | return InternalizeUtf8String(CStrVector(str)); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 97 | } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 98 | Handle<String> InternalizeString(Handle<String> str); |
| 99 | Handle<String> InternalizeOneByteString(Vector<const uint8_t> str); |
| 100 | Handle<String> InternalizeOneByteString(Handle<SeqOneByteString>, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 101 | int from, |
| 102 | int length); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 103 | Handle<String> InternalizeTwoByteString(Vector<const uc16> str); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 104 | |
| 105 | |
| 106 | // String creation functions. Most of the string creation functions take |
| 107 | // a Heap::PretenureFlag argument to optionally request that they be |
| 108 | // allocated in the old generation. The pretenure flag defaults to |
| 109 | // DONT_TENURE. |
| 110 | // |
| 111 | // Creates a new String object. There are two String encodings: ASCII and |
| 112 | // two byte. One should choose between the three string factory functions |
| 113 | // based on the encoding of the string buffer that the string is |
| 114 | // initialized from. |
| 115 | // - ...FromAscii initializes the string from a buffer that is ASCII |
| 116 | // encoded (it does not check that the buffer is ASCII encoded) and |
| 117 | // the result will be ASCII encoded. |
| 118 | // - ...FromUtf8 initializes the string from a buffer that is UTF-8 |
| 119 | // encoded. If the characters are all single-byte characters, the |
| 120 | // result will be ASCII encoded, otherwise it will converted to two |
| 121 | // byte. |
| 122 | // - ...FromTwoByte initializes the string from a buffer that is two |
| 123 | // byte encoded. If the characters are all single-byte characters, |
| 124 | // the result will be converted to ASCII, otherwise it will be left as |
| 125 | // two byte. |
| 126 | // |
| 127 | // ASCII strings are pretenured when used as keys in the SourceCodeCache. |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 128 | Handle<String> NewStringFromOneByte( |
| 129 | Vector<const uint8_t> str, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 130 | PretenureFlag pretenure = NOT_TENURED); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 131 | // TODO(dcarney): remove this function. |
| 132 | inline Handle<String> NewStringFromAscii( |
| 133 | Vector<const char> str, |
| 134 | PretenureFlag pretenure = NOT_TENURED) { |
| 135 | return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure); |
| 136 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 137 | |
| 138 | // UTF8 strings are pretenured when used for regexp literal patterns and |
| 139 | // flags in the parser. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 140 | Handle<String> NewStringFromUtf8( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 141 | Vector<const char> str, |
| 142 | PretenureFlag pretenure = NOT_TENURED); |
| 143 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 144 | Handle<String> NewStringFromTwoByte( |
erik.corry@gmail.com | 4a2e25e | 2010-07-07 12:22:46 +0000 | [diff] [blame] | 145 | Vector<const uc16> str, |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 146 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 147 | |
erik.corry@gmail.com | 4a2e25e | 2010-07-07 12:22:46 +0000 | [diff] [blame] | 148 | // Allocates and partially initializes an ASCII or TwoByte String. The |
| 149 | // characters of the string are uninitialized. Currently used in regexp code |
| 150 | // only, where they are pretenured. |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 151 | Handle<SeqOneByteString> NewRawOneByteString( |
erik.corry@gmail.com | 4a2e25e | 2010-07-07 12:22:46 +0000 | [diff] [blame] | 152 | int length, |
| 153 | PretenureFlag pretenure = NOT_TENURED); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 154 | Handle<SeqTwoByteString> NewRawTwoByteString( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 155 | int length, |
| 156 | PretenureFlag pretenure = NOT_TENURED); |
| 157 | |
| 158 | // Create a new cons string object which consists of a pair of strings. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 159 | Handle<String> NewConsString(Handle<String> first, |
| 160 | Handle<String> second); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 161 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 162 | // Create a new sequential string containing the concatenation of the inputs. |
| 163 | Handle<String> NewFlatConcatString(Handle<String> first, |
| 164 | Handle<String> second); |
| 165 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 166 | // Create a new string object which holds a substring of a string. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 167 | Handle<String> NewSubString(Handle<String> str, |
| 168 | int begin, |
| 169 | int end); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 170 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 171 | // Create a new string object which holds a proper substring of a string. |
| 172 | Handle<String> NewProperSubString(Handle<String> str, |
| 173 | int begin, |
| 174 | int end); |
| 175 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 176 | // Creates a new external String object. There are two String encodings |
| 177 | // in the system: ASCII and two byte. Unlike other String types, it does |
| 178 | // not make sense to have a UTF-8 factory function for external strings, |
| 179 | // because we cannot change the underlying buffer. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 180 | Handle<String> NewExternalStringFromAscii( |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 181 | const ExternalAsciiString::Resource* resource); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 182 | Handle<String> NewExternalStringFromTwoByte( |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 183 | const ExternalTwoByteString::Resource* resource); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 184 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 185 | // Create a symbol. |
| 186 | Handle<Symbol> NewSymbol(); |
| 187 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 188 | // Create a global (but otherwise uninitialized) context. |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 189 | Handle<Context> NewNativeContext(); |
| 190 | |
| 191 | // Create a global context. |
| 192 | Handle<Context> NewGlobalContext(Handle<JSFunction> function, |
| 193 | Handle<ScopeInfo> scope_info); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 194 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 195 | // Create a module context. |
danno@chromium.org | 81cac2b | 2012-07-10 11:28:27 +0000 | [diff] [blame] | 196 | Handle<Context> NewModuleContext(Handle<ScopeInfo> scope_info); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 197 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 198 | // Create a function context. |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 199 | Handle<Context> NewFunctionContext(int length, Handle<JSFunction> function); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 200 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 201 | // Create a catch context. |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 202 | Handle<Context> NewCatchContext(Handle<JSFunction> function, |
| 203 | Handle<Context> previous, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 204 | Handle<String> name, |
| 205 | Handle<Object> thrown_object); |
| 206 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 207 | // Create a 'with' context. |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 208 | Handle<Context> NewWithContext(Handle<JSFunction> function, |
| 209 | Handle<Context> previous, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 210 | Handle<JSObject> extension); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 211 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 212 | // Create a block context. |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 213 | Handle<Context> NewBlockContext(Handle<JSFunction> function, |
| 214 | Handle<Context> previous, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 215 | Handle<ScopeInfo> scope_info); |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 216 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 217 | // Return the internalized version of the passed in string. |
| 218 | Handle<String> InternalizedStringFromString(Handle<String> value); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 219 | |
| 220 | // Allocate a new struct. The struct is pretenured (allocated directly in |
| 221 | // the old generation). |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 222 | Handle<Struct> NewStruct(InstanceType type); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 223 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 224 | Handle<DeclaredAccessorDescriptor> NewDeclaredAccessorDescriptor(); |
| 225 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 226 | Handle<DeclaredAccessorInfo> NewDeclaredAccessorInfo(); |
| 227 | |
| 228 | Handle<ExecutableAccessorInfo> NewExecutableAccessorInfo(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 229 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 230 | Handle<Script> NewScript(Handle<String> source); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 231 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 232 | // Foreign objects are pretenured when allocated by the bootstrapper. |
| 233 | Handle<Foreign> NewForeign(Address addr, |
| 234 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 235 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 236 | // Allocate a new foreign object. The foreign is pretenured (allocated |
| 237 | // directly in the old generation). |
| 238 | Handle<Foreign> NewForeign(const AccessorDescriptor* foreign); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 239 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 240 | Handle<ByteArray> NewByteArray(int length, |
| 241 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 242 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 243 | Handle<ExternalArray> NewExternalArray( |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 244 | int length, |
| 245 | ExternalArrayType array_type, |
| 246 | void* external_pointer, |
| 247 | PretenureFlag pretenure = NOT_TENURED); |
| 248 | |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 249 | Handle<Cell> NewCell(Handle<Object> value); |
| 250 | |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 251 | Handle<PropertyCell> NewPropertyCell(Handle<Object> value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 252 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 253 | Handle<AllocationSite> NewAllocationSite(); |
| 254 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 255 | Handle<Map> NewMap( |
| 256 | InstanceType type, |
| 257 | int instance_size, |
| 258 | ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 259 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 260 | Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 261 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 262 | Handle<Map> CopyWithPreallocatedFieldDescriptors(Handle<Map> map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 263 | |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 264 | // Copy the map adding more inobject properties if possible without |
| 265 | // overflowing the instance size. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 266 | Handle<Map> CopyMap(Handle<Map> map, int extra_inobject_props); |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 267 | Handle<Map> CopyMap(Handle<Map> map); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 268 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 269 | Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, |
| 270 | ElementsKind elements_kind); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 271 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 272 | Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 273 | |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 274 | Handle<FixedArray> CopySizeFixedArray(Handle<FixedArray> array, |
jkummerow@chromium.org | 25b0e21 | 2013-10-04 15:38:52 +0000 | [diff] [blame] | 275 | int new_length, |
| 276 | PretenureFlag pretenure = NOT_TENURED); |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 277 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 278 | Handle<FixedDoubleArray> CopyFixedDoubleArray( |
| 279 | Handle<FixedDoubleArray> array); |
| 280 | |
mstarzinger@chromium.org | a2e1a40 | 2013-10-15 08:25:05 +0000 | [diff] [blame] | 281 | Handle<ConstantPoolArray> CopyConstantPoolArray( |
| 282 | Handle<ConstantPoolArray> array); |
| 283 | |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 284 | // Numbers (e.g. literals) are pretenured by the parser. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 285 | Handle<Object> NewNumber(double value, |
| 286 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 287 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 288 | Handle<Object> NewNumberFromInt(int32_t value, |
| 289 | PretenureFlag pretenure = NOT_TENURED); |
| 290 | Handle<Object> NewNumberFromUint(uint32_t value, |
| 291 | PretenureFlag pretenure = NOT_TENURED); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 292 | inline Handle<Object> NewNumberFromSize(size_t value, |
| 293 | PretenureFlag pretenure = NOT_TENURED); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 294 | Handle<HeapNumber> NewHeapNumber(double value, |
| 295 | PretenureFlag pretenure = NOT_TENURED); |
| 296 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 297 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 298 | // These objects are used by the api to create env-independent data |
| 299 | // structures in the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 300 | Handle<JSObject> NewNeanderObject(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 301 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 302 | Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 303 | |
| 304 | // JS objects are pretenured when allocated by the bootstrapper and |
| 305 | // runtime. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 306 | Handle<JSObject> NewJSObject(Handle<JSFunction> constructor, |
| 307 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 308 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 309 | // Global objects are pretenured. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 310 | Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 311 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 312 | // JS objects are pretenured when allocated by the bootstrapper and |
| 313 | // runtime. |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 314 | Handle<JSObject> NewJSObjectFromMap(Handle<Map> map, |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 315 | PretenureFlag pretenure = NOT_TENURED, |
| 316 | bool allocate_properties = true); |
| 317 | |
| 318 | Handle<JSObject> NewJSObjectFromMapForDeoptimizer( |
| 319 | Handle<Map> map, PretenureFlag pretenure = NOT_TENURED); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 320 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 321 | // JS modules are pretenured. |
danno@chromium.org | 81cac2b | 2012-07-10 11:28:27 +0000 | [diff] [blame] | 322 | Handle<JSModule> NewJSModule(Handle<Context> context, |
| 323 | Handle<ScopeInfo> scope_info); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 324 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 325 | // JS arrays are pretenured when allocated by the parser. |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 326 | Handle<JSArray> NewJSArray( |
| 327 | int capacity, |
| 328 | ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, |
| 329 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 330 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 331 | Handle<JSArray> NewJSArrayWithElements( |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 332 | Handle<FixedArrayBase> elements, |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 333 | ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 334 | PretenureFlag pretenure = NOT_TENURED); |
| 335 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 336 | void SetElementsCapacityAndLength(Handle<JSArray> array, |
| 337 | int capacity, |
| 338 | int length); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 339 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 340 | void SetContent(Handle<JSArray> array, Handle<FixedArrayBase> elements); |
| 341 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 342 | Handle<JSArrayBuffer> NewJSArrayBuffer(); |
| 343 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 344 | Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type); |
| 345 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 346 | Handle<JSDataView> NewJSDataView(); |
| 347 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 348 | Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype); |
| 349 | |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 350 | // Change the type of the argument into a JS object/function and reinitialize. |
| 351 | void BecomeJSObject(Handle<JSReceiver> object); |
| 352 | void BecomeJSFunction(Handle<JSReceiver> object); |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 353 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 354 | Handle<JSFunction> NewFunction(Handle<String> name, |
| 355 | Handle<Object> prototype); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 356 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 357 | Handle<JSFunction> NewFunctionWithoutPrototype( |
| 358 | Handle<String> name, |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 359 | LanguageMode language_mode); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 360 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 361 | Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 362 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 363 | Handle<JSFunction> BaseNewFunctionFromSharedFunctionInfo( |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 364 | Handle<SharedFunctionInfo> function_info, |
| 365 | Handle<Map> function_map, |
| 366 | PretenureFlag pretenure); |
| 367 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 368 | Handle<JSFunction> NewFunctionFromSharedFunctionInfo( |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 369 | Handle<SharedFunctionInfo> function_info, |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 370 | Handle<Context> context, |
| 371 | PretenureFlag pretenure = TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 372 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 373 | Handle<ScopeInfo> NewScopeInfo(int length); |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 374 | |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 375 | Handle<JSObject> NewExternal(void* value); |
| 376 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 377 | Handle<Code> NewCode(const CodeDesc& desc, |
| 378 | Code::Flags flags, |
| 379 | Handle<Object> self_reference, |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 380 | bool immovable = false, |
| 381 | bool crankshafted = false); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 382 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 383 | Handle<Code> CopyCode(Handle<Code> code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 384 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 385 | Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 386 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 387 | Handle<Object> ToObject(Handle<Object> object); |
| 388 | Handle<Object> ToObject(Handle<Object> object, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 389 | Handle<Context> native_context); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 390 | |
| 391 | // Interface for creating error objects. |
| 392 | |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 393 | Handle<Object> NewError(const char* maker, const char* message, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 394 | Handle<JSArray> args); |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 395 | Handle<String> EmergencyNewError(const char* message, Handle<JSArray> args); |
| 396 | Handle<Object> NewError(const char* maker, const char* message, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 397 | Vector< Handle<Object> > args); |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 398 | Handle<Object> NewError(const char* message, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 399 | Vector< Handle<Object> > args); |
| 400 | Handle<Object> NewError(Handle<String> message); |
| 401 | Handle<Object> NewError(const char* constructor, |
| 402 | Handle<String> message); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 403 | |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 404 | Handle<Object> NewTypeError(const char* message, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 405 | Vector< Handle<Object> > args); |
| 406 | Handle<Object> NewTypeError(Handle<String> message); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 407 | |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 408 | Handle<Object> NewRangeError(const char* message, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 409 | Vector< Handle<Object> > args); |
| 410 | Handle<Object> NewRangeError(Handle<String> message); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 411 | |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 412 | Handle<Object> NewSyntaxError(const char* message, Handle<JSArray> args); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 413 | Handle<Object> NewSyntaxError(Handle<String> message); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 414 | |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 415 | Handle<Object> NewReferenceError(const char* message, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 416 | Vector< Handle<Object> > args); |
| 417 | Handle<Object> NewReferenceError(Handle<String> message); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 418 | |
ulan@chromium.org | dfe5307 | 2013-06-06 14:14:51 +0000 | [diff] [blame] | 419 | Handle<Object> NewEvalError(const char* message, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 420 | Vector< Handle<Object> > args); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 421 | |
| 422 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 423 | Handle<JSFunction> NewFunction(Handle<String> name, |
| 424 | InstanceType type, |
| 425 | int instance_size, |
| 426 | Handle<Code> code, |
| 427 | bool force_initial_map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 428 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 429 | Handle<JSFunction> NewFunction(Handle<Map> function_map, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 430 | Handle<SharedFunctionInfo> shared, Handle<Object> prototype); |
| 431 | |
| 432 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 433 | Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name, |
| 434 | InstanceType type, |
| 435 | int instance_size, |
| 436 | Handle<JSObject> prototype, |
| 437 | Handle<Code> code, |
| 438 | bool force_initial_map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 439 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 440 | Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, |
| 441 | Handle<Code> code); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 442 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 443 | Handle<String> NumberToString(Handle<Object> number); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 444 | Handle<String> Uint32ToString(uint32_t value); |
sgjesse@chromium.org | c514574 | 2009-10-07 09:00:33 +0000 | [diff] [blame] | 445 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 446 | enum ApiInstanceType { |
| 447 | JavaScriptObject, |
| 448 | InnerGlobalObject, |
| 449 | OuterGlobalObject |
| 450 | }; |
| 451 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 452 | Handle<JSFunction> CreateApiFunction( |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 453 | Handle<FunctionTemplateInfo> data, |
| 454 | ApiInstanceType type = JavaScriptObject); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 455 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 456 | Handle<JSFunction> InstallMembers(Handle<JSFunction> function); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 457 | |
| 458 | // Installs interceptors on the instance. 'desc' is a function template, |
| 459 | // and instance is an object instance created by the function of this |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 460 | // function template. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 461 | void ConfigureInstance(Handle<FunctionTemplateInfo> desc, |
| 462 | Handle<JSObject> instance, |
| 463 | bool* pending_exception); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 464 | |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 465 | #define ROOT_ACCESSOR(type, name, camel_name) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 466 | inline Handle<type> name() { \ |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 467 | return Handle<type>(BitCast<type**>( \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 468 | &isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 469 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 470 | ROOT_LIST(ROOT_ACCESSOR) |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 471 | #undef ROOT_ACCESSOR |
| 472 | |
| 473 | #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ |
| 474 | inline Handle<Map> name##_map() { \ |
| 475 | return Handle<Map>(BitCast<Map**>( \ |
| 476 | &isolate()->heap()->roots_[Heap::k##Name##MapRootIndex])); \ |
| 477 | } |
| 478 | STRUCT_LIST(STRUCT_MAP_ACCESSOR) |
| 479 | #undef STRUCT_MAP_ACCESSOR |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 480 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 481 | #define STRING_ACCESSOR(name, str) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 482 | inline Handle<String> name() { \ |
vegorov@chromium.org | 26c16f8 | 2010-08-11 13:41:03 +0000 | [diff] [blame] | 483 | return Handle<String>(BitCast<String**>( \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 484 | &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 485 | } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 486 | INTERNALIZED_STRING_LIST(STRING_ACCESSOR) |
| 487 | #undef STRING_ACCESSOR |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 488 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 489 | Handle<String> hidden_string() { |
| 490 | return Handle<String>(&isolate()->heap()->hidden_string_); |
ager@chromium.org | 3b45ab5 | 2009-03-19 22:21:34 +0000 | [diff] [blame] | 491 | } |
| 492 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 493 | Handle<SharedFunctionInfo> NewSharedFunctionInfo( |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 494 | Handle<String> name, |
| 495 | int number_of_literals, |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 496 | bool is_generator, |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 497 | Handle<Code> code, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 498 | Handle<ScopeInfo> scope_info); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 499 | Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 500 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 501 | Handle<JSMessageObject> NewJSMessageObject( |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 502 | Handle<String> type, |
| 503 | Handle<JSArray> arguments, |
| 504 | int start_position, |
| 505 | int end_position, |
| 506 | Handle<Object> script, |
| 507 | Handle<Object> stack_trace, |
| 508 | Handle<Object> stack_frames); |
| 509 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 510 | Handle<SeededNumberDictionary> DictionaryAtNumberPut( |
| 511 | Handle<SeededNumberDictionary>, |
| 512 | uint32_t key, |
| 513 | Handle<Object> value); |
| 514 | |
| 515 | Handle<UnseededNumberDictionary> DictionaryAtNumberPut( |
| 516 | Handle<UnseededNumberDictionary>, |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 517 | uint32_t key, |
| 518 | Handle<Object> value); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 519 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 520 | #ifdef ENABLE_DEBUGGER_SUPPORT |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 521 | Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 522 | #endif |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 523 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 524 | // Return a map using the map cache in the native context. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 525 | // The key the an ordered set of property names. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 526 | Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context, |
| 527 | Handle<FixedArray> keys); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 528 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 529 | // Creates a new FixedArray that holds the data associated with the |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 530 | // atom regexp and stores it in the regexp. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 531 | void SetRegExpAtomData(Handle<JSRegExp> regexp, |
| 532 | JSRegExp::Type type, |
| 533 | Handle<String> source, |
| 534 | JSRegExp::Flags flags, |
| 535 | Handle<Object> match_pattern); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 536 | |
| 537 | // Creates a new FixedArray that holds the data associated with the |
| 538 | // irregexp regexp and stores it in the regexp. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 539 | void SetRegExpIrregexpData(Handle<JSRegExp> regexp, |
| 540 | JSRegExp::Type type, |
| 541 | Handle<String> source, |
| 542 | JSRegExp::Flags flags, |
| 543 | int capture_count); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 544 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 545 | // Returns the value for a known global constant (a property of the global |
| 546 | // object which is neither configurable nor writable) like 'undefined'. |
| 547 | // Returns a null handle when the given name is unknown. |
| 548 | Handle<Object> GlobalConstantFor(Handle<String> name); |
| 549 | |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 550 | // Converts the given boolean condition to JavaScript boolean value. |
| 551 | Handle<Object> ToBoolean(bool value); |
| 552 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 553 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 554 | Isolate* isolate() { return reinterpret_cast<Isolate*>(this); } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 555 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 556 | Handle<JSFunction> NewFunctionHelper(Handle<String> name, |
| 557 | Handle<Object> prototype); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 558 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 559 | Handle<JSFunction> NewFunctionWithoutPrototypeHelper( |
| 560 | Handle<String> name, |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 561 | LanguageMode language_mode); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 562 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 563 | // Create a new map cache. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 564 | Handle<MapCache> NewMapCache(int at_least_space_for); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 565 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 566 | // Update the map cache in the native context with (keys, map) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 567 | Handle<MapCache> AddToMapCache(Handle<Context> context, |
| 568 | Handle<FixedArray> keys, |
| 569 | Handle<Map> map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 570 | }; |
| 571 | |
| 572 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 573 | Handle<Object> Factory::NewNumberFromSize(size_t value, |
| 574 | PretenureFlag pretenure) { |
| 575 | if (Smi::IsValid(static_cast<intptr_t>(value))) { |
| 576 | return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)), |
| 577 | isolate()); |
| 578 | } else { |
| 579 | return NewNumber(static_cast<double>(value), pretenure); |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 584 | // Used to "safely" transition from pointer-based runtime code to Handle-based |
| 585 | // runtime code. When a GC happens during the called Handle-based code, a |
| 586 | // failure object is returned to the pointer-based code to cause it abort and |
| 587 | // re-trigger a gc of it's own. Since this double-gc will cause the Handle-based |
| 588 | // code to be called twice, it must be idempotent. |
| 589 | class IdempotentPointerToHandleCodeTrampoline { |
| 590 | public: |
| 591 | explicit IdempotentPointerToHandleCodeTrampoline(Isolate* isolate) |
| 592 | : isolate_(isolate) {} |
| 593 | |
| 594 | template<typename R> |
| 595 | MUST_USE_RESULT MaybeObject* Call(R (*function)()) { |
| 596 | int collections = isolate_->heap()->gc_count(); |
| 597 | (*function)(); |
| 598 | return (collections == isolate_->heap()->gc_count()) |
| 599 | ? isolate_->heap()->true_value() |
| 600 | : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); |
| 601 | } |
| 602 | |
| 603 | template<typename R> |
| 604 | MUST_USE_RESULT MaybeObject* CallWithReturnValue(R (*function)()) { |
| 605 | int collections = isolate_->heap()->gc_count(); |
| 606 | Object* result = (*function)(); |
| 607 | return (collections == isolate_->heap()->gc_count()) |
| 608 | ? result |
| 609 | : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); |
| 610 | } |
| 611 | |
| 612 | template<typename R, typename P1> |
| 613 | MUST_USE_RESULT MaybeObject* Call(R (*function)(P1), P1 p1) { |
| 614 | int collections = isolate_->heap()->gc_count(); |
| 615 | (*function)(p1); |
| 616 | return (collections == isolate_->heap()->gc_count()) |
| 617 | ? isolate_->heap()->true_value() |
| 618 | : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); |
| 619 | } |
| 620 | |
| 621 | template<typename R, typename P1> |
| 622 | MUST_USE_RESULT MaybeObject* CallWithReturnValue( |
| 623 | R (*function)(P1), |
| 624 | P1 p1) { |
| 625 | int collections = isolate_->heap()->gc_count(); |
| 626 | Object* result = (*function)(p1); |
| 627 | return (collections == isolate_->heap()->gc_count()) |
| 628 | ? result |
| 629 | : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); |
| 630 | } |
| 631 | |
| 632 | template<typename R, typename P1, typename P2> |
| 633 | MUST_USE_RESULT MaybeObject* Call( |
| 634 | R (*function)(P1, P2), |
| 635 | P1 p1, |
| 636 | P2 p2) { |
| 637 | int collections = isolate_->heap()->gc_count(); |
| 638 | (*function)(p1, p2); |
| 639 | return (collections == isolate_->heap()->gc_count()) |
| 640 | ? isolate_->heap()->true_value() |
| 641 | : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); |
| 642 | } |
| 643 | |
| 644 | template<typename R, typename P1, typename P2> |
| 645 | MUST_USE_RESULT MaybeObject* CallWithReturnValue( |
| 646 | R (*function)(P1, P2), |
| 647 | P1 p1, |
| 648 | P2 p2) { |
| 649 | int collections = isolate_->heap()->gc_count(); |
| 650 | Object* result = (*function)(p1, p2); |
| 651 | return (collections == isolate_->heap()->gc_count()) |
| 652 | ? result |
| 653 | : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); |
| 654 | } |
| 655 | |
hpayer@chromium.org | c5d4971 | 2013-09-11 08:25:48 +0000 | [diff] [blame] | 656 | template<typename R, typename P1, typename P2, typename P3, typename P4, |
| 657 | typename P5, typename P6, typename P7> |
| 658 | MUST_USE_RESULT MaybeObject* CallWithReturnValue( |
| 659 | R (*function)(P1, P2, P3, P4, P5, P6, P7), |
| 660 | P1 p1, |
| 661 | P2 p2, |
| 662 | P3 p3, |
| 663 | P4 p4, |
| 664 | P5 p5, |
| 665 | P6 p6, |
| 666 | P7 p7) { |
| 667 | int collections = isolate_->heap()->gc_count(); |
| 668 | Handle<Object> result = (*function)(p1, p2, p3, p4, p5, p6, p7); |
| 669 | return (collections == isolate_->heap()->gc_count()) |
| 670 | ? *result |
| 671 | : reinterpret_cast<MaybeObject*>(Failure::RetryAfterGC()); |
| 672 | } |
| 673 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 674 | private: |
| 675 | Isolate* isolate_; |
| 676 | }; |
| 677 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 678 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 679 | } } // namespace v8::internal |
| 680 | |
| 681 | #endif // V8_FACTORY_H_ |