1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "src/isolate.h"
13 class FeedbackVectorSpec;
15 // Interface for handle based allocation.
18 Handle<Oddball> NewOddball(Handle<Map> map,
19 const char* to_string,
20 Handle<Object> to_number,
23 // Allocates a fixed array initialized with undefined values.
24 Handle<FixedArray> NewFixedArray(
26 PretenureFlag pretenure = NOT_TENURED);
28 // Allocate a new fixed array with non-existing entries (the hole).
29 Handle<FixedArray> NewFixedArrayWithHoles(
31 PretenureFlag pretenure = NOT_TENURED);
33 // Allocates an uninitialized fixed array. It must be filled by the caller.
34 Handle<FixedArray> NewUninitializedFixedArray(int size);
36 // Allocate a new uninitialized fixed double array.
37 // The function returns a pre-allocated empty fixed array for capacity = 0,
38 // so the return type must be the general fixed array class.
39 Handle<FixedArrayBase> NewFixedDoubleArray(
41 PretenureFlag pretenure = NOT_TENURED);
43 // Allocate a new fixed double array with hole values.
44 Handle<FixedArrayBase> NewFixedDoubleArrayWithHoles(
46 PretenureFlag pretenure = NOT_TENURED);
48 Handle<ConstantPoolArray> NewConstantPoolArray(
49 const ConstantPoolArray::NumberOfEntries& small);
51 Handle<ConstantPoolArray> NewExtendedConstantPoolArray(
52 const ConstantPoolArray::NumberOfEntries& small,
53 const ConstantPoolArray::NumberOfEntries& extended);
55 Handle<OrderedHashSet> NewOrderedHashSet();
56 Handle<OrderedHashMap> NewOrderedHashMap();
58 // Create a new boxed value.
59 Handle<Box> NewBox(Handle<Object> value);
61 // Create a pre-tenured empty AccessorPair.
62 Handle<AccessorPair> NewAccessorPair();
64 // Create an empty TypeFeedbackInfo.
65 Handle<TypeFeedbackInfo> NewTypeFeedbackInfo();
67 // Finds the internalized copy for string in the string table.
68 // If not found, a new string is added to the table and returned.
69 Handle<String> InternalizeUtf8String(Vector<const char> str);
70 Handle<String> InternalizeUtf8String(const char* str) {
71 return InternalizeUtf8String(CStrVector(str));
73 Handle<String> InternalizeString(Handle<String> str);
74 Handle<String> InternalizeOneByteString(Vector<const uint8_t> str);
75 Handle<String> InternalizeOneByteString(
76 Handle<SeqOneByteString>, int from, int length);
78 Handle<String> InternalizeTwoByteString(Vector<const uc16> str);
80 template<class StringTableKey>
81 Handle<String> InternalizeStringWithKey(StringTableKey* key);
84 // String creation functions. Most of the string creation functions take
85 // a Heap::PretenureFlag argument to optionally request that they be
86 // allocated in the old generation. The pretenure flag defaults to
89 // Creates a new String object. There are two String encodings: one-byte and
90 // two-byte. One should choose between the three string factory functions
91 // based on the encoding of the string buffer that the string is
93 // - ...FromOneByte initializes the string from a buffer that is Latin1
94 // encoded (it does not check that the buffer is Latin1 encoded) and
95 // the result will be Latin1 encoded.
96 // - ...FromUtf8 initializes the string from a buffer that is UTF-8
97 // encoded. If the characters are all ASCII characters, the result
98 // will be Latin1 encoded, otherwise it will converted to two-byte.
99 // - ...FromTwoByte initializes the string from a buffer that is two-byte
100 // encoded. If the characters are all Latin1 characters, the result
101 // will be converted to Latin1, otherwise it will be left as two-byte.
103 // One-byte strings are pretenured when used as keys in the SourceCodeCache.
104 MUST_USE_RESULT MaybeHandle<String> NewStringFromOneByte(
105 Vector<const uint8_t> str,
106 PretenureFlag pretenure = NOT_TENURED);
109 inline Handle<String> NewStringFromStaticChars(
110 const char (&str)[N], PretenureFlag pretenure = NOT_TENURED) {
111 DCHECK(N == StrLength(str) + 1);
112 return NewStringFromOneByte(STATIC_CHAR_VECTOR(str), pretenure)
116 inline Handle<String> NewStringFromAsciiChecked(
118 PretenureFlag pretenure = NOT_TENURED) {
119 return NewStringFromOneByte(
120 OneByteVector(str), pretenure).ToHandleChecked();
124 // Allocates and fully initializes a String. There are two String encodings:
125 // one-byte and two-byte. One should choose between the threestring
126 // allocation functions based on the encoding of the string buffer used to
127 // initialized the string.
128 // - ...FromOneByte initializes the string from a buffer that is Latin1
129 // encoded (it does not check that the buffer is Latin1 encoded) and the
130 // result will be Latin1 encoded.
131 // - ...FromUTF8 initializes the string from a buffer that is UTF-8
132 // encoded. If the characters are all ASCII characters, the result
133 // will be Latin1 encoded, otherwise it will converted to two-byte.
134 // - ...FromTwoByte initializes the string from a buffer that is two-byte
135 // encoded. If the characters are all Latin1 characters, the
136 // result will be converted to Latin1, otherwise it will be left as
139 // TODO(dcarney): remove this function.
140 MUST_USE_RESULT inline MaybeHandle<String> NewStringFromAscii(
141 Vector<const char> str,
142 PretenureFlag pretenure = NOT_TENURED) {
143 return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure);
146 // UTF8 strings are pretenured when used for regexp literal patterns and
147 // flags in the parser.
148 MUST_USE_RESULT MaybeHandle<String> NewStringFromUtf8(
149 Vector<const char> str,
150 PretenureFlag pretenure = NOT_TENURED);
152 MUST_USE_RESULT MaybeHandle<String> NewStringFromTwoByte(
153 Vector<const uc16> str,
154 PretenureFlag pretenure = NOT_TENURED);
156 // Allocates an internalized string in old space based on the character
158 MUST_USE_RESULT Handle<String> NewInternalizedStringFromUtf8(
159 Vector<const char> str,
161 uint32_t hash_field);
163 MUST_USE_RESULT Handle<String> NewOneByteInternalizedString(
164 Vector<const uint8_t> str, uint32_t hash_field);
166 MUST_USE_RESULT Handle<String> NewOneByteInternalizedSubString(
167 Handle<SeqOneByteString> string, int offset, int length,
168 uint32_t hash_field);
170 MUST_USE_RESULT Handle<String> NewTwoByteInternalizedString(
171 Vector<const uc16> str,
172 uint32_t hash_field);
174 MUST_USE_RESULT Handle<String> NewInternalizedStringImpl(
175 Handle<String> string, int chars, uint32_t hash_field);
177 // Compute the matching internalized string map for a string if possible.
178 // Empty handle is returned if string is in new space or not flattened.
179 MUST_USE_RESULT MaybeHandle<Map> InternalizedStringMapForString(
180 Handle<String> string);
182 // Allocates and partially initializes an one-byte or two-byte String. The
183 // characters of the string are uninitialized. Currently used in regexp code
184 // only, where they are pretenured.
185 MUST_USE_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString(
187 PretenureFlag pretenure = NOT_TENURED);
188 MUST_USE_RESULT MaybeHandle<SeqTwoByteString> NewRawTwoByteString(
190 PretenureFlag pretenure = NOT_TENURED);
192 // Creates a single character string where the character has given code.
193 // A cache is used for Latin1 codes.
194 Handle<String> LookupSingleCharacterStringFromCode(uint32_t code);
196 // Create a new cons string object which consists of a pair of strings.
197 MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left,
198 Handle<String> right);
200 // Create a new string object which holds a proper substring of a string.
201 Handle<String> NewProperSubString(Handle<String> str,
205 // Create a new string object which holds a substring of a string.
206 Handle<String> NewSubString(Handle<String> str, int begin, int end) {
207 if (begin == 0 && end == str->length()) return str;
208 return NewProperSubString(str, begin, end);
211 // Creates a new external String object. There are two String encodings
212 // in the system: one-byte and two-byte. Unlike other String types, it does
213 // not make sense to have a UTF-8 factory function for external strings,
214 // because we cannot change the underlying buffer. Note that these strings
215 // are backed by a string resource that resides outside the V8 heap.
216 MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromOneByte(
217 const ExternalOneByteString::Resource* resource);
218 MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromTwoByte(
219 const ExternalTwoByteString::Resource* resource);
222 Handle<Symbol> NewSymbol();
223 Handle<Symbol> NewPrivateSymbol();
224 Handle<Symbol> NewPrivateOwnSymbol();
226 // Create a global (but otherwise uninitialized) context.
227 Handle<Context> NewNativeContext();
229 // Create a script context.
230 Handle<Context> NewScriptContext(Handle<JSFunction> function,
231 Handle<ScopeInfo> scope_info);
233 // Create an empty script context table.
234 Handle<ScriptContextTable> NewScriptContextTable();
236 // Create a module context.
237 Handle<Context> NewModuleContext(Handle<ScopeInfo> scope_info);
239 // Create a function context.
240 Handle<Context> NewFunctionContext(int length, Handle<JSFunction> function);
242 // Create a catch context.
243 Handle<Context> NewCatchContext(Handle<JSFunction> function,
244 Handle<Context> previous,
246 Handle<Object> thrown_object);
248 // Create a 'with' context.
249 Handle<Context> NewWithContext(Handle<JSFunction> function,
250 Handle<Context> previous,
251 Handle<JSReceiver> extension);
253 // Create a block context.
254 Handle<Context> NewBlockContext(Handle<JSFunction> function,
255 Handle<Context> previous,
256 Handle<ScopeInfo> scope_info);
258 // Allocate a new struct. The struct is pretenured (allocated directly in
259 // the old generation).
260 Handle<Struct> NewStruct(InstanceType type);
262 Handle<CodeCache> NewCodeCache();
264 Handle<AliasedArgumentsEntry> NewAliasedArgumentsEntry(
265 int aliased_context_slot);
267 Handle<ExecutableAccessorInfo> NewExecutableAccessorInfo();
269 Handle<Script> NewScript(Handle<String> source);
271 // Foreign objects are pretenured when allocated by the bootstrapper.
272 Handle<Foreign> NewForeign(Address addr,
273 PretenureFlag pretenure = NOT_TENURED);
275 // Allocate a new foreign object. The foreign is pretenured (allocated
276 // directly in the old generation).
277 Handle<Foreign> NewForeign(const AccessorDescriptor* foreign);
279 Handle<ByteArray> NewByteArray(int length,
280 PretenureFlag pretenure = NOT_TENURED);
282 Handle<ExternalArray> NewExternalArray(
284 ExternalArrayType array_type,
285 void* external_pointer,
286 PretenureFlag pretenure = NOT_TENURED);
288 Handle<FixedTypedArrayBase> NewFixedTypedArray(
290 ExternalArrayType array_type,
291 PretenureFlag pretenure = NOT_TENURED);
293 Handle<Cell> NewCell(Handle<Object> value);
295 Handle<PropertyCell> NewPropertyCellWithHole();
297 Handle<PropertyCell> NewPropertyCell(Handle<Object> value);
299 Handle<WeakCell> NewWeakCell(Handle<HeapObject> value);
301 // Allocate a tenured AllocationSite. It's payload is null.
302 Handle<AllocationSite> NewAllocationSite();
307 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND);
309 Handle<HeapObject> NewFillerObject(int size,
311 AllocationSpace space);
313 Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
315 Handle<JSObject> CopyJSObject(Handle<JSObject> object);
317 Handle<JSObject> CopyJSObjectWithAllocationSite(Handle<JSObject> object,
318 Handle<AllocationSite> site);
320 Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
323 Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
325 // This method expects a COW array in new space, and creates a copy
326 // of it in old space.
327 Handle<FixedArray> CopyAndTenureFixedCOWArray(Handle<FixedArray> array);
329 Handle<FixedDoubleArray> CopyFixedDoubleArray(
330 Handle<FixedDoubleArray> array);
332 Handle<ConstantPoolArray> CopyConstantPoolArray(
333 Handle<ConstantPoolArray> array);
335 // Numbers (e.g. literals) are pretenured by the parser.
336 // The return value may be a smi or a heap number.
337 Handle<Object> NewNumber(double value,
338 PretenureFlag pretenure = NOT_TENURED);
340 Handle<Object> NewNumberFromInt(int32_t value,
341 PretenureFlag pretenure = NOT_TENURED);
342 Handle<Object> NewNumberFromUint(uint32_t value,
343 PretenureFlag pretenure = NOT_TENURED);
344 Handle<Object> NewNumberFromSize(size_t value,
345 PretenureFlag pretenure = NOT_TENURED) {
346 if (Smi::IsValid(static_cast<intptr_t>(value))) {
347 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
350 return NewNumber(static_cast<double>(value), pretenure);
352 Handle<HeapNumber> NewHeapNumber(double value,
353 MutableMode mode = IMMUTABLE,
354 PretenureFlag pretenure = NOT_TENURED);
356 // These objects are used by the api to create env-independent data
357 // structures in the heap.
358 inline Handle<JSObject> NewNeanderObject() {
359 return NewJSObjectFromMap(neander_map());
362 Handle<JSWeakMap> NewJSWeakMap();
364 Handle<JSObject> NewArgumentsObject(Handle<JSFunction> callee, int length);
366 // JS objects are pretenured when allocated by the bootstrapper and
368 Handle<JSObject> NewJSObject(Handle<JSFunction> constructor,
369 PretenureFlag pretenure = NOT_TENURED);
370 // JSObject that should have a memento pointing to the allocation site.
371 Handle<JSObject> NewJSObjectWithMemento(Handle<JSFunction> constructor,
372 Handle<AllocationSite> site);
374 // Global objects are pretenured and initialized based on a constructor.
375 Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor);
377 // JS objects are pretenured when allocated by the bootstrapper and
379 Handle<JSObject> NewJSObjectFromMap(
381 PretenureFlag pretenure = NOT_TENURED,
382 bool allocate_properties = true,
383 Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null());
385 // JS modules are pretenured.
386 Handle<JSModule> NewJSModule(Handle<Context> context,
387 Handle<ScopeInfo> scope_info);
389 // JS arrays are pretenured when allocated by the parser.
391 // Create a JSArray with no elements.
392 Handle<JSArray> NewJSArray(
393 ElementsKind elements_kind,
394 PretenureFlag pretenure = NOT_TENURED);
396 // Create a JSArray with a specified length and elements initialized
397 // according to the specified mode.
398 Handle<JSArray> NewJSArray(
399 ElementsKind elements_kind, int length, int capacity,
400 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS,
401 PretenureFlag pretenure = NOT_TENURED);
403 Handle<JSArray> NewJSArray(
405 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
406 PretenureFlag pretenure = NOT_TENURED) {
408 elements_kind = GetHoleyElementsKind(elements_kind);
410 return NewJSArray(elements_kind, 0, capacity,
411 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
414 // Create a JSArray with the given elements.
415 Handle<JSArray> NewJSArrayWithElements(
416 Handle<FixedArrayBase> elements,
417 ElementsKind elements_kind,
419 PretenureFlag pretenure = NOT_TENURED);
421 Handle<JSArray> NewJSArrayWithElements(
422 Handle<FixedArrayBase> elements,
423 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
424 PretenureFlag pretenure = NOT_TENURED) {
425 return NewJSArrayWithElements(
426 elements, elements_kind, elements->length(), pretenure);
429 void NewJSArrayStorage(
430 Handle<JSArray> array,
433 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS);
435 Handle<JSGeneratorObject> NewJSGeneratorObject(Handle<JSFunction> function);
437 Handle<JSArrayBuffer> NewJSArrayBuffer();
439 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type);
441 // Creates a new JSTypedArray with the specified buffer.
442 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type,
443 Handle<JSArrayBuffer> buffer,
444 size_t byte_offset, size_t length);
446 Handle<JSDataView> NewJSDataView();
447 Handle<JSDataView> NewJSDataView(Handle<JSArrayBuffer> buffer,
448 size_t byte_offset, size_t byte_length);
450 // TODO(aandrey): Maybe these should take table, index and kind arguments.
451 Handle<JSMapIterator> NewJSMapIterator();
452 Handle<JSSetIterator> NewJSSetIterator();
454 // Allocates a Harmony proxy.
455 Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype);
457 // Allocates a Harmony function proxy.
458 Handle<JSProxy> NewJSFunctionProxy(Handle<Object> handler,
459 Handle<Object> call_trap,
460 Handle<Object> construct_trap,
461 Handle<Object> prototype);
463 // Reinitialize an JSGlobalProxy based on a constructor. The object
464 // must have the same size as objects allocated using the
465 // constructor. The object is reinitialized and behaves as an
466 // object that has been freshly allocated using the constructor.
467 void ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> global,
468 Handle<JSFunction> constructor);
470 Handle<JSGlobalProxy> NewUninitializedJSGlobalProxy();
472 // Change the type of the argument into a JS object/function and reinitialize.
473 void BecomeJSObject(Handle<JSProxy> object);
474 void BecomeJSFunction(Handle<JSProxy> object);
476 Handle<JSFunction> NewFunction(Handle<String> name,
478 Handle<Object> prototype,
479 bool read_only_prototype = false);
480 Handle<JSFunction> NewFunction(Handle<String> name);
481 Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
484 Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
485 Handle<SharedFunctionInfo> function_info,
486 Handle<Context> context,
487 PretenureFlag pretenure = TENURED);
489 Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code,
490 Handle<Object> prototype, InstanceType type,
492 bool read_only_prototype = false,
493 bool install_constructor = false);
494 Handle<JSFunction> NewFunction(Handle<String> name,
499 // Create a serialized scope info.
500 Handle<ScopeInfo> NewScopeInfo(int length);
502 // Create an External object for V8's external API.
503 Handle<JSObject> NewExternal(void* value);
505 // The reference to the Code object is stored in self_reference.
506 // This allows generated code to reference its own Code object
507 // by containing this handle.
508 Handle<Code> NewCode(const CodeDesc& desc,
510 Handle<Object> self_reference,
511 bool immovable = false,
512 bool crankshafted = false,
513 int prologue_offset = Code::kPrologueOffsetNotSet,
514 bool is_debug = false);
516 Handle<Code> CopyCode(Handle<Code> code);
518 Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info);
520 // Interface for creating error objects.
522 MaybeHandle<Object> NewError(const char* maker, const char* message,
523 Handle<JSArray> args);
524 Handle<String> EmergencyNewError(const char* message, Handle<JSArray> args);
525 MaybeHandle<Object> NewError(const char* maker, const char* message,
526 Vector<Handle<Object> > args);
527 MaybeHandle<Object> NewError(const char* message,
528 Vector<Handle<Object> > args);
529 MaybeHandle<Object> NewError(Handle<String> message);
530 MaybeHandle<Object> NewError(const char* constructor, Handle<String> message);
532 MaybeHandle<Object> NewTypeError(const char* message,
533 Vector<Handle<Object> > args);
534 MaybeHandle<Object> NewTypeError(Handle<String> message);
536 MaybeHandle<Object> NewRangeError(const char* message,
537 Vector<Handle<Object> > args);
538 MaybeHandle<Object> NewRangeError(Handle<String> message);
540 MaybeHandle<Object> NewInvalidStringLengthError() {
541 return NewRangeError("invalid_string_length",
542 HandleVector<Object>(NULL, 0));
545 MaybeHandle<Object> NewSyntaxError(const char* message, Handle<JSArray> args);
546 MaybeHandle<Object> NewSyntaxError(Handle<String> message);
548 MaybeHandle<Object> NewReferenceError(const char* message,
549 Vector<Handle<Object> > args);
550 MaybeHandle<Object> NewReferenceError(const char* message,
551 Handle<JSArray> args);
552 MaybeHandle<Object> NewReferenceError(Handle<String> message);
554 MaybeHandle<Object> NewEvalError(const char* message,
555 Vector<Handle<Object> > args);
557 Handle<String> NumberToString(Handle<Object> number,
558 bool check_number_string_cache = true);
560 Handle<String> Uint32ToString(uint32_t value) {
561 return NumberToString(NewNumberFromUint(value));
564 Handle<JSFunction> InstallMembers(Handle<JSFunction> function);
566 #define ROOT_ACCESSOR(type, name, camel_name) \
567 inline Handle<type> name() { \
568 return Handle<type>(bit_cast<type**>( \
569 &isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \
571 ROOT_LIST(ROOT_ACCESSOR)
574 #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
575 inline Handle<Map> name##_map() { \
576 return Handle<Map>(bit_cast<Map**>( \
577 &isolate()->heap()->roots_[Heap::k##Name##MapRootIndex])); \
579 STRUCT_LIST(STRUCT_MAP_ACCESSOR)
580 #undef STRUCT_MAP_ACCESSOR
582 #define STRING_ACCESSOR(name, str) \
583 inline Handle<String> name() { \
584 return Handle<String>(bit_cast<String**>( \
585 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
587 INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
588 #undef STRING_ACCESSOR
590 #define SYMBOL_ACCESSOR(name) \
591 inline Handle<Symbol> name() { \
592 return Handle<Symbol>(bit_cast<Symbol**>( \
593 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
595 PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
596 #undef SYMBOL_ACCESSOR
598 #define SYMBOL_ACCESSOR(name, varname, description) \
599 inline Handle<Symbol> name() { \
600 return Handle<Symbol>(bit_cast<Symbol**>( \
601 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
603 PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
604 #undef SYMBOL_ACCESSOR
606 inline void set_string_table(Handle<StringTable> table) {
607 isolate()->heap()->set_string_table(*table);
610 Handle<String> hidden_string() {
611 return Handle<String>(&isolate()->heap()->hidden_string_);
614 // Allocates a new SharedFunctionInfo object.
615 Handle<SharedFunctionInfo> NewSharedFunctionInfo(
616 Handle<String> name, int number_of_literals, FunctionKind kind,
617 Handle<Code> code, Handle<ScopeInfo> scope_info,
618 Handle<TypeFeedbackVector> feedback_vector);
619 Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name,
620 MaybeHandle<Code> code);
622 // Allocate a new type feedback vector
623 Handle<TypeFeedbackVector> NewTypeFeedbackVector(
624 const FeedbackVectorSpec& spec);
626 // Allocates a new JSMessageObject object.
627 Handle<JSMessageObject> NewJSMessageObject(
629 Handle<JSArray> arguments,
632 Handle<Object> script,
633 Handle<Object> stack_frames);
635 Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
637 // Return a map for given number of properties using the map cache in the
639 Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context,
640 int number_of_properties,
641 bool* is_result_from_cache);
643 // Creates a new FixedArray that holds the data associated with the
644 // atom regexp and stores it in the regexp.
645 void SetRegExpAtomData(Handle<JSRegExp> regexp,
647 Handle<String> source,
648 JSRegExp::Flags flags,
649 Handle<Object> match_pattern);
651 // Creates a new FixedArray that holds the data associated with the
652 // irregexp regexp and stores it in the regexp.
653 void SetRegExpIrregexpData(Handle<JSRegExp> regexp,
655 Handle<String> source,
656 JSRegExp::Flags flags,
659 // Returns the value for a known global constant (a property of the global
660 // object which is neither configurable nor writable) like 'undefined'.
661 // Returns a null handle when the given name is unknown.
662 Handle<Object> GlobalConstantFor(Handle<String> name);
664 // Converts the given boolean condition to JavaScript boolean value.
665 Handle<Object> ToBoolean(bool value);
668 Isolate* isolate() { return reinterpret_cast<Isolate*>(this); }
670 // Creates a heap object based on the map. The fields of the heap object are
671 // not initialized by New<>() functions. It's the responsibility of the caller
674 Handle<T> New(Handle<Map> map, AllocationSpace space);
677 Handle<T> New(Handle<Map> map,
678 AllocationSpace space,
679 Handle<AllocationSite> allocation_site);
681 // Creates a code object that is not yet fully initialized yet.
682 inline Handle<Code> NewCodeRaw(int object_size, bool immovable);
684 // Attempt to find the number in a small cache. If we finds it, return
685 // the string representation of the number. Otherwise return undefined.
686 Handle<Object> GetNumberStringCache(Handle<Object> number);
688 // Update the cache with a new number-string pair.
689 void SetNumberStringCache(Handle<Object> number, Handle<String> string);
691 // Initializes a function with a shared part and prototype.
692 // Note: this code was factored out of NewFunction such that other parts of
693 // the VM could use it. Specifically, a function that creates instances of
694 // type JS_FUNCTION_TYPE benefit from the use of this function.
695 inline void InitializeFunction(Handle<JSFunction> function,
696 Handle<SharedFunctionInfo> info,
697 Handle<Context> context);
699 // Creates a function initialized with a shared part.
700 Handle<JSFunction> NewFunction(Handle<Map> map,
701 Handle<SharedFunctionInfo> info,
702 Handle<Context> context,
703 PretenureFlag pretenure = TENURED);
705 Handle<JSFunction> NewFunction(Handle<Map> map,
707 MaybeHandle<Code> maybe_code);
709 // Reinitialize a JSProxy into an (empty) JS object of respective type and
710 // size, but keeping the original prototype. The receiver must have at least
711 // the size of the new object. The object is reinitialized and behaves as an
712 // object that has been freshly allocated.
713 void ReinitializeJSProxy(Handle<JSProxy> proxy, InstanceType type, int size);
716 } } // namespace v8::internal
718 #endif // V8_FACTORY_H_