blob: 71bfdc4c4b55b126fc959d7e9cf36ab8545ead37 [file] [log] [blame]
Ben Murdochb0fe1622011-05-05 13:52:32 +01001// Copyright 2010 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002// 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
31#include "globals.h"
Steve Block44f0eee2011-05-26 01:26:41 +010032#include "handles.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000033#include "heap.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000034
35namespace v8 {
36namespace internal {
37
Steve Blocka7e24c12009-10-30 11:49:00 +000038// Interface for handle based allocation.
39
Steve Block44f0eee2011-05-26 01:26:41 +010040class Factory {
Steve Blocka7e24c12009-10-30 11:49:00 +000041 public:
42 // Allocate a new fixed array with undefined entries.
Steve Block44f0eee2011-05-26 01:26:41 +010043 Handle<FixedArray> NewFixedArray(
Steve Blocka7e24c12009-10-30 11:49:00 +000044 int size,
45 PretenureFlag pretenure = NOT_TENURED);
46
47 // Allocate a new fixed array with non-existing entries (the hole).
Steve Block44f0eee2011-05-26 01:26:41 +010048 Handle<FixedArray> NewFixedArrayWithHoles(
Steve Block6ded16b2010-05-10 14:33:55 +010049 int size,
50 PretenureFlag pretenure = NOT_TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +000051
Steve Block44f0eee2011-05-26 01:26:41 +010052 Handle<NumberDictionary> NewNumberDictionary(int at_least_space_for);
Steve Blocka7e24c12009-10-30 11:49:00 +000053
Steve Block44f0eee2011-05-26 01:26:41 +010054 Handle<StringDictionary> NewStringDictionary(int at_least_space_for);
Steve Blocka7e24c12009-10-30 11:49:00 +000055
Steve Block44f0eee2011-05-26 01:26:41 +010056 Handle<DescriptorArray> NewDescriptorArray(int number_of_descriptors);
57 Handle<DeoptimizationInputData> NewDeoptimizationInputData(
Ben Murdochb0fe1622011-05-05 13:52:32 +010058 int deopt_entry_count,
59 PretenureFlag pretenure);
Steve Block44f0eee2011-05-26 01:26:41 +010060 Handle<DeoptimizationOutputData> NewDeoptimizationOutputData(
Ben Murdochb0fe1622011-05-05 13:52:32 +010061 int deopt_entry_count,
62 PretenureFlag pretenure);
Steve Blocka7e24c12009-10-30 11:49:00 +000063
Steve Block44f0eee2011-05-26 01:26:41 +010064 Handle<String> LookupSymbol(Vector<const char> str);
65 Handle<String> LookupAsciiSymbol(Vector<const char> str);
66 Handle<String> LookupTwoByteSymbol(Vector<const uc16> str);
67 Handle<String> LookupAsciiSymbol(const char* str) {
Steve Blocka7e24c12009-10-30 11:49:00 +000068 return LookupSymbol(CStrVector(str));
69 }
70
71
72 // String creation functions. Most of the string creation functions take
73 // a Heap::PretenureFlag argument to optionally request that they be
74 // allocated in the old generation. The pretenure flag defaults to
75 // DONT_TENURE.
76 //
77 // Creates a new String object. There are two String encodings: ASCII and
78 // two byte. One should choose between the three string factory functions
79 // based on the encoding of the string buffer that the string is
80 // initialized from.
81 // - ...FromAscii initializes the string from a buffer that is ASCII
82 // encoded (it does not check that the buffer is ASCII encoded) and
83 // the result will be ASCII encoded.
84 // - ...FromUtf8 initializes the string from a buffer that is UTF-8
85 // encoded. If the characters are all single-byte characters, the
86 // result will be ASCII encoded, otherwise it will converted to two
87 // byte.
88 // - ...FromTwoByte initializes the string from a buffer that is two
89 // byte encoded. If the characters are all single-byte characters,
90 // the result will be converted to ASCII, otherwise it will be left as
91 // two byte.
92 //
93 // ASCII strings are pretenured when used as keys in the SourceCodeCache.
Steve Block44f0eee2011-05-26 01:26:41 +010094 Handle<String> NewStringFromAscii(
Steve Blocka7e24c12009-10-30 11:49:00 +000095 Vector<const char> str,
96 PretenureFlag pretenure = NOT_TENURED);
97
98 // UTF8 strings are pretenured when used for regexp literal patterns and
99 // flags in the parser.
Steve Block44f0eee2011-05-26 01:26:41 +0100100 Handle<String> NewStringFromUtf8(
Steve Blocka7e24c12009-10-30 11:49:00 +0000101 Vector<const char> str,
102 PretenureFlag pretenure = NOT_TENURED);
103
Steve Block44f0eee2011-05-26 01:26:41 +0100104 Handle<String> NewStringFromTwoByte(
Leon Clarkeac952652010-07-15 11:15:24 +0100105 Vector<const uc16> str,
Steve Blocka7e24c12009-10-30 11:49:00 +0000106 PretenureFlag pretenure = NOT_TENURED);
107
Leon Clarkeac952652010-07-15 11:15:24 +0100108 // Allocates and partially initializes an ASCII or TwoByte String. The
109 // characters of the string are uninitialized. Currently used in regexp code
110 // only, where they are pretenured.
Steve Block44f0eee2011-05-26 01:26:41 +0100111 Handle<String> NewRawAsciiString(
Leon Clarkeac952652010-07-15 11:15:24 +0100112 int length,
113 PretenureFlag pretenure = NOT_TENURED);
Steve Block44f0eee2011-05-26 01:26:41 +0100114 Handle<String> NewRawTwoByteString(
Steve Blocka7e24c12009-10-30 11:49:00 +0000115 int length,
116 PretenureFlag pretenure = NOT_TENURED);
117
118 // Create a new cons string object which consists of a pair of strings.
Steve Block44f0eee2011-05-26 01:26:41 +0100119 Handle<String> NewConsString(Handle<String> first,
120 Handle<String> second);
Steve Blocka7e24c12009-10-30 11:49:00 +0000121
Steve Blockd0582a62009-12-15 09:54:21 +0000122 // Create a new string object which holds a substring of a string.
Steve Block44f0eee2011-05-26 01:26:41 +0100123 Handle<String> NewSubString(Handle<String> str,
124 int begin,
125 int end);
Steve Blocka7e24c12009-10-30 11:49:00 +0000126
127 // Creates a new external String object. There are two String encodings
128 // in the system: ASCII and two byte. Unlike other String types, it does
129 // not make sense to have a UTF-8 factory function for external strings,
130 // because we cannot change the underlying buffer.
Steve Block44f0eee2011-05-26 01:26:41 +0100131 Handle<String> NewExternalStringFromAscii(
Steve Blocka7e24c12009-10-30 11:49:00 +0000132 ExternalAsciiString::Resource* resource);
Steve Block44f0eee2011-05-26 01:26:41 +0100133 Handle<String> NewExternalStringFromTwoByte(
Steve Blocka7e24c12009-10-30 11:49:00 +0000134 ExternalTwoByteString::Resource* resource);
135
136 // Create a global (but otherwise uninitialized) context.
Steve Block44f0eee2011-05-26 01:26:41 +0100137 Handle<Context> NewGlobalContext();
Steve Blocka7e24c12009-10-30 11:49:00 +0000138
139 // Create a function context.
Steve Block44f0eee2011-05-26 01:26:41 +0100140 Handle<Context> NewFunctionContext(int length,
141 Handle<JSFunction> closure);
Steve Blocka7e24c12009-10-30 11:49:00 +0000142
143 // Create a 'with' context.
Steve Block44f0eee2011-05-26 01:26:41 +0100144 Handle<Context> NewWithContext(Handle<Context> previous,
145 Handle<JSObject> extension,
146 bool is_catch_context);
Steve Blocka7e24c12009-10-30 11:49:00 +0000147
148 // Return the Symbol matching the passed in string.
Steve Block44f0eee2011-05-26 01:26:41 +0100149 Handle<String> SymbolFromString(Handle<String> value);
Steve Blocka7e24c12009-10-30 11:49:00 +0000150
151 // Allocate a new struct. The struct is pretenured (allocated directly in
152 // the old generation).
Steve Block44f0eee2011-05-26 01:26:41 +0100153 Handle<Struct> NewStruct(InstanceType type);
Steve Blocka7e24c12009-10-30 11:49:00 +0000154
Steve Block44f0eee2011-05-26 01:26:41 +0100155 Handle<AccessorInfo> NewAccessorInfo();
Steve Blocka7e24c12009-10-30 11:49:00 +0000156
Steve Block44f0eee2011-05-26 01:26:41 +0100157 Handle<Script> NewScript(Handle<String> source);
Steve Blocka7e24c12009-10-30 11:49:00 +0000158
159 // Proxies are pretenured when allocated by the bootstrapper.
Steve Block44f0eee2011-05-26 01:26:41 +0100160 Handle<Proxy> NewProxy(Address addr,
161 PretenureFlag pretenure = NOT_TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000162
163 // Allocate a new proxy. The proxy is pretenured (allocated directly in
164 // the old generation).
Steve Block44f0eee2011-05-26 01:26:41 +0100165 Handle<Proxy> NewProxy(const AccessorDescriptor* proxy);
Steve Blocka7e24c12009-10-30 11:49:00 +0000166
Steve Block44f0eee2011-05-26 01:26:41 +0100167 Handle<ByteArray> NewByteArray(int length,
168 PretenureFlag pretenure = NOT_TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000169
Steve Block44f0eee2011-05-26 01:26:41 +0100170 Handle<ExternalArray> NewExternalArray(
Steve Block3ce2e202009-11-05 08:53:23 +0000171 int length,
172 ExternalArrayType array_type,
173 void* external_pointer,
174 PretenureFlag pretenure = NOT_TENURED);
175
Steve Block44f0eee2011-05-26 01:26:41 +0100176 Handle<JSGlobalPropertyCell> NewJSGlobalPropertyCell(
Ben Murdochb0fe1622011-05-05 13:52:32 +0100177 Handle<Object> value);
178
Steve Block44f0eee2011-05-26 01:26:41 +0100179 Handle<Map> NewMap(InstanceType type, int instance_size);
Steve Blocka7e24c12009-10-30 11:49:00 +0000180
Steve Block44f0eee2011-05-26 01:26:41 +0100181 Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
Steve Blocka7e24c12009-10-30 11:49:00 +0000182
Steve Block44f0eee2011-05-26 01:26:41 +0100183 Handle<Map> CopyMapDropDescriptors(Handle<Map> map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000184
185 // Copy the map adding more inobject properties if possible without
186 // overflowing the instance size.
Steve Block44f0eee2011-05-26 01:26:41 +0100187 Handle<Map> CopyMap(Handle<Map> map, int extra_inobject_props);
Steve Blocka7e24c12009-10-30 11:49:00 +0000188
Steve Block44f0eee2011-05-26 01:26:41 +0100189 Handle<Map> CopyMapDropTransitions(Handle<Map> map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000190
Steve Block44f0eee2011-05-26 01:26:41 +0100191 Handle<Map> GetFastElementsMap(Handle<Map> map);
Steve Block8defd9f2010-07-08 12:39:36 +0100192
Steve Block44f0eee2011-05-26 01:26:41 +0100193 Handle<Map> GetSlowElementsMap(Handle<Map> map);
Steve Block8defd9f2010-07-08 12:39:36 +0100194
Steve Block44f0eee2011-05-26 01:26:41 +0100195 Handle<Map> GetExternalArrayElementsMap(Handle<Map> map,
196 ExternalArrayType array_type,
197 bool safe_to_add_transition);
Steve Block1e0659c2011-05-24 12:43:12 +0100198
Steve Block44f0eee2011-05-26 01:26:41 +0100199 Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
Steve Blocka7e24c12009-10-30 11:49:00 +0000200
201 // Numbers (eg, literals) are pretenured by the parser.
Steve Block44f0eee2011-05-26 01:26:41 +0100202 Handle<Object> NewNumber(double value,
203 PretenureFlag pretenure = NOT_TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000204
Steve Block44f0eee2011-05-26 01:26:41 +0100205 Handle<Object> NewNumberFromInt(int value);
206 Handle<Object> NewNumberFromUint(uint32_t value);
Steve Blocka7e24c12009-10-30 11:49:00 +0000207
208 // These objects are used by the api to create env-independent data
209 // structures in the heap.
Steve Block44f0eee2011-05-26 01:26:41 +0100210 Handle<JSObject> NewNeanderObject();
Steve Blocka7e24c12009-10-30 11:49:00 +0000211
Steve Block44f0eee2011-05-26 01:26:41 +0100212 Handle<JSObject> NewArgumentsObject(Handle<Object> callee, int length);
Steve Blocka7e24c12009-10-30 11:49:00 +0000213
214 // JS objects are pretenured when allocated by the bootstrapper and
215 // runtime.
Steve Block44f0eee2011-05-26 01:26:41 +0100216 Handle<JSObject> NewJSObject(Handle<JSFunction> constructor,
217 PretenureFlag pretenure = NOT_TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000218
219 // Global objects are pretenured.
Steve Block44f0eee2011-05-26 01:26:41 +0100220 Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor);
Steve Blocka7e24c12009-10-30 11:49:00 +0000221
222 // JS objects are pretenured when allocated by the bootstrapper and
223 // runtime.
Steve Block44f0eee2011-05-26 01:26:41 +0100224 Handle<JSObject> NewJSObjectFromMap(Handle<Map> map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000225
226 // JS arrays are pretenured when allocated by the parser.
Steve Block44f0eee2011-05-26 01:26:41 +0100227 Handle<JSArray> NewJSArray(int capacity,
228 PretenureFlag pretenure = NOT_TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000229
Steve Block44f0eee2011-05-26 01:26:41 +0100230 Handle<JSArray> NewJSArrayWithElements(
Steve Blocka7e24c12009-10-30 11:49:00 +0000231 Handle<FixedArray> elements,
232 PretenureFlag pretenure = NOT_TENURED);
233
Steve Block44f0eee2011-05-26 01:26:41 +0100234 Handle<JSFunction> NewFunction(Handle<String> name,
235 Handle<Object> prototype);
Steve Blocka7e24c12009-10-30 11:49:00 +0000236
Steve Block44f0eee2011-05-26 01:26:41 +0100237 Handle<JSFunction> NewFunctionWithoutPrototype(
238 Handle<String> name,
239 StrictModeFlag strict_mode);
Steve Block6ded16b2010-05-10 14:33:55 +0100240
Steve Block44f0eee2011-05-26 01:26:41 +0100241 Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global);
Steve Blocka7e24c12009-10-30 11:49:00 +0000242
Steve Block44f0eee2011-05-26 01:26:41 +0100243 Handle<JSFunction> BaseNewFunctionFromSharedFunctionInfo(
Steve Block6ded16b2010-05-10 14:33:55 +0100244 Handle<SharedFunctionInfo> function_info,
245 Handle<Map> function_map,
246 PretenureFlag pretenure);
247
Steve Block44f0eee2011-05-26 01:26:41 +0100248 Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
Steve Block6ded16b2010-05-10 14:33:55 +0100249 Handle<SharedFunctionInfo> function_info,
Leon Clarkee46be812010-01-19 14:06:41 +0000250 Handle<Context> context,
251 PretenureFlag pretenure = TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000252
Steve Block44f0eee2011-05-26 01:26:41 +0100253 Handle<Code> NewCode(const CodeDesc& desc,
254 Code::Flags flags,
255 Handle<Object> self_reference,
256 bool immovable = false);
Steve Blocka7e24c12009-10-30 11:49:00 +0000257
Steve Block44f0eee2011-05-26 01:26:41 +0100258 Handle<Code> CopyCode(Handle<Code> code);
Steve Blocka7e24c12009-10-30 11:49:00 +0000259
Steve Block44f0eee2011-05-26 01:26:41 +0100260 Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info);
Steve Block6ded16b2010-05-10 14:33:55 +0100261
Steve Block44f0eee2011-05-26 01:26:41 +0100262 Handle<Object> ToObject(Handle<Object> object);
263 Handle<Object> ToObject(Handle<Object> object,
264 Handle<Context> global_context);
Steve Blocka7e24c12009-10-30 11:49:00 +0000265
266 // Interface for creating error objects.
267
Steve Block44f0eee2011-05-26 01:26:41 +0100268 Handle<Object> NewError(const char* maker, const char* type,
269 Handle<JSArray> args);
270 Handle<Object> NewError(const char* maker, const char* type,
271 Vector< Handle<Object> > args);
272 Handle<Object> NewError(const char* type,
273 Vector< Handle<Object> > args);
274 Handle<Object> NewError(Handle<String> message);
275 Handle<Object> NewError(const char* constructor,
276 Handle<String> message);
Steve Blocka7e24c12009-10-30 11:49:00 +0000277
Steve Block44f0eee2011-05-26 01:26:41 +0100278 Handle<Object> NewTypeError(const char* type,
279 Vector< Handle<Object> > args);
280 Handle<Object> NewTypeError(Handle<String> message);
Steve Blocka7e24c12009-10-30 11:49:00 +0000281
Steve Block44f0eee2011-05-26 01:26:41 +0100282 Handle<Object> NewRangeError(const char* type,
283 Vector< Handle<Object> > args);
284 Handle<Object> NewRangeError(Handle<String> message);
Steve Blocka7e24c12009-10-30 11:49:00 +0000285
Steve Block44f0eee2011-05-26 01:26:41 +0100286 Handle<Object> NewSyntaxError(const char* type, Handle<JSArray> args);
287 Handle<Object> NewSyntaxError(Handle<String> message);
Steve Blocka7e24c12009-10-30 11:49:00 +0000288
Steve Block44f0eee2011-05-26 01:26:41 +0100289 Handle<Object> NewReferenceError(const char* type,
290 Vector< Handle<Object> > args);
291 Handle<Object> NewReferenceError(Handle<String> message);
Steve Blocka7e24c12009-10-30 11:49:00 +0000292
Steve Block44f0eee2011-05-26 01:26:41 +0100293 Handle<Object> NewEvalError(const char* type,
294 Vector< Handle<Object> > args);
Steve Blocka7e24c12009-10-30 11:49:00 +0000295
296
Steve Block44f0eee2011-05-26 01:26:41 +0100297 Handle<JSFunction> NewFunction(Handle<String> name,
298 InstanceType type,
299 int instance_size,
300 Handle<Code> code,
301 bool force_initial_map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000302
Steve Block44f0eee2011-05-26 01:26:41 +0100303 Handle<JSFunction> NewFunction(Handle<Map> function_map,
Steve Blocka7e24c12009-10-30 11:49:00 +0000304 Handle<SharedFunctionInfo> shared, Handle<Object> prototype);
305
306
Steve Block44f0eee2011-05-26 01:26:41 +0100307 Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name,
308 InstanceType type,
309 int instance_size,
310 Handle<JSObject> prototype,
311 Handle<Code> code,
312 bool force_initial_map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000313
Steve Block44f0eee2011-05-26 01:26:41 +0100314 Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
315 Handle<Code> code);
Steve Block6ded16b2010-05-10 14:33:55 +0100316
Steve Block44f0eee2011-05-26 01:26:41 +0100317 Handle<DescriptorArray> CopyAppendProxyDescriptor(
Steve Blocka7e24c12009-10-30 11:49:00 +0000318 Handle<DescriptorArray> array,
319 Handle<String> key,
320 Handle<Object> value,
321 PropertyAttributes attributes);
322
Steve Block44f0eee2011-05-26 01:26:41 +0100323 Handle<String> NumberToString(Handle<Object> number);
Steve Blocka7e24c12009-10-30 11:49:00 +0000324
325 enum ApiInstanceType {
326 JavaScriptObject,
327 InnerGlobalObject,
328 OuterGlobalObject
329 };
330
Steve Block44f0eee2011-05-26 01:26:41 +0100331 Handle<JSFunction> CreateApiFunction(
Steve Blocka7e24c12009-10-30 11:49:00 +0000332 Handle<FunctionTemplateInfo> data,
333 ApiInstanceType type = JavaScriptObject);
334
Steve Block44f0eee2011-05-26 01:26:41 +0100335 Handle<JSFunction> InstallMembers(Handle<JSFunction> function);
Steve Blocka7e24c12009-10-30 11:49:00 +0000336
337 // Installs interceptors on the instance. 'desc' is a function template,
338 // and instance is an object instance created by the function of this
339 // function template.
Steve Block44f0eee2011-05-26 01:26:41 +0100340 void ConfigureInstance(Handle<FunctionTemplateInfo> desc,
341 Handle<JSObject> instance,
342 bool* pending_exception);
Steve Blocka7e24c12009-10-30 11:49:00 +0000343
344#define ROOT_ACCESSOR(type, name, camel_name) \
Steve Block44f0eee2011-05-26 01:26:41 +0100345 inline Handle<type> name() { \
Iain Merrick75681382010-08-19 15:07:18 +0100346 return Handle<type>(BitCast<type**>( \
Steve Block44f0eee2011-05-26 01:26:41 +0100347 &isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \
Steve Blocka7e24c12009-10-30 11:49:00 +0000348 }
349 ROOT_LIST(ROOT_ACCESSOR)
350#undef ROOT_ACCESSOR_ACCESSOR
351
Steve Block44f0eee2011-05-26 01:26:41 +0100352#define SYMBOL_ACCESSOR(name, str) \
353 inline Handle<String> name() { \
Iain Merrick75681382010-08-19 15:07:18 +0100354 return Handle<String>(BitCast<String**>( \
Steve Block44f0eee2011-05-26 01:26:41 +0100355 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
Steve Blocka7e24c12009-10-30 11:49:00 +0000356 }
357 SYMBOL_LIST(SYMBOL_ACCESSOR)
358#undef SYMBOL_ACCESSOR
359
Steve Block44f0eee2011-05-26 01:26:41 +0100360 Handle<String> hidden_symbol() {
361 return Handle<String>(&isolate()->heap()->hidden_symbol_);
Steve Blocka7e24c12009-10-30 11:49:00 +0000362 }
363
Steve Block44f0eee2011-05-26 01:26:41 +0100364 Handle<SharedFunctionInfo> NewSharedFunctionInfo(
Ben Murdoch3bec4d22010-07-22 14:51:16 +0100365 Handle<String> name,
366 int number_of_literals,
367 Handle<Code> code,
368 Handle<SerializedScopeInfo> scope_info);
Steve Block44f0eee2011-05-26 01:26:41 +0100369 Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name);
Steve Blocka7e24c12009-10-30 11:49:00 +0000370
Steve Block44f0eee2011-05-26 01:26:41 +0100371 Handle<JSMessageObject> NewJSMessageObject(
Steve Block1e0659c2011-05-24 12:43:12 +0100372 Handle<String> type,
373 Handle<JSArray> arguments,
374 int start_position,
375 int end_position,
376 Handle<Object> script,
377 Handle<Object> stack_trace,
378 Handle<Object> stack_frames);
379
Steve Block44f0eee2011-05-26 01:26:41 +0100380 Handle<NumberDictionary> DictionaryAtNumberPut(
Steve Blocka7e24c12009-10-30 11:49:00 +0000381 Handle<NumberDictionary>,
382 uint32_t key,
383 Handle<Object> value);
384
385#ifdef ENABLE_DEBUGGER_SUPPORT
Steve Block44f0eee2011-05-26 01:26:41 +0100386 Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
Steve Blocka7e24c12009-10-30 11:49:00 +0000387#endif
388
389 // Return a map using the map cache in the global context.
390 // The key the an ordered set of property names.
Steve Block44f0eee2011-05-26 01:26:41 +0100391 Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context,
392 Handle<FixedArray> keys);
Steve Blocka7e24c12009-10-30 11:49:00 +0000393
394 // Creates a new FixedArray that holds the data associated with the
395 // atom regexp and stores it in the regexp.
Steve Block44f0eee2011-05-26 01:26:41 +0100396 void SetRegExpAtomData(Handle<JSRegExp> regexp,
397 JSRegExp::Type type,
398 Handle<String> source,
399 JSRegExp::Flags flags,
400 Handle<Object> match_pattern);
Steve Blocka7e24c12009-10-30 11:49:00 +0000401
402 // Creates a new FixedArray that holds the data associated with the
403 // irregexp regexp and stores it in the regexp.
Steve Block44f0eee2011-05-26 01:26:41 +0100404 void SetRegExpIrregexpData(Handle<JSRegExp> regexp,
405 JSRegExp::Type type,
406 Handle<String> source,
407 JSRegExp::Flags flags,
408 int capture_count);
Steve Blocka7e24c12009-10-30 11:49:00 +0000409
410 private:
Steve Block44f0eee2011-05-26 01:26:41 +0100411 Isolate* isolate() { return reinterpret_cast<Isolate*>(this); }
Steve Blocka7e24c12009-10-30 11:49:00 +0000412
Steve Block44f0eee2011-05-26 01:26:41 +0100413 Handle<JSFunction> NewFunctionHelper(Handle<String> name,
414 Handle<Object> prototype);
Steve Block6ded16b2010-05-10 14:33:55 +0100415
Steve Block44f0eee2011-05-26 01:26:41 +0100416 Handle<JSFunction> NewFunctionWithoutPrototypeHelper(
417 Handle<String> name,
418 StrictModeFlag strict_mode);
419
420 Handle<DescriptorArray> CopyAppendCallbackDescriptors(
Steve Blocka7e24c12009-10-30 11:49:00 +0000421 Handle<DescriptorArray> array,
422 Handle<Object> descriptors);
423
Steve Blocka7e24c12009-10-30 11:49:00 +0000424 // Create a new map cache.
Steve Block44f0eee2011-05-26 01:26:41 +0100425 Handle<MapCache> NewMapCache(int at_least_space_for);
Steve Blocka7e24c12009-10-30 11:49:00 +0000426
427 // Update the map cache in the global context with (keys, map)
Steve Block44f0eee2011-05-26 01:26:41 +0100428 Handle<MapCache> AddToMapCache(Handle<Context> context,
429 Handle<FixedArray> keys,
430 Handle<Map> map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000431};
432
433
434} } // namespace v8::internal
435
436#endif // V8_FACTORY_H_