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);
199 MUST_USE_RESULT MaybeHandle<String> NewOneByteConsString(
200 int length, Handle<String> left, Handle<String> right);
201 MUST_USE_RESULT MaybeHandle<String> NewTwoByteConsString(
202 int length, Handle<String> left, Handle<String> right);
203 MUST_USE_RESULT MaybeHandle<String> NewRawConsString(Handle<Map> map,
206 Handle<String> right);
208 // Create a new string object which holds a proper substring of a string.
209 Handle<String> NewProperSubString(Handle<String> str,
213 // Create a new string object which holds a substring of a string.
214 Handle<String> NewSubString(Handle<String> str, int begin, int end) {
215 if (begin == 0 && end == str->length()) return str;
216 return NewProperSubString(str, begin, end);
219 // Creates a new external String object. There are two String encodings
220 // in the system: one-byte and two-byte. Unlike other String types, it does
221 // not make sense to have a UTF-8 factory function for external strings,
222 // because we cannot change the underlying buffer. Note that these strings
223 // are backed by a string resource that resides outside the V8 heap.
224 MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromOneByte(
225 const ExternalOneByteString::Resource* resource);
226 MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromTwoByte(
227 const ExternalTwoByteString::Resource* resource);
230 Handle<Symbol> NewSymbol();
231 Handle<Symbol> NewPrivateSymbol();
232 Handle<Symbol> NewPrivateOwnSymbol();
234 // Create a global (but otherwise uninitialized) context.
235 Handle<Context> NewNativeContext();
237 // Create a script context.
238 Handle<Context> NewScriptContext(Handle<JSFunction> function,
239 Handle<ScopeInfo> scope_info);
241 // Create an empty script context table.
242 Handle<ScriptContextTable> NewScriptContextTable();
244 // Create a module context.
245 Handle<Context> NewModuleContext(Handle<ScopeInfo> scope_info);
247 // Create a function context.
248 Handle<Context> NewFunctionContext(int length, Handle<JSFunction> function);
250 // Create a catch context.
251 Handle<Context> NewCatchContext(Handle<JSFunction> function,
252 Handle<Context> previous,
254 Handle<Object> thrown_object);
256 // Create a 'with' context.
257 Handle<Context> NewWithContext(Handle<JSFunction> function,
258 Handle<Context> previous,
259 Handle<JSReceiver> extension);
261 // Create a block context.
262 Handle<Context> NewBlockContext(Handle<JSFunction> function,
263 Handle<Context> previous,
264 Handle<ScopeInfo> scope_info);
266 // Allocate a new struct. The struct is pretenured (allocated directly in
267 // the old generation).
268 Handle<Struct> NewStruct(InstanceType type);
270 Handle<CodeCache> NewCodeCache();
272 Handle<AliasedArgumentsEntry> NewAliasedArgumentsEntry(
273 int aliased_context_slot);
275 Handle<ExecutableAccessorInfo> NewExecutableAccessorInfo();
277 Handle<Script> NewScript(Handle<String> source);
279 // Foreign objects are pretenured when allocated by the bootstrapper.
280 Handle<Foreign> NewForeign(Address addr,
281 PretenureFlag pretenure = NOT_TENURED);
283 // Allocate a new foreign object. The foreign is pretenured (allocated
284 // directly in the old generation).
285 Handle<Foreign> NewForeign(const AccessorDescriptor* foreign);
287 Handle<ByteArray> NewByteArray(int length,
288 PretenureFlag pretenure = NOT_TENURED);
290 Handle<ExternalArray> NewExternalArray(
292 ExternalArrayType array_type,
293 void* external_pointer,
294 PretenureFlag pretenure = NOT_TENURED);
296 Handle<FixedTypedArrayBase> NewFixedTypedArray(
298 ExternalArrayType array_type,
299 PretenureFlag pretenure = NOT_TENURED);
301 Handle<Cell> NewCell(Handle<Object> value);
303 Handle<PropertyCell> NewPropertyCell();
305 Handle<WeakCell> NewWeakCell(Handle<HeapObject> value);
307 // Allocate a tenured AllocationSite. It's payload is null.
308 Handle<AllocationSite> NewAllocationSite();
313 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND);
315 Handle<HeapObject> NewFillerObject(int size,
317 AllocationSpace space);
319 Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
321 Handle<JSObject> CopyJSObject(Handle<JSObject> object);
323 Handle<JSObject> CopyJSObjectWithAllocationSite(Handle<JSObject> object,
324 Handle<AllocationSite> site);
326 Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
329 Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
331 // This method expects a COW array in new space, and creates a copy
332 // of it in old space.
333 Handle<FixedArray> CopyAndTenureFixedCOWArray(Handle<FixedArray> array);
335 Handle<FixedDoubleArray> CopyFixedDoubleArray(
336 Handle<FixedDoubleArray> array);
338 Handle<ConstantPoolArray> CopyConstantPoolArray(
339 Handle<ConstantPoolArray> array);
341 // Numbers (e.g. literals) are pretenured by the parser.
342 // The return value may be a smi or a heap number.
343 Handle<Object> NewNumber(double value,
344 PretenureFlag pretenure = NOT_TENURED);
346 Handle<Object> NewNumberFromInt(int32_t value,
347 PretenureFlag pretenure = NOT_TENURED);
348 Handle<Object> NewNumberFromUint(uint32_t value,
349 PretenureFlag pretenure = NOT_TENURED);
350 Handle<Object> NewNumberFromSize(size_t value,
351 PretenureFlag pretenure = NOT_TENURED) {
352 if (Smi::IsValid(static_cast<intptr_t>(value))) {
353 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
356 return NewNumber(static_cast<double>(value), pretenure);
358 Handle<HeapNumber> NewHeapNumber(double value,
359 MutableMode mode = IMMUTABLE,
360 PretenureFlag pretenure = NOT_TENURED);
362 // These objects are used by the api to create env-independent data
363 // structures in the heap.
364 inline Handle<JSObject> NewNeanderObject() {
365 return NewJSObjectFromMap(neander_map());
368 Handle<JSWeakMap> NewJSWeakMap();
370 Handle<JSObject> NewArgumentsObject(Handle<JSFunction> callee, int length);
372 // JS objects are pretenured when allocated by the bootstrapper and
374 Handle<JSObject> NewJSObject(Handle<JSFunction> constructor,
375 PretenureFlag pretenure = NOT_TENURED);
376 // JSObject that should have a memento pointing to the allocation site.
377 Handle<JSObject> NewJSObjectWithMemento(Handle<JSFunction> constructor,
378 Handle<AllocationSite> site);
380 // Global objects are pretenured and initialized based on a constructor.
381 Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor);
383 // JS objects are pretenured when allocated by the bootstrapper and
385 Handle<JSObject> NewJSObjectFromMap(
387 PretenureFlag pretenure = NOT_TENURED,
388 bool allocate_properties = true,
389 Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null());
391 // JS modules are pretenured.
392 Handle<JSModule> NewJSModule(Handle<Context> context,
393 Handle<ScopeInfo> scope_info);
395 // JS arrays are pretenured when allocated by the parser.
397 // Create a JSArray with no elements.
398 Handle<JSArray> NewJSArray(
399 ElementsKind elements_kind,
400 PretenureFlag pretenure = NOT_TENURED);
402 // Create a JSArray with a specified length and elements initialized
403 // according to the specified mode.
404 Handle<JSArray> NewJSArray(
405 ElementsKind elements_kind, int length, int capacity,
406 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS,
407 PretenureFlag pretenure = NOT_TENURED);
409 Handle<JSArray> NewJSArray(
411 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
412 PretenureFlag pretenure = NOT_TENURED) {
414 elements_kind = GetHoleyElementsKind(elements_kind);
416 return NewJSArray(elements_kind, 0, capacity,
417 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
420 // Create a JSArray with the given elements.
421 Handle<JSArray> NewJSArrayWithElements(
422 Handle<FixedArrayBase> elements,
423 ElementsKind elements_kind,
425 PretenureFlag pretenure = NOT_TENURED);
427 Handle<JSArray> NewJSArrayWithElements(
428 Handle<FixedArrayBase> elements,
429 ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
430 PretenureFlag pretenure = NOT_TENURED) {
431 return NewJSArrayWithElements(
432 elements, elements_kind, elements->length(), pretenure);
435 void NewJSArrayStorage(
436 Handle<JSArray> array,
439 ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS);
441 Handle<JSGeneratorObject> NewJSGeneratorObject(Handle<JSFunction> function);
443 Handle<JSArrayBuffer> NewJSArrayBuffer();
445 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type);
447 // Creates a new JSTypedArray with the specified buffer.
448 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type,
449 Handle<JSArrayBuffer> buffer,
450 size_t byte_offset, size_t length);
452 Handle<JSDataView> NewJSDataView();
453 Handle<JSDataView> NewJSDataView(Handle<JSArrayBuffer> buffer,
454 size_t byte_offset, size_t byte_length);
456 // TODO(aandrey): Maybe these should take table, index and kind arguments.
457 Handle<JSMapIterator> NewJSMapIterator();
458 Handle<JSSetIterator> NewJSSetIterator();
460 // Allocates a Harmony proxy.
461 Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype);
463 // Allocates a Harmony function proxy.
464 Handle<JSProxy> NewJSFunctionProxy(Handle<Object> handler,
465 Handle<Object> call_trap,
466 Handle<Object> construct_trap,
467 Handle<Object> prototype);
469 // Reinitialize an JSGlobalProxy based on a constructor. The object
470 // must have the same size as objects allocated using the
471 // constructor. The object is reinitialized and behaves as an
472 // object that has been freshly allocated using the constructor.
473 void ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> global,
474 Handle<JSFunction> constructor);
476 Handle<JSGlobalProxy> NewUninitializedJSGlobalProxy();
478 // Change the type of the argument into a JS object/function and reinitialize.
479 void BecomeJSObject(Handle<JSProxy> object);
480 void BecomeJSFunction(Handle<JSProxy> object);
482 Handle<JSFunction> NewFunction(Handle<String> name,
484 Handle<Object> prototype,
485 bool read_only_prototype = false);
486 Handle<JSFunction> NewFunction(Handle<String> name);
487 Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
490 Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
491 Handle<SharedFunctionInfo> function_info,
492 Handle<Context> context,
493 PretenureFlag pretenure = TENURED);
495 Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code,
496 Handle<Object> prototype, InstanceType type,
498 bool read_only_prototype = false,
499 bool install_constructor = false);
500 Handle<JSFunction> NewFunction(Handle<String> name,
505 // Create a serialized scope info.
506 Handle<ScopeInfo> NewScopeInfo(int length);
508 // Create an External object for V8's external API.
509 Handle<JSObject> NewExternal(void* value);
511 // The reference to the Code object is stored in self_reference.
512 // This allows generated code to reference its own Code object
513 // by containing this handle.
514 Handle<Code> NewCode(const CodeDesc& desc,
516 Handle<Object> self_reference,
517 bool immovable = false,
518 bool crankshafted = false,
519 int prologue_offset = Code::kPrologueOffsetNotSet,
520 bool is_debug = false);
522 Handle<Code> CopyCode(Handle<Code> code);
524 Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info);
526 // Interface for creating error objects.
528 Handle<Object> NewError(const char* maker, const char* message,
529 Handle<JSArray> args);
530 Handle<String> EmergencyNewError(const char* message, Handle<JSArray> args);
531 Handle<Object> NewError(const char* maker, const char* message,
532 Vector<Handle<Object> > args);
533 Handle<Object> NewError(const char* message, Vector<Handle<Object> > args);
534 Handle<Object> NewError(Handle<String> message);
535 Handle<Object> NewError(const char* constructor, Handle<String> message);
537 Handle<Object> NewTypeError(const char* message,
538 Vector<Handle<Object> > args);
539 Handle<Object> NewTypeError(Handle<String> message);
541 Handle<Object> NewRangeError(const char* message,
542 Vector<Handle<Object> > args);
543 Handle<Object> NewRangeError(Handle<String> message);
545 Handle<Object> NewInvalidStringLengthError() {
546 return NewRangeError("invalid_string_length",
547 HandleVector<Object>(NULL, 0));
550 Handle<Object> NewSyntaxError(const char* message, Handle<JSArray> args);
551 Handle<Object> NewSyntaxError(Handle<String> message);
553 Handle<Object> NewReferenceError(const char* message,
554 Vector<Handle<Object> > args);
555 Handle<Object> NewReferenceError(const char* message, Handle<JSArray> args);
556 Handle<Object> NewReferenceError(Handle<String> message);
558 Handle<Object> NewEvalError(const char* message,
559 Vector<Handle<Object> > args);
561 Handle<String> NumberToString(Handle<Object> number,
562 bool check_number_string_cache = true);
564 Handle<String> Uint32ToString(uint32_t value) {
565 return NumberToString(NewNumberFromUint(value));
568 Handle<JSFunction> InstallMembers(Handle<JSFunction> function);
570 #define ROOT_ACCESSOR(type, name, camel_name) \
571 inline Handle<type> name() { \
572 return Handle<type>(bit_cast<type**>( \
573 &isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \
575 ROOT_LIST(ROOT_ACCESSOR)
578 #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
579 inline Handle<Map> name##_map() { \
580 return Handle<Map>(bit_cast<Map**>( \
581 &isolate()->heap()->roots_[Heap::k##Name##MapRootIndex])); \
583 STRUCT_LIST(STRUCT_MAP_ACCESSOR)
584 #undef STRUCT_MAP_ACCESSOR
586 #define STRING_ACCESSOR(name, str) \
587 inline Handle<String> name() { \
588 return Handle<String>(bit_cast<String**>( \
589 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
591 INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
592 #undef STRING_ACCESSOR
594 #define SYMBOL_ACCESSOR(name) \
595 inline Handle<Symbol> name() { \
596 return Handle<Symbol>(bit_cast<Symbol**>( \
597 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
599 PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
600 #undef SYMBOL_ACCESSOR
602 #define SYMBOL_ACCESSOR(name, varname, description) \
603 inline Handle<Symbol> name() { \
604 return Handle<Symbol>(bit_cast<Symbol**>( \
605 &isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
607 PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
608 #undef SYMBOL_ACCESSOR
610 inline void set_string_table(Handle<StringTable> table) {
611 isolate()->heap()->set_string_table(*table);
614 Handle<String> hidden_string() {
615 return Handle<String>(&isolate()->heap()->hidden_string_);
618 // Allocates a new SharedFunctionInfo object.
619 Handle<SharedFunctionInfo> NewSharedFunctionInfo(
620 Handle<String> name, int number_of_literals, FunctionKind kind,
621 Handle<Code> code, Handle<ScopeInfo> scope_info,
622 Handle<TypeFeedbackVector> feedback_vector);
623 Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name,
624 MaybeHandle<Code> code);
626 // Allocate a new type feedback vector
627 template <typename Spec>
628 Handle<TypeFeedbackVector> NewTypeFeedbackVector(const Spec* spec);
630 // Allocates a new JSMessageObject object.
631 Handle<JSMessageObject> NewJSMessageObject(
633 Handle<JSArray> arguments,
636 Handle<Object> script,
637 Handle<Object> stack_frames);
639 Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
641 // Return a map for given number of properties using the map cache in the
643 Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context,
644 int number_of_properties,
645 bool* is_result_from_cache);
647 // Creates a new FixedArray that holds the data associated with the
648 // atom regexp and stores it in the regexp.
649 void SetRegExpAtomData(Handle<JSRegExp> regexp,
651 Handle<String> source,
652 JSRegExp::Flags flags,
653 Handle<Object> match_pattern);
655 // Creates a new FixedArray that holds the data associated with the
656 // irregexp regexp and stores it in the regexp.
657 void SetRegExpIrregexpData(Handle<JSRegExp> regexp,
659 Handle<String> source,
660 JSRegExp::Flags flags,
663 // Returns the value for a known global constant (a property of the global
664 // object which is neither configurable nor writable) like 'undefined'.
665 // Returns a null handle when the given name is unknown.
666 Handle<Object> GlobalConstantFor(Handle<String> name);
668 // Converts the given boolean condition to JavaScript boolean value.
669 Handle<Object> ToBoolean(bool value);
672 Isolate* isolate() { return reinterpret_cast<Isolate*>(this); }
674 // Creates a heap object based on the map. The fields of the heap object are
675 // not initialized by New<>() functions. It's the responsibility of the caller
678 Handle<T> New(Handle<Map> map, AllocationSpace space);
681 Handle<T> New(Handle<Map> map,
682 AllocationSpace space,
683 Handle<AllocationSite> allocation_site);
685 // Creates a code object that is not yet fully initialized yet.
686 inline Handle<Code> NewCodeRaw(int object_size, bool immovable);
688 // Attempt to find the number in a small cache. If we finds it, return
689 // the string representation of the number. Otherwise return undefined.
690 Handle<Object> GetNumberStringCache(Handle<Object> number);
692 // Update the cache with a new number-string pair.
693 void SetNumberStringCache(Handle<Object> number, Handle<String> string);
695 // Initializes a function with a shared part and prototype.
696 // Note: this code was factored out of NewFunction such that other parts of
697 // the VM could use it. Specifically, a function that creates instances of
698 // type JS_FUNCTION_TYPE benefit from the use of this function.
699 inline void InitializeFunction(Handle<JSFunction> function,
700 Handle<SharedFunctionInfo> info,
701 Handle<Context> context);
703 // Creates a function initialized with a shared part.
704 Handle<JSFunction> NewFunction(Handle<Map> map,
705 Handle<SharedFunctionInfo> info,
706 Handle<Context> context,
707 PretenureFlag pretenure = TENURED);
709 Handle<JSFunction> NewFunction(Handle<Map> map,
711 MaybeHandle<Code> maybe_code);
713 // Reinitialize a JSProxy into an (empty) JS object of respective type and
714 // size, but keeping the original prototype. The receiver must have at least
715 // the size of the new object. The object is reinitialized and behaves as an
716 // object that has been freshly allocated.
717 void ReinitializeJSProxy(Handle<JSProxy> proxy, InstanceType type, int size);
720 } } // namespace v8::internal
722 #endif // V8_FACTORY_H_