2014-03-31 12:01:02 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_FACTORY_H_
|
|
|
|
#define V8_FACTORY_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/isolate.h"
|
2015-04-16 07:01:20 +00:00
|
|
|
#include "src/messages.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-11-27 16:36:18 +00:00
|
|
|
class FeedbackVectorSpec;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-11-27 16:36:18 +00:00
|
|
|
// Interface for handle based allocation.
|
2015-04-20 13:08:11 +00:00
|
|
|
class Factory final {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2014-04-16 14:15:32 +00:00
|
|
|
Handle<Oddball> NewOddball(Handle<Map> map,
|
|
|
|
const char* to_string,
|
|
|
|
Handle<Object> to_number,
|
|
|
|
byte kind);
|
|
|
|
|
2014-03-20 13:01:08 +00:00
|
|
|
// Allocates a fixed array initialized with undefined values.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<FixedArray> NewFixedArray(
|
2008-07-03 15:10:15 +00:00
|
|
|
int size,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-10-29 10:02:09 +00:00
|
|
|
|
|
|
|
// Allocate a new fixed array with non-existing entries (the hole).
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<FixedArray> NewFixedArrayWithHoles(
|
2010-04-14 14:46:15 +00:00
|
|
|
int size,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-10-29 10:02:09 +00:00
|
|
|
|
2014-03-20 13:01:08 +00:00
|
|
|
// Allocates an uninitialized fixed array. It must be filled by the caller.
|
|
|
|
Handle<FixedArray> NewUninitializedFixedArray(int size);
|
|
|
|
|
2011-06-09 10:03:35 +00:00
|
|
|
// Allocate a new uninitialized fixed double array.
|
2014-04-24 05:29:00 +00:00
|
|
|
// The function returns a pre-allocated empty fixed array for capacity = 0,
|
|
|
|
// so the return type must be the general fixed array class.
|
|
|
|
Handle<FixedArrayBase> NewFixedDoubleArray(
|
2011-06-09 10:03:35 +00:00
|
|
|
int size,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
|
2014-04-14 16:05:19 +00:00
|
|
|
// Allocate a new fixed double array with hole values.
|
2014-04-24 05:29:00 +00:00
|
|
|
Handle<FixedArrayBase> NewFixedDoubleArrayWithHoles(
|
2014-04-14 16:05:19 +00:00
|
|
|
int size,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
|
2013-10-14 13:35:06 +00:00
|
|
|
Handle<ConstantPoolArray> NewConstantPoolArray(
|
2014-06-03 16:22:10 +00:00
|
|
|
const ConstantPoolArray::NumberOfEntries& small);
|
|
|
|
|
|
|
|
Handle<ConstantPoolArray> NewExtendedConstantPoolArray(
|
|
|
|
const ConstantPoolArray::NumberOfEntries& small,
|
|
|
|
const ConstantPoolArray::NumberOfEntries& extended);
|
2013-10-14 13:35:06 +00:00
|
|
|
|
2014-04-04 20:41:57 +00:00
|
|
|
Handle<OrderedHashSet> NewOrderedHashSet();
|
|
|
|
Handle<OrderedHashMap> NewOrderedHashMap();
|
|
|
|
|
2014-04-07 12:43:35 +00:00
|
|
|
// Create a new boxed value.
|
|
|
|
Handle<Box> NewBox(Handle<Object> value);
|
|
|
|
|
2015-04-07 10:42:45 +00:00
|
|
|
// Create a new PrototypeInfo struct.
|
|
|
|
Handle<PrototypeInfo> NewPrototypeInfo();
|
|
|
|
|
2014-04-07 10:12:54 +00:00
|
|
|
// Create a pre-tenured empty AccessorPair.
|
2012-01-10 16:11:33 +00:00
|
|
|
Handle<AccessorPair> NewAccessorPair();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-07 10:12:54 +00:00
|
|
|
// Create an empty TypeFeedbackInfo.
|
2012-02-20 12:57:23 +00:00
|
|
|
Handle<TypeFeedbackInfo> NewTypeFeedbackInfo();
|
|
|
|
|
2014-04-23 15:43:39 +00:00
|
|
|
// Finds the internalized copy for string in the string table.
|
|
|
|
// If not found, a new string is added to the table and returned.
|
2013-02-28 17:03:34 +00:00
|
|
|
Handle<String> InternalizeUtf8String(Vector<const char> str);
|
|
|
|
Handle<String> InternalizeUtf8String(const char* str) {
|
|
|
|
return InternalizeUtf8String(CStrVector(str));
|
2012-12-17 15:56:16 +00:00
|
|
|
}
|
2013-02-28 17:03:34 +00:00
|
|
|
Handle<String> InternalizeString(Handle<String> str);
|
|
|
|
Handle<String> InternalizeOneByteString(Vector<const uint8_t> str);
|
2014-01-29 14:31:34 +00:00
|
|
|
Handle<String> InternalizeOneByteString(
|
|
|
|
Handle<SeqOneByteString>, int from, int length);
|
|
|
|
|
2013-02-28 17:03:34 +00:00
|
|
|
Handle<String> InternalizeTwoByteString(Vector<const uc16> str);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-01-17 10:27:57 +00:00
|
|
|
template<class StringTableKey>
|
|
|
|
Handle<String> InternalizeStringWithKey(StringTableKey* key);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// String creation functions. Most of the string creation functions take
|
|
|
|
// a Heap::PretenureFlag argument to optionally request that they be
|
|
|
|
// allocated in the old generation. The pretenure flag defaults to
|
|
|
|
// DONT_TENURE.
|
|
|
|
//
|
2014-09-10 12:38:12 +00:00
|
|
|
// Creates a new String object. There are two String encodings: one-byte and
|
|
|
|
// two-byte. One should choose between the three string factory functions
|
2008-07-03 15:10:15 +00:00
|
|
|
// based on the encoding of the string buffer that the string is
|
|
|
|
// initialized from.
|
2014-09-10 12:38:12 +00:00
|
|
|
// - ...FromOneByte initializes the string from a buffer that is Latin1
|
|
|
|
// encoded (it does not check that the buffer is Latin1 encoded) and
|
|
|
|
// the result will be Latin1 encoded.
|
2008-07-03 15:10:15 +00:00
|
|
|
// - ...FromUtf8 initializes the string from a buffer that is UTF-8
|
2014-09-10 12:38:12 +00:00
|
|
|
// encoded. If the characters are all ASCII characters, the result
|
|
|
|
// will be Latin1 encoded, otherwise it will converted to two-byte.
|
|
|
|
// - ...FromTwoByte initializes the string from a buffer that is two-byte
|
|
|
|
// encoded. If the characters are all Latin1 characters, the result
|
|
|
|
// will be converted to Latin1, otherwise it will be left as two-byte.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2014-09-10 12:38:12 +00:00
|
|
|
// One-byte strings are pretenured when used as keys in the SourceCodeCache.
|
2014-04-17 13:27:02 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewStringFromOneByte(
|
2013-01-09 10:30:54 +00:00
|
|
|
Vector<const uint8_t> str,
|
2008-07-03 15:10:15 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2014-04-17 13:27:02 +00:00
|
|
|
|
2014-09-10 12:38:12 +00:00
|
|
|
template <size_t N>
|
|
|
|
inline Handle<String> NewStringFromStaticChars(
|
|
|
|
const char (&str)[N], PretenureFlag pretenure = NOT_TENURED) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(N == StrLength(str) + 1);
|
2014-09-10 12:38:12 +00:00
|
|
|
return NewStringFromOneByte(STATIC_CHAR_VECTOR(str), pretenure)
|
|
|
|
.ToHandleChecked();
|
2014-04-17 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline Handle<String> NewStringFromAsciiChecked(
|
|
|
|
const char* str,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED) {
|
|
|
|
return NewStringFromOneByte(
|
|
|
|
OneByteVector(str), pretenure).ToHandleChecked();
|
|
|
|
}
|
|
|
|
|
2014-06-18 13:26:02 +00:00
|
|
|
|
2014-09-10 12:38:12 +00:00
|
|
|
// Allocates and fully initializes a String. There are two String encodings:
|
|
|
|
// one-byte and two-byte. One should choose between the threestring
|
2014-06-18 13:26:02 +00:00
|
|
|
// allocation functions based on the encoding of the string buffer used to
|
|
|
|
// initialized the string.
|
2014-09-10 12:38:12 +00:00
|
|
|
// - ...FromOneByte initializes the string from a buffer that is Latin1
|
|
|
|
// encoded (it does not check that the buffer is Latin1 encoded) and the
|
|
|
|
// result will be Latin1 encoded.
|
2014-06-18 13:26:02 +00:00
|
|
|
// - ...FromUTF8 initializes the string from a buffer that is UTF-8
|
2014-09-10 12:38:12 +00:00
|
|
|
// encoded. If the characters are all ASCII characters, the result
|
|
|
|
// will be Latin1 encoded, otherwise it will converted to two-byte.
|
2014-06-18 13:26:02 +00:00
|
|
|
// - ...FromTwoByte initializes the string from a buffer that is two-byte
|
2014-09-10 12:38:12 +00:00
|
|
|
// encoded. If the characters are all Latin1 characters, the
|
|
|
|
// result will be converted to Latin1, otherwise it will be left as
|
2014-06-18 13:26:02 +00:00
|
|
|
// two-byte.
|
|
|
|
|
2013-01-09 10:30:54 +00:00
|
|
|
// TODO(dcarney): remove this function.
|
2014-04-17 13:27:02 +00:00
|
|
|
MUST_USE_RESULT inline MaybeHandle<String> NewStringFromAscii(
|
2013-01-09 10:30:54 +00:00
|
|
|
Vector<const char> str,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED) {
|
|
|
|
return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// UTF8 strings are pretenured when used for regexp literal patterns and
|
|
|
|
// flags in the parser.
|
2014-04-17 13:27:02 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewStringFromUtf8(
|
2008-07-03 15:10:15 +00:00
|
|
|
Vector<const char> str,
|
2012-09-04 12:23:22 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-17 13:27:02 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewStringFromTwoByte(
|
2010-07-05 12:49:00 +00:00
|
|
|
Vector<const uc16> str,
|
2009-08-18 07:14:02 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-25 13:59:33 +00:00
|
|
|
// Allocates an internalized string in old space based on the character
|
|
|
|
// stream.
|
|
|
|
MUST_USE_RESULT Handle<String> NewInternalizedStringFromUtf8(
|
|
|
|
Vector<const char> str,
|
|
|
|
int chars,
|
|
|
|
uint32_t hash_field);
|
|
|
|
|
|
|
|
MUST_USE_RESULT Handle<String> NewOneByteInternalizedString(
|
2014-08-19 08:53:38 +00:00
|
|
|
Vector<const uint8_t> str, uint32_t hash_field);
|
|
|
|
|
|
|
|
MUST_USE_RESULT Handle<String> NewOneByteInternalizedSubString(
|
|
|
|
Handle<SeqOneByteString> string, int offset, int length,
|
|
|
|
uint32_t hash_field);
|
2014-04-25 13:59:33 +00:00
|
|
|
|
|
|
|
MUST_USE_RESULT Handle<String> NewTwoByteInternalizedString(
|
|
|
|
Vector<const uc16> str,
|
|
|
|
uint32_t hash_field);
|
|
|
|
|
|
|
|
MUST_USE_RESULT Handle<String> NewInternalizedStringImpl(
|
2014-04-25 16:02:50 +00:00
|
|
|
Handle<String> string, int chars, uint32_t hash_field);
|
2014-04-25 13:59:33 +00:00
|
|
|
|
|
|
|
// Compute the matching internalized string map for a string if possible.
|
|
|
|
// Empty handle is returned if string is in new space or not flattened.
|
|
|
|
MUST_USE_RESULT MaybeHandle<Map> InternalizedStringMapForString(
|
|
|
|
Handle<String> string);
|
|
|
|
|
2014-09-10 12:38:12 +00:00
|
|
|
// Allocates and partially initializes an one-byte or two-byte String. The
|
2010-07-05 12:49:00 +00:00
|
|
|
// characters of the string are uninitialized. Currently used in regexp code
|
|
|
|
// only, where they are pretenured.
|
2014-04-04 12:06:11 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<SeqOneByteString> NewRawOneByteString(
|
2010-07-05 12:49:00 +00:00
|
|
|
int length,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2014-04-04 12:06:11 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<SeqTwoByteString> NewRawTwoByteString(
|
2008-07-03 15:10:15 +00:00
|
|
|
int length,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
|
2014-04-23 15:43:39 +00:00
|
|
|
// Creates a single character string where the character has given code.
|
2014-09-10 12:38:12 +00:00
|
|
|
// A cache is used for Latin1 codes.
|
2014-04-23 15:43:39 +00:00
|
|
|
Handle<String> LookupSingleCharacterStringFromCode(uint32_t code);
|
2014-04-08 06:45:53 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Create a new cons string object which consists of a pair of strings.
|
2014-04-03 12:30:37 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left,
|
|
|
|
Handle<String> right);
|
2015-03-30 06:28:35 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewOneByteConsString(
|
|
|
|
int length, Handle<String> left, Handle<String> right);
|
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewTwoByteConsString(
|
|
|
|
int length, Handle<String> left, Handle<String> right);
|
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewRawConsString(Handle<Map> map,
|
|
|
|
int length,
|
|
|
|
Handle<String> left,
|
|
|
|
Handle<String> right);
|
2013-12-23 12:37:56 +00:00
|
|
|
|
2011-06-27 09:02:34 +00:00
|
|
|
// Create a new string object which holds a proper substring of a string.
|
|
|
|
Handle<String> NewProperSubString(Handle<String> str,
|
2011-06-22 14:20:23 +00:00
|
|
|
int begin,
|
|
|
|
int end);
|
|
|
|
|
2013-12-23 12:37:56 +00:00
|
|
|
// Create a new string object which holds a substring of a string.
|
|
|
|
Handle<String> NewSubString(Handle<String> str, int begin, int end) {
|
|
|
|
if (begin == 0 && end == str->length()) return str;
|
|
|
|
return NewProperSubString(str, begin, end);
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Creates a new external String object. There are two String encodings
|
2014-09-10 12:38:12 +00:00
|
|
|
// in the system: one-byte and two-byte. Unlike other String types, it does
|
2008-07-03 15:10:15 +00:00
|
|
|
// not make sense to have a UTF-8 factory function for external strings,
|
2014-04-16 13:35:36 +00:00
|
|
|
// because we cannot change the underlying buffer. Note that these strings
|
|
|
|
// are backed by a string resource that resides outside the V8 heap.
|
2014-09-10 12:38:12 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromOneByte(
|
|
|
|
const ExternalOneByteString::Resource* resource);
|
2014-04-04 12:06:11 +00:00
|
|
|
MUST_USE_RESULT MaybeHandle<String> NewExternalStringFromTwoByte(
|
2011-09-21 13:28:09 +00:00
|
|
|
const ExternalTwoByteString::Resource* resource);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-03-01 10:34:31 +00:00
|
|
|
// Create a symbol.
|
|
|
|
Handle<Symbol> NewSymbol();
|
Provide private symbols through internal APIs
Adds a notion of private symbols, mainly intended for internal use, especially, self-hosting of built-in types that would otherwise require new C++ classes.
On the JS side (i.e., in built-ins), private properties can be created and accessed through a set of macros:
NEW_PRIVATE(print_name)
HAS_PRIVATE(obj, sym)
GET_PRIVATE(obj, sym)
SET_PRIVATE(obj, sym, val)
DELETE_PRIVATE(obj, sym)
In the V8 API, they are accessible via a new class Private, and respective HasPrivate/Get/Private/SetPrivate/DeletePrivate methods on calss Object.
These APIs are designed and restricted such that their implementation can later be replaced by whatever ES7+ will officially provide.
R=yangguo@chromium.org
BUG=
Review URL: https://codereview.chromium.org/48923002
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17683 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2013-11-13 10:34:06 +00:00
|
|
|
Handle<Symbol> NewPrivateSymbol();
|
2014-08-12 15:28:20 +00:00
|
|
|
Handle<Symbol> NewPrivateOwnSymbol();
|
2013-03-01 10:34:31 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Create a global (but otherwise uninitialized) context.
|
2012-08-17 09:03:08 +00:00
|
|
|
Handle<Context> NewNativeContext();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-11-12 11:34:09 +00:00
|
|
|
// Create a script context.
|
|
|
|
Handle<Context> NewScriptContext(Handle<JSFunction> function,
|
2012-08-27 09:40:26 +00:00
|
|
|
Handle<ScopeInfo> scope_info);
|
|
|
|
|
2014-11-12 11:34:09 +00:00
|
|
|
// Create an empty script context table.
|
|
|
|
Handle<ScriptContextTable> NewScriptContextTable();
|
2014-11-07 16:29:13 +00:00
|
|
|
|
2012-04-16 14:43:27 +00:00
|
|
|
// Create a module context.
|
2012-07-09 08:59:03 +00:00
|
|
|
Handle<Context> NewModuleContext(Handle<ScopeInfo> scope_info);
|
2012-04-16 14:43:27 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Create a function context.
|
2012-04-16 14:43:27 +00:00
|
|
|
Handle<Context> NewFunctionContext(int length, Handle<JSFunction> function);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-06-09 11:26:01 +00:00
|
|
|
// Create a catch context.
|
2011-06-29 07:41:42 +00:00
|
|
|
Handle<Context> NewCatchContext(Handle<JSFunction> function,
|
|
|
|
Handle<Context> previous,
|
2011-06-16 06:37:49 +00:00
|
|
|
Handle<String> name,
|
|
|
|
Handle<Object> thrown_object);
|
2011-06-09 11:26:01 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Create a 'with' context.
|
2011-06-29 07:41:42 +00:00
|
|
|
Handle<Context> NewWithContext(Handle<JSFunction> function,
|
|
|
|
Handle<Context> previous,
|
2014-04-09 08:51:46 +00:00
|
|
|
Handle<JSReceiver> extension);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-04-16 14:43:27 +00:00
|
|
|
// Create a block context.
|
2011-08-11 16:29:28 +00:00
|
|
|
Handle<Context> NewBlockContext(Handle<JSFunction> function,
|
|
|
|
Handle<Context> previous,
|
2011-11-03 10:36:55 +00:00
|
|
|
Handle<ScopeInfo> scope_info);
|
2011-08-11 16:29:28 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Allocate a new struct. The struct is pretenured (allocated directly in
|
|
|
|
// the old generation).
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Struct> NewStruct(InstanceType type);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-16 12:10:56 +00:00
|
|
|
Handle<CodeCache> NewCodeCache();
|
|
|
|
|
2013-11-14 17:30:48 +00:00
|
|
|
Handle<AliasedArgumentsEntry> NewAliasedArgumentsEntry(
|
|
|
|
int aliased_context_slot);
|
|
|
|
|
2013-02-12 14:33:08 +00:00
|
|
|
Handle<ExecutableAccessorInfo> NewExecutableAccessorInfo();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Script> NewScript(Handle<String> source);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-05-19 11:47:34 +00:00
|
|
|
// Foreign objects are pretenured when allocated by the bootstrapper.
|
|
|
|
Handle<Foreign> NewForeign(Address addr,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-05-19 11:47:34 +00:00
|
|
|
// Allocate a new foreign object. The foreign is pretenured (allocated
|
|
|
|
// directly in the old generation).
|
|
|
|
Handle<Foreign> NewForeign(const AccessorDescriptor* foreign);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<ByteArray> NewByteArray(int length,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2009-07-28 08:43:51 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<ExternalArray> NewExternalArray(
|
2009-10-20 15:26:17 +00:00
|
|
|
int length,
|
|
|
|
ExternalArrayType array_type,
|
|
|
|
void* external_pointer,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
Handle<FixedTypedArrayBase> NewFixedTypedArray(
|
|
|
|
int length,
|
|
|
|
ExternalArrayType array_type,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2009-10-20 15:26:17 +00:00
|
|
|
|
2013-06-12 15:03:44 +00:00
|
|
|
Handle<Cell> NewCell(Handle<Object> value);
|
|
|
|
|
2015-03-17 13:27:25 +00:00
|
|
|
Handle<PropertyCell> NewPropertyCell();
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2014-10-14 14:43:45 +00:00
|
|
|
Handle<WeakCell> NewWeakCell(Handle<HeapObject> value);
|
|
|
|
|
2014-04-16 12:54:29 +00:00
|
|
|
// Allocate a tenured AllocationSite. It's payload is null.
|
2013-07-08 10:02:16 +00:00
|
|
|
Handle<AllocationSite> NewAllocationSite();
|
|
|
|
|
2012-05-23 14:24:29 +00:00
|
|
|
Handle<Map> NewMap(
|
|
|
|
InstanceType type,
|
|
|
|
int instance_size,
|
|
|
|
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-17 13:15:22 +00:00
|
|
|
Handle<HeapObject> NewFillerObject(int size,
|
|
|
|
bool double_align,
|
|
|
|
AllocationSpace space);
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-29 07:02:11 +00:00
|
|
|
Handle<JSObject> CopyJSObject(Handle<JSObject> object);
|
|
|
|
|
|
|
|
Handle<JSObject> CopyJSObjectWithAllocationSite(Handle<JSObject> object,
|
|
|
|
Handle<AllocationSite> site);
|
|
|
|
|
2014-04-28 15:33:16 +00:00
|
|
|
Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
|
|
|
|
Handle<Map> map);
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-03-17 13:42:37 +00:00
|
|
|
// This method expects a COW array in new space, and creates a copy
|
|
|
|
// of it in old space.
|
|
|
|
Handle<FixedArray> CopyAndTenureFixedCOWArray(Handle<FixedArray> array);
|
|
|
|
|
2011-10-19 11:36:55 +00:00
|
|
|
Handle<FixedDoubleArray> CopyFixedDoubleArray(
|
|
|
|
Handle<FixedDoubleArray> array);
|
|
|
|
|
2013-10-14 13:35:06 +00:00
|
|
|
Handle<ConstantPoolArray> CopyConstantPoolArray(
|
|
|
|
Handle<ConstantPoolArray> array);
|
|
|
|
|
2012-01-16 12:38:59 +00:00
|
|
|
// Numbers (e.g. literals) are pretenured by the parser.
|
2014-04-16 14:04:54 +00:00
|
|
|
// The return value may be a smi or a heap number.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Object> NewNumber(double value,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-11-21 10:18:47 +00:00
|
|
|
Handle<Object> NewNumberFromInt(int32_t value,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
Handle<Object> NewNumberFromUint(uint32_t value,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2014-03-31 12:01:02 +00:00
|
|
|
Handle<Object> NewNumberFromSize(size_t value,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED) {
|
|
|
|
if (Smi::IsValid(static_cast<intptr_t>(value))) {
|
|
|
|
return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
|
|
|
|
isolate());
|
|
|
|
}
|
|
|
|
return NewNumber(static_cast<double>(value), pretenure);
|
|
|
|
}
|
2013-05-08 15:02:08 +00:00
|
|
|
Handle<HeapNumber> NewHeapNumber(double value,
|
2014-07-01 15:02:31 +00:00
|
|
|
MutableMode mode = IMMUTABLE,
|
2013-05-08 15:02:08 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// These objects are used by the api to create env-independent data
|
|
|
|
// structures in the heap.
|
2014-04-29 08:25:24 +00:00
|
|
|
inline Handle<JSObject> NewNeanderObject() {
|
|
|
|
return NewJSObjectFromMap(neander_map());
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2015-02-05 09:40:13 +00:00
|
|
|
Handle<JSWeakMap> NewJSWeakMap();
|
|
|
|
|
2014-07-07 13:27:37 +00:00
|
|
|
Handle<JSObject> NewArgumentsObject(Handle<JSFunction> callee, int length);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// JS objects are pretenured when allocated by the bootstrapper and
|
|
|
|
// runtime.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<JSObject> NewJSObject(Handle<JSFunction> constructor,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2014-03-19 13:39:09 +00:00
|
|
|
// JSObject that should have a memento pointing to the allocation site.
|
|
|
|
Handle<JSObject> NewJSObjectWithMemento(Handle<JSFunction> constructor,
|
|
|
|
Handle<AllocationSite> site);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-10-21 13:55:24 +00:00
|
|
|
// Global objects are pretenured and initialized based on a constructor.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor);
|
2009-06-30 10:05:36 +00:00
|
|
|
|
2008-09-25 07:46:07 +00:00
|
|
|
// JS objects are pretenured when allocated by the bootstrapper and
|
|
|
|
// runtime.
|
2014-03-17 15:01:45 +00:00
|
|
|
Handle<JSObject> NewJSObjectFromMap(
|
|
|
|
Handle<Map> map,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED,
|
|
|
|
bool allocate_properties = true,
|
|
|
|
Handle<AllocationSite> allocation_site = Handle<AllocationSite>::null());
|
2013-08-07 11:24:14 +00:00
|
|
|
|
2012-04-16 14:43:27 +00:00
|
|
|
// JS modules are pretenured.
|
2012-07-09 08:59:03 +00:00
|
|
|
Handle<JSModule> NewJSModule(Handle<Context> context,
|
|
|
|
Handle<ScopeInfo> scope_info);
|
2012-04-16 14:43:27 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// JS arrays are pretenured when allocated by the parser.
|
2014-04-07 10:00:14 +00:00
|
|
|
|
2014-04-07 12:43:35 +00:00
|
|
|
// Create a JSArray with no elements.
|
2014-04-07 10:00:14 +00:00
|
|
|
Handle<JSArray> NewJSArray(
|
|
|
|
ElementsKind elements_kind,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
|
2014-04-07 12:43:35 +00:00
|
|
|
// Create a JSArray with a specified length and elements initialized
|
|
|
|
// according to the specified mode.
|
2014-03-21 11:22:16 +00:00
|
|
|
Handle<JSArray> NewJSArray(
|
2014-07-25 13:00:06 +00:00
|
|
|
ElementsKind elements_kind, int length, int capacity,
|
|
|
|
ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS,
|
2014-03-21 11:22:16 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
|
2012-05-23 14:24:29 +00:00
|
|
|
Handle<JSArray> NewJSArray(
|
|
|
|
int capacity,
|
|
|
|
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
|
2014-03-21 11:22:16 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED) {
|
2014-04-03 09:12:59 +00:00
|
|
|
if (capacity != 0) {
|
|
|
|
elements_kind = GetHoleyElementsKind(elements_kind);
|
|
|
|
}
|
2014-03-27 16:41:09 +00:00
|
|
|
return NewJSArray(elements_kind, 0, capacity,
|
|
|
|
INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
|
2014-03-21 11:22:16 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 12:43:35 +00:00
|
|
|
// Create a JSArray with the given elements.
|
2014-03-21 11:22:16 +00:00
|
|
|
Handle<JSArray> NewJSArrayWithElements(
|
|
|
|
Handle<FixedArrayBase> elements,
|
|
|
|
ElementsKind elements_kind,
|
|
|
|
int length,
|
2012-05-23 14:24:29 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<JSArray> NewJSArrayWithElements(
|
2011-12-09 08:50:19 +00:00
|
|
|
Handle<FixedArrayBase> elements,
|
2012-05-23 14:24:29 +00:00
|
|
|
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
|
2014-03-21 11:22:16 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED) {
|
|
|
|
return NewJSArrayWithElements(
|
|
|
|
elements, elements_kind, elements->length(), pretenure);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-03-17 15:01:45 +00:00
|
|
|
void NewJSArrayStorage(
|
|
|
|
Handle<JSArray> array,
|
|
|
|
int length,
|
|
|
|
int capacity,
|
|
|
|
ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS);
|
|
|
|
|
2013-11-05 12:11:27 +00:00
|
|
|
Handle<JSGeneratorObject> NewJSGeneratorObject(Handle<JSFunction> function);
|
|
|
|
|
2013-04-25 12:02:23 +00:00
|
|
|
Handle<JSArrayBuffer> NewJSArrayBuffer();
|
|
|
|
|
2013-04-29 11:09:03 +00:00
|
|
|
Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type);
|
|
|
|
|
2015-04-27 09:28:16 +00:00
|
|
|
Handle<JSTypedArray> NewJSTypedArray(ElementsKind elements_kind);
|
|
|
|
|
2014-10-07 07:36:21 +00:00
|
|
|
// Creates a new JSTypedArray with the specified buffer.
|
|
|
|
Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type,
|
|
|
|
Handle<JSArrayBuffer> buffer,
|
2014-10-17 09:04:58 +00:00
|
|
|
size_t byte_offset, size_t length);
|
2014-10-07 07:36:21 +00:00
|
|
|
|
2015-04-27 09:28:16 +00:00
|
|
|
// Creates a new on-heap JSTypedArray.
|
|
|
|
Handle<JSTypedArray> NewJSTypedArray(ElementsKind elements_kind,
|
|
|
|
size_t number_of_elements);
|
|
|
|
|
2013-06-21 13:02:38 +00:00
|
|
|
Handle<JSDataView> NewJSDataView();
|
2014-10-17 09:04:58 +00:00
|
|
|
Handle<JSDataView> NewJSDataView(Handle<JSArrayBuffer> buffer,
|
|
|
|
size_t byte_offset, size_t byte_length);
|
2013-06-21 13:02:38 +00:00
|
|
|
|
2014-11-04 10:02:25 +00:00
|
|
|
// TODO(aandrey): Maybe these should take table, index and kind arguments.
|
|
|
|
Handle<JSMapIterator> NewJSMapIterator();
|
|
|
|
Handle<JSSetIterator> NewJSSetIterator();
|
|
|
|
|
2014-04-16 13:35:36 +00:00
|
|
|
// Allocates a Harmony proxy.
|
2011-05-13 10:58:25 +00:00
|
|
|
Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype);
|
|
|
|
|
2014-04-16 13:35:36 +00:00
|
|
|
// Allocates a Harmony function proxy.
|
2014-04-15 10:59:38 +00:00
|
|
|
Handle<JSProxy> NewJSFunctionProxy(Handle<Object> handler,
|
|
|
|
Handle<Object> call_trap,
|
|
|
|
Handle<Object> construct_trap,
|
|
|
|
Handle<Object> prototype);
|
|
|
|
|
2014-04-15 11:51:34 +00:00
|
|
|
// Reinitialize an JSGlobalProxy based on a constructor. The object
|
|
|
|
// must have the same size as objects allocated using the
|
|
|
|
// constructor. The object is reinitialized and behaves as an
|
|
|
|
// object that has been freshly allocated using the constructor.
|
|
|
|
void ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> global,
|
|
|
|
Handle<JSFunction> constructor);
|
|
|
|
|
2015-01-14 16:42:15 +00:00
|
|
|
Handle<JSGlobalProxy> NewUninitializedJSGlobalProxy();
|
|
|
|
|
2011-09-13 11:42:57 +00:00
|
|
|
// Change the type of the argument into a JS object/function and reinitialize.
|
2014-08-27 15:54:23 +00:00
|
|
|
void BecomeJSObject(Handle<JSProxy> object);
|
|
|
|
void BecomeJSFunction(Handle<JSProxy> object);
|
2011-07-18 13:04:52 +00:00
|
|
|
|
2015-04-09 22:40:16 +00:00
|
|
|
Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code,
|
2014-05-09 17:59:15 +00:00
|
|
|
Handle<Object> prototype,
|
2015-04-09 22:40:16 +00:00
|
|
|
bool read_only_prototype = false,
|
|
|
|
bool is_strict = false);
|
2014-05-09 16:39:33 +00:00
|
|
|
Handle<JSFunction> NewFunction(Handle<String> name);
|
2014-05-09 17:39:54 +00:00
|
|
|
Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
|
2015-04-09 22:40:16 +00:00
|
|
|
Handle<Code> code,
|
|
|
|
bool is_strict = false);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
|
2010-03-23 06:04:44 +00:00
|
|
|
Handle<SharedFunctionInfo> function_info,
|
2009-12-16 15:43:20 +00:00
|
|
|
Handle<Context> context,
|
|
|
|
PretenureFlag pretenure = TENURED);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-11-13 14:12:03 +00:00
|
|
|
Handle<JSFunction> NewFunction(Handle<String> name, Handle<Code> code,
|
|
|
|
Handle<Object> prototype, InstanceType type,
|
2014-05-09 17:59:15 +00:00
|
|
|
int instance_size,
|
2014-11-13 14:12:03 +00:00
|
|
|
bool read_only_prototype = false,
|
2015-04-09 22:40:16 +00:00
|
|
|
bool install_constructor = false,
|
|
|
|
bool is_strict = false);
|
2014-04-15 11:51:34 +00:00
|
|
|
Handle<JSFunction> NewFunction(Handle<String> name,
|
2014-05-09 17:39:54 +00:00
|
|
|
Handle<Code> code,
|
2014-04-15 11:51:34 +00:00
|
|
|
InstanceType type,
|
2014-05-09 17:39:54 +00:00
|
|
|
int instance_size);
|
2014-04-15 11:51:34 +00:00
|
|
|
|
2014-04-07 10:12:54 +00:00
|
|
|
// Create a serialized scope info.
|
2011-11-03 10:36:55 +00:00
|
|
|
Handle<ScopeInfo> NewScopeInfo(int length);
|
2011-08-11 16:29:28 +00:00
|
|
|
|
2014-04-07 10:12:54 +00:00
|
|
|
// Create an External object for V8's external API.
|
2012-11-13 12:27:03 +00:00
|
|
|
Handle<JSObject> NewExternal(void* value);
|
|
|
|
|
2014-04-16 11:38:56 +00:00
|
|
|
// The reference to the Code object is stored in self_reference.
|
|
|
|
// This allows generated code to reference its own Code object
|
|
|
|
// by containing this handle.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Code> NewCode(const CodeDesc& desc,
|
|
|
|
Code::Flags flags,
|
|
|
|
Handle<Object> self_reference,
|
2013-04-18 09:50:46 +00:00
|
|
|
bool immovable = false,
|
2013-10-23 13:48:04 +00:00
|
|
|
bool crankshafted = false,
|
2014-05-12 13:47:01 +00:00
|
|
|
int prologue_offset = Code::kPrologueOffsetNotSet,
|
|
|
|
bool is_debug = false);
|
2008-11-25 11:07:48 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Code> CopyCode(Handle<Code> code);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Code> CopyCode(Handle<Code> code, Vector<byte> reloc_info);
|
2010-03-15 21:06:51 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Interface for creating error objects.
|
|
|
|
|
2015-02-24 09:01:33 +00:00
|
|
|
Handle<Object> NewError(const char* maker, const char* message,
|
|
|
|
Handle<JSArray> args);
|
2013-06-06 13:28:22 +00:00
|
|
|
Handle<String> EmergencyNewError(const char* message, Handle<JSArray> args);
|
2015-04-16 07:01:20 +00:00
|
|
|
|
2015-02-24 09:01:33 +00:00
|
|
|
Handle<Object> NewError(const char* constructor, Handle<String> message);
|
2014-09-01 09:11:44 +00:00
|
|
|
|
2015-02-24 09:01:33 +00:00
|
|
|
Handle<Object> NewInvalidStringLengthError() {
|
2015-05-06 07:51:56 +00:00
|
|
|
return NewRangeError(MessageTemplate::kInvalidStringLength);
|
2014-04-03 12:30:37 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 08:35:59 +00:00
|
|
|
Handle<Object> NewError(const char* maker,
|
|
|
|
MessageTemplate::Template template_index,
|
|
|
|
Handle<Object> arg0, Handle<Object> arg1,
|
|
|
|
Handle<Object> arg2);
|
|
|
|
|
|
|
|
Handle<Object> NewError(MessageTemplate::Template template_index,
|
|
|
|
Handle<Object> arg0 = Handle<Object>(),
|
|
|
|
Handle<Object> arg1 = Handle<Object>(),
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
|
|
|
|
|
|
|
Handle<Object> NewTypeError(MessageTemplate::Template template_index,
|
|
|
|
Handle<Object> arg0 = Handle<Object>(),
|
|
|
|
Handle<Object> arg1 = Handle<Object>(),
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
|
|
|
|
2015-05-15 13:32:32 +00:00
|
|
|
Handle<Object> NewSyntaxError(MessageTemplate::Template template_index,
|
|
|
|
Handle<Object> arg0 = Handle<Object>(),
|
|
|
|
Handle<Object> arg1 = Handle<Object>(),
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
|
|
|
|
2015-05-07 10:00:21 +00:00
|
|
|
Handle<Object> NewReferenceError(MessageTemplate::Template template_index,
|
|
|
|
Handle<Object> arg0 = Handle<Object>(),
|
|
|
|
Handle<Object> arg1 = Handle<Object>(),
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
|
|
|
|
2015-05-06 07:51:56 +00:00
|
|
|
Handle<Object> NewRangeError(MessageTemplate::Template template_index,
|
|
|
|
Handle<Object> arg0 = Handle<Object>(),
|
|
|
|
Handle<Object> arg1 = Handle<Object>(),
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
|
|
|
|
2015-04-17 08:35:59 +00:00
|
|
|
Handle<Object> NewEvalError(MessageTemplate::Template template_index,
|
|
|
|
Handle<Object> arg0 = Handle<Object>(),
|
|
|
|
Handle<Object> arg1 = Handle<Object>(),
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
|
|
|
|
2014-04-15 11:16:02 +00:00
|
|
|
Handle<String> NumberToString(Handle<Object> number,
|
|
|
|
bool check_number_string_cache = true);
|
2014-04-16 14:04:54 +00:00
|
|
|
|
|
|
|
Handle<String> Uint32ToString(uint32_t value) {
|
|
|
|
return NumberToString(NewNumberFromUint(value));
|
|
|
|
}
|
2009-10-02 13:43:16 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<JSFunction> InstallMembers(Handle<JSFunction> function);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-09-08 09:11:11 +00:00
|
|
|
#define ROOT_ACCESSOR(type, name, camel_name) \
|
|
|
|
inline Handle<type> name() { \
|
|
|
|
return Handle<type>(bit_cast<type**>( \
|
|
|
|
&isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \
|
2009-07-08 19:12:58 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
ROOT_LIST(ROOT_ACCESSOR)
|
2013-09-20 09:27:40 +00:00
|
|
|
#undef ROOT_ACCESSOR
|
|
|
|
|
2014-09-08 09:11:11 +00:00
|
|
|
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
|
|
|
|
inline Handle<Map> name##_map() { \
|
|
|
|
return Handle<Map>(bit_cast<Map**>( \
|
|
|
|
&isolate()->heap()->roots_[Heap::k##Name##MapRootIndex])); \
|
|
|
|
}
|
2013-09-20 09:27:40 +00:00
|
|
|
STRUCT_LIST(STRUCT_MAP_ACCESSOR)
|
|
|
|
#undef STRUCT_MAP_ACCESSOR
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-09-08 09:11:11 +00:00
|
|
|
#define STRING_ACCESSOR(name, str) \
|
|
|
|
inline Handle<String> name() { \
|
|
|
|
return Handle<String>(bit_cast<String**>( \
|
|
|
|
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
2009-07-08 19:12:58 +00:00
|
|
|
}
|
2013-02-28 17:03:34 +00:00
|
|
|
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
|
|
|
|
#undef STRING_ACCESSOR
|
2009-03-19 19:29:23 +00:00
|
|
|
|
2014-10-01 11:53:29 +00:00
|
|
|
#define SYMBOL_ACCESSOR(name) \
|
|
|
|
inline Handle<Symbol> name() { \
|
|
|
|
return Handle<Symbol>(bit_cast<Symbol**>( \
|
|
|
|
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
|
|
|
}
|
|
|
|
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
|
|
|
#undef SYMBOL_ACCESSOR
|
|
|
|
|
2014-11-13 08:47:52 +00:00
|
|
|
#define SYMBOL_ACCESSOR(name, varname, description) \
|
|
|
|
inline Handle<Symbol> name() { \
|
|
|
|
return Handle<Symbol>(bit_cast<Symbol**>( \
|
|
|
|
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
|
|
|
}
|
|
|
|
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
|
|
|
#undef SYMBOL_ACCESSOR
|
|
|
|
|
2014-04-23 15:43:39 +00:00
|
|
|
inline void set_string_table(Handle<StringTable> table) {
|
|
|
|
isolate()->heap()->set_string_table(*table);
|
|
|
|
}
|
|
|
|
|
2015-04-28 11:13:22 +00:00
|
|
|
inline void set_weak_stack_trace_list(Handle<WeakFixedArray> list) {
|
|
|
|
isolate()->heap()->set_weak_stack_trace_list(*list);
|
|
|
|
}
|
|
|
|
|
2013-02-28 17:03:34 +00:00
|
|
|
Handle<String> hidden_string() {
|
|
|
|
return Handle<String>(&isolate()->heap()->hidden_string_);
|
2009-03-19 18:50:00 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-16 13:35:36 +00:00
|
|
|
// Allocates a new SharedFunctionInfo object.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<SharedFunctionInfo> NewSharedFunctionInfo(
|
2014-09-10 16:39:42 +00:00
|
|
|
Handle<String> name, int number_of_literals, FunctionKind kind,
|
|
|
|
Handle<Code> code, Handle<ScopeInfo> scope_info,
|
2014-09-18 09:59:53 +00:00
|
|
|
Handle<TypeFeedbackVector> feedback_vector);
|
2014-05-09 17:39:54 +00:00
|
|
|
Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name,
|
|
|
|
MaybeHandle<Code> code);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-30 14:33:35 +00:00
|
|
|
// Allocate a new type feedback vector
|
2015-03-17 15:16:21 +00:00
|
|
|
template <typename Spec>
|
|
|
|
Handle<TypeFeedbackVector> NewTypeFeedbackVector(const Spec* spec);
|
2014-04-30 14:33:35 +00:00
|
|
|
|
2014-04-16 13:35:36 +00:00
|
|
|
// Allocates a new JSMessageObject object.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<JSMessageObject> NewJSMessageObject(
|
2011-02-02 13:31:52 +00:00
|
|
|
Handle<String> type,
|
|
|
|
Handle<JSArray> arguments,
|
|
|
|
int start_position,
|
|
|
|
int end_position,
|
|
|
|
Handle<Object> script,
|
|
|
|
Handle<Object> stack_frames);
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<DebugInfo> NewDebugInfo(Handle<SharedFunctionInfo> shared);
|
2008-09-25 07:46:07 +00:00
|
|
|
|
2014-11-10 18:03:50 +00:00
|
|
|
// Return a map for given number of properties using the map cache in the
|
|
|
|
// native context.
|
2011-03-18 20:35:07 +00:00
|
|
|
Handle<Map> ObjectLiteralMapFromCache(Handle<Context> context,
|
2014-11-10 18:03:50 +00:00
|
|
|
int number_of_properties,
|
|
|
|
bool* is_result_from_cache);
|
2008-09-25 07:46:07 +00:00
|
|
|
|
2008-10-24 08:40:02 +00:00
|
|
|
// Creates a new FixedArray that holds the data associated with the
|
2009-03-11 14:00:55 +00:00
|
|
|
// atom regexp and stores it in the regexp.
|
2011-03-18 20:35:07 +00:00
|
|
|
void SetRegExpAtomData(Handle<JSRegExp> regexp,
|
|
|
|
JSRegExp::Type type,
|
|
|
|
Handle<String> source,
|
|
|
|
JSRegExp::Flags flags,
|
|
|
|
Handle<Object> match_pattern);
|
2009-03-11 14:00:55 +00:00
|
|
|
|
|
|
|
// Creates a new FixedArray that holds the data associated with the
|
|
|
|
// irregexp regexp and stores it in the regexp.
|
2011-03-18 20:35:07 +00:00
|
|
|
void SetRegExpIrregexpData(Handle<JSRegExp> regexp,
|
|
|
|
JSRegExp::Type type,
|
|
|
|
Handle<String> source,
|
|
|
|
JSRegExp::Flags flags,
|
|
|
|
int capture_count);
|
2008-10-24 08:40:02 +00:00
|
|
|
|
2011-09-23 08:00:06 +00:00
|
|
|
// Returns the value for a known global constant (a property of the global
|
|
|
|
// object which is neither configurable nor writable) like 'undefined'.
|
|
|
|
// Returns a null handle when the given name is unknown.
|
2015-04-13 16:22:11 +00:00
|
|
|
Handle<Object> GlobalConstantFor(Handle<Name> name);
|
2011-09-23 08:00:06 +00:00
|
|
|
|
2011-10-10 09:21:48 +00:00
|
|
|
// Converts the given boolean condition to JavaScript boolean value.
|
|
|
|
Handle<Object> ToBoolean(bool value);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate* isolate() { return reinterpret_cast<Isolate*>(this); }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-15 11:51:34 +00:00
|
|
|
// Creates a heap object based on the map. The fields of the heap object are
|
|
|
|
// not initialized by New<>() functions. It's the responsibility of the caller
|
|
|
|
// to do that.
|
|
|
|
template<typename T>
|
|
|
|
Handle<T> New(Handle<Map> map, AllocationSpace space);
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
Handle<T> New(Handle<Map> map,
|
|
|
|
AllocationSpace space,
|
|
|
|
Handle<AllocationSite> allocation_site);
|
|
|
|
|
2014-04-29 13:58:55 +00:00
|
|
|
// Creates a code object that is not yet fully initialized yet.
|
|
|
|
inline Handle<Code> NewCodeRaw(int object_size, bool immovable);
|
|
|
|
|
2014-04-16 14:04:54 +00:00
|
|
|
// Attempt to find the number in a small cache. If we finds it, return
|
|
|
|
// the string representation of the number. Otherwise return undefined.
|
|
|
|
Handle<Object> GetNumberStringCache(Handle<Object> number);
|
|
|
|
|
|
|
|
// Update the cache with a new number-string pair.
|
|
|
|
void SetNumberStringCache(Handle<Object> number, Handle<String> string);
|
2014-05-09 17:39:54 +00:00
|
|
|
|
|
|
|
// Initializes a function with a shared part and prototype.
|
|
|
|
// Note: this code was factored out of NewFunction such that other parts of
|
|
|
|
// the VM could use it. Specifically, a function that creates instances of
|
|
|
|
// type JS_FUNCTION_TYPE benefit from the use of this function.
|
|
|
|
inline void InitializeFunction(Handle<JSFunction> function,
|
|
|
|
Handle<SharedFunctionInfo> info,
|
|
|
|
Handle<Context> context);
|
|
|
|
|
|
|
|
// Creates a function initialized with a shared part.
|
|
|
|
Handle<JSFunction> NewFunction(Handle<Map> map,
|
|
|
|
Handle<SharedFunctionInfo> info,
|
|
|
|
Handle<Context> context,
|
|
|
|
PretenureFlag pretenure = TENURED);
|
|
|
|
|
|
|
|
Handle<JSFunction> NewFunction(Handle<Map> map,
|
|
|
|
Handle<String> name,
|
|
|
|
MaybeHandle<Code> maybe_code);
|
2014-08-27 15:54:23 +00:00
|
|
|
|
|
|
|
// Reinitialize a JSProxy into an (empty) JS object of respective type and
|
|
|
|
// size, but keeping the original prototype. The receiver must have at least
|
|
|
|
// the size of the new object. The object is reinitialized and behaves as an
|
|
|
|
// object that has been freshly allocated.
|
|
|
|
void ReinitializeJSProxy(Handle<JSProxy> proxy, InstanceType type, int size);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_FACTORY_H_
|