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"
|
2015-10-12 15:21:20 +00:00
|
|
|
#include "src/type-feedback-vector.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
|
|
|
// 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:
|
2015-08-11 10:47:24 +00:00
|
|
|
Handle<Oddball> NewOddball(Handle<Map> map, const char* to_string,
|
2016-02-29 12:16:00 +00:00
|
|
|
Handle<Object> to_number, bool to_boolean,
|
|
|
|
const char* type_of, byte kind);
|
2014-04-16 14:15:32 +00:00
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
[es6] Parameter scopes for sloppy eval
This CL is a nightmare! For the utterly irrelevant edge case of a sloppy function with non-simple parameters and a call to direct eval, like here,
let x = 1;
function f(g = () => x) {
var y
eval("var x = 2")
return g() + x // f() = 3
}
we have to do all of the following, on top of the declaration block ("varblock") contexts we already introduce around the body:
- Introduce the ability for varblock contexts to have both a ScopeInfo and an extension object (e.g., the body varblock in the example will contain both a static var y and a dynamic var x). No other scope needs that. Since there are no context slots left, a special new struct is introduced that pairs up scope info and extension object.
- When declaring lookup slots in the runtime, this new struct is allocated in the case where an extension object has to be added to a block scope (at which point the block's extension slot still contains a plain ScopeInfo).
- While at it, introduce some abstraction to access context extension slots in a more controlled manner, in order to keep special-casing to a minimum.
- Make sure that even empty varblock contexts do not get optimised away when they contain a sloppy eval, so that they can host the potential extension object.
- Extend dynamic search for declaration contexts (used by sloppy direct eval) to recognize varblock contexts.
- In the parser, if a function has a sloppy direct eval, introduce an additional varblock scope around each non-simple (desugared) parameter, as required by the spec to contain possible dynamic var bindings.
- In the pattern rewriter, add the ability to hoist the named variables the pattern declares to an outer scope. That is required because the actual destructuring has to be evaluated inside the protecting varblock scope, but the bindings that the desugaring introduces are in the outer scope.
- ScopeInfos need to save the information whether a block is a varblock, to make sloppy eval calls work correctly that deserialise them as part of the scope chain.
- Add the ability to materialize block scopes with extension objects in the debugger. Likewise, enable setting extension variables in block scopes via the debugger interface.
- While at it, refactor and unify some respective code in the debugger.
Sorry, this CL is large. I could try to split it up, but everything is rather entangled.
@mstarzinger: Please review the changes to contexts.
@yangguo: Please have a look at the debugger stuff.
R=littledan@chromium.org, mstarzinger@chromium.org, yangguo@chromium.org
BUG=v8:811,v8:2160
LOG=N
Review URL: https://codereview.chromium.org/1292753007
Cr-Commit-Position: refs/heads/master@{#30295}
2015-08-21 10:58:35 +00:00
|
|
|
// Create a new SloppyBlockWithEvalContextExtension struct.
|
|
|
|
Handle<SloppyBlockWithEvalContextExtension>
|
|
|
|
NewSloppyBlockWithEvalContextExtension(Handle<ScopeInfo> scope_info,
|
|
|
|
Handle<JSObject> extension);
|
|
|
|
|
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
|
|
|
}
|
2016-02-18 14:33:34 +00:00
|
|
|
|
2013-02-28 17:03:34 +00:00
|
|
|
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);
|
|
|
|
|
2016-02-18 14:33:34 +00:00
|
|
|
// Internalized strings are created in the old generation (data space).
|
|
|
|
Handle<String> InternalizeString(Handle<String> string) {
|
|
|
|
if (string->IsInternalizedString()) return string;
|
|
|
|
return StringTable::LookupString(isolate(), string);
|
|
|
|
}
|
2015-11-02 08:55:02 +00:00
|
|
|
|
2016-02-18 14:33:34 +00:00
|
|
|
Handle<Name> InternalizeName(Handle<Name> name) {
|
|
|
|
if (name->IsUniqueName()) return name;
|
|
|
|
return StringTable::LookupString(isolate(), Handle<String>::cast(name));
|
|
|
|
}
|
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.
|
2015-09-29 08:08:14 +00:00
|
|
|
Handle<String> NewInternalizedStringFromUtf8(Vector<const char> str,
|
|
|
|
int chars, uint32_t hash_field);
|
2014-04-25 13:59:33 +00:00
|
|
|
|
2015-09-29 08:08:14 +00:00
|
|
|
Handle<String> NewOneByteInternalizedString(Vector<const uint8_t> str,
|
|
|
|
uint32_t hash_field);
|
2014-08-19 08:53:38 +00:00
|
|
|
|
2015-09-29 08:08:14 +00:00
|
|
|
Handle<String> NewOneByteInternalizedSubString(
|
2014-08-19 08:53:38 +00:00
|
|
|
Handle<SeqOneByteString> string, int offset, int length,
|
|
|
|
uint32_t hash_field);
|
2014-04-25 13:59:33 +00:00
|
|
|
|
2015-09-29 08:08:14 +00:00
|
|
|
Handle<String> NewTwoByteInternalizedString(Vector<const uc16> str,
|
|
|
|
uint32_t hash_field);
|
2014-04-25 13:59:33 +00:00
|
|
|
|
2015-09-29 08:08:14 +00:00
|
|
|
Handle<String> NewInternalizedStringImpl(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);
|
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();
|
2015-10-29 14:17:24 +00:00
|
|
|
Handle<Symbol> NewPrivateSymbol();
|
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);
|
|
|
|
|
2016-01-18 15:08:36 +00:00
|
|
|
Handle<AccessorInfo> NewAccessorInfo();
|
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
|
|
|
|
2015-07-24 14:56:26 +00:00
|
|
|
Handle<BytecodeArray> NewBytecodeArray(int length, const byte* raw_bytecodes,
|
2015-08-27 11:11:09 +00:00
|
|
|
int frame_size, int parameter_count,
|
|
|
|
Handle<FixedArray> constant_pool);
|
2015-07-24 12:02:41 +00:00
|
|
|
|
2015-07-28 09:29:34 +00:00
|
|
|
Handle<FixedTypedArrayBase> NewFixedTypedArrayWithExternalPointer(
|
|
|
|
int length, ExternalArrayType array_type, void* external_pointer,
|
2009-10-20 15:26:17 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2014-01-16 17:08:45 +00:00
|
|
|
|
|
|
|
Handle<FixedTypedArrayBase> NewFixedTypedArray(
|
2015-06-03 07:41:28 +00:00
|
|
|
int length, ExternalArrayType array_type, bool initialize,
|
2014-01-16 17:08:45 +00:00
|
|
|
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);
|
|
|
|
|
2015-12-03 13:18:19 +00:00
|
|
|
Handle<TransitionArray> NewTransitionArray(int capacity);
|
|
|
|
|
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);
|
|
|
|
|
2015-08-05 08:53:17 +00:00
|
|
|
Handle<FixedArray> CopyFixedArrayAndGrow(
|
|
|
|
Handle<FixedArray> array, int grow_by,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2015-08-04 17:48:42 +00:00
|
|
|
|
2016-02-11 18:58:49 +00:00
|
|
|
Handle<FixedArray> CopyFixedArrayUpTo(Handle<FixedArray> array, int new_len,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
|
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);
|
|
|
|
|
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) {
|
2016-01-14 17:23:22 +00:00
|
|
|
// We can't use Smi::IsValid() here because that operates on a signed
|
|
|
|
// intptr_t, and casting from size_t could create a bogus sign bit.
|
|
|
|
if (value <= static_cast<size_t>(Smi::kMaxValue)) {
|
2014-03-31 12:01:02 +00:00
|
|
|
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);
|
2015-08-17 18:58:38 +00:00
|
|
|
|
|
|
|
#define SIMD128_NEW_DECL(TYPE, Type, type, lane_count, lane_type) \
|
|
|
|
Handle<Type> New##Type(lane_type lanes[lane_count], \
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
|
|
|
SIMD128_TYPES(SIMD128_NEW_DECL)
|
|
|
|
#undef SIMD128_NEW_DECL
|
2013-05-08 15:02:08 +00:00
|
|
|
|
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.
|
2015-11-02 14:57:59 +00:00
|
|
|
Handle<JSGlobalObject> NewJSGlobalObject(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,
|
|
|
|
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 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,
|
2015-06-08 12:17:58 +00:00
|
|
|
Strength strength = Strength::WEAK,
|
2014-07-25 13:00:06 +00:00
|
|
|
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(
|
2015-06-08 12:17:58 +00:00
|
|
|
int capacity, ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
|
|
|
|
Strength strength = Strength::WEAK,
|
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);
|
|
|
|
}
|
2015-06-02 11:46:04 +00:00
|
|
|
return NewJSArray(elements_kind, 0, capacity, strength,
|
2014-03-27 16:41:09 +00:00
|
|
|
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.
|
2015-06-08 12:17:58 +00:00
|
|
|
Handle<JSArray> NewJSArrayWithElements(Handle<FixedArrayBase> elements,
|
|
|
|
ElementsKind elements_kind, int length,
|
|
|
|
Strength strength = Strength::WEAK,
|
|
|
|
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,
|
2015-06-08 12:17:58 +00:00
|
|
|
Strength strength = Strength::WEAK,
|
2014-03-21 11:22:16 +00:00
|
|
|
PretenureFlag pretenure = NOT_TENURED) {
|
2015-06-02 11:46:04 +00:00
|
|
|
return NewJSArrayWithElements(elements, elements_kind, elements->length(),
|
|
|
|
strength, pretenure);
|
2014-03-21 11:22:16 +00:00
|
|
|
}
|
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);
|
|
|
|
|
2015-05-22 13:43:38 +00:00
|
|
|
Handle<JSArrayBuffer> NewJSArrayBuffer(
|
2015-09-17 14:47:37 +00:00
|
|
|
SharedFlag shared = SharedFlag::kNotShared,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2013-04-25 12:02:23 +00:00
|
|
|
|
2015-09-17 14:47:37 +00:00
|
|
|
Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2013-04-29 11:09:03 +00:00
|
|
|
|
2015-09-17 14:47:37 +00:00
|
|
|
Handle<JSTypedArray> NewJSTypedArray(ElementsKind elements_kind,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2015-04-27 09:28:16 +00:00
|
|
|
|
2014-10-07 07:36:21 +00:00
|
|
|
// Creates a new JSTypedArray with the specified buffer.
|
|
|
|
Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type,
|
|
|
|
Handle<JSArrayBuffer> buffer,
|
2015-09-17 14:47:37 +00:00
|
|
|
size_t byte_offset, size_t length,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
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,
|
2015-09-17 14:47:37 +00:00
|
|
|
size_t number_of_elements,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2015-04-27 09:28:16 +00:00
|
|
|
|
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
|
|
|
|
2015-05-26 17:36:48 +00:00
|
|
|
Handle<JSMap> NewJSMap();
|
|
|
|
Handle<JSSet> NewJSSet();
|
|
|
|
|
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();
|
|
|
|
|
2015-12-27 06:30:53 +00:00
|
|
|
// Allocates a bound function.
|
|
|
|
MaybeHandle<JSBoundFunction> NewJSBoundFunction(
|
|
|
|
Handle<JSReceiver> target_function, Handle<Object> bound_this,
|
|
|
|
Vector<Handle<Object>> bound_args);
|
|
|
|
|
2014-04-16 13:35:36 +00:00
|
|
|
// Allocates a Harmony proxy.
|
2015-11-12 22:11:53 +00:00
|
|
|
Handle<JSProxy> NewJSProxy(Handle<JSReceiver> target,
|
2015-11-13 14:13:50 +00:00
|
|
|
Handle<JSReceiver> handler);
|
2011-05-13 10:58:25 +00:00
|
|
|
|
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();
|
|
|
|
|
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(
|
2015-11-03 16:42:21 +00:00
|
|
|
Handle<Map> initial_map, Handle<SharedFunctionInfo> function_info,
|
|
|
|
Handle<Context> context, PretenureFlag pretenure = TENURED);
|
|
|
|
|
|
|
|
Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
|
|
|
|
Handle<SharedFunctionInfo> function_info, Handle<Context> context,
|
2009-12-16 15:43:20 +00:00
|
|
|
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);
|
2015-12-08 16:04:08 +00:00
|
|
|
Handle<JSFunction> NewFunction(Handle<Map> map, Handle<String> name,
|
|
|
|
MaybeHandle<Code> maybe_code);
|
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
|
|
|
|
2016-02-22 13:16:46 +00:00
|
|
|
Handle<BytecodeArray> CopyBytecodeArray(Handle<BytecodeArray>);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Interface for creating error objects.
|
2015-08-14 15:12:34 +00:00
|
|
|
Handle<Object> NewError(Handle<JSFunction> 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-08-17 11:02:31 +00:00
|
|
|
Handle<Object> NewError(Handle<JSFunction> constructor,
|
2015-04-17 08:35:59 +00:00
|
|
|
MessageTemplate::Template template_index,
|
2015-05-18 08:34:05 +00:00
|
|
|
Handle<Object> arg0 = Handle<Object>(),
|
|
|
|
Handle<Object> arg1 = Handle<Object>(),
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
2015-04-17 08:35:59 +00:00
|
|
|
|
2015-09-01 09:25:19 +00:00
|
|
|
#define DECLARE_ERROR(NAME) \
|
|
|
|
Handle<Object> New##NAME(MessageTemplate::Template template_index, \
|
|
|
|
Handle<Object> arg0 = Handle<Object>(), \
|
|
|
|
Handle<Object> arg1 = Handle<Object>(), \
|
|
|
|
Handle<Object> arg2 = Handle<Object>());
|
|
|
|
DECLARE_ERROR(Error)
|
|
|
|
DECLARE_ERROR(EvalError)
|
|
|
|
DECLARE_ERROR(RangeError)
|
|
|
|
DECLARE_ERROR(ReferenceError)
|
|
|
|
DECLARE_ERROR(SyntaxError)
|
|
|
|
DECLARE_ERROR(TypeError)
|
2015-08-17 11:02:31 +00:00
|
|
|
#undef DEFINE_ERROR
|
2015-04-17 08:35:59 +00:00
|
|
|
|
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
|
|
|
|
|
2015-08-28 10:22:31 +00:00
|
|
|
#define SYMBOL_ACCESSOR(name, description) \
|
2014-11-13 08:47:52 +00:00
|
|
|
inline Handle<Symbol> name() { \
|
|
|
|
return Handle<Symbol>(bit_cast<Symbol**>( \
|
|
|
|
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
|
|
|
}
|
|
|
|
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
2015-10-06 18:10:20 +00:00
|
|
|
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
2014-11-13 08:47:52 +00:00
|
|
|
#undef SYMBOL_ACCESSOR
|
|
|
|
|
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,
|
2016-02-05 10:48:27 +00:00
|
|
|
Handle<TypeFeedbackVector> feedback_vector);
|
2014-05-09 17:39:54 +00:00
|
|
|
Handle<SharedFunctionInfo> NewSharedFunctionInfo(Handle<String> name,
|
2015-11-24 17:16:40 +00:00
|
|
|
MaybeHandle<Code> code,
|
|
|
|
bool is_constructor);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-04-16 13:35:36 +00:00
|
|
|
// Allocates a new JSMessageObject object.
|
2015-05-18 08:34:05 +00:00
|
|
|
Handle<JSMessageObject> NewJSMessageObject(MessageTemplate::Template message,
|
|
|
|
Handle<Object> argument,
|
|
|
|
int start_position,
|
|
|
|
int end_position,
|
|
|
|
Handle<Object> script,
|
|
|
|
Handle<Object> stack_frames);
|
2011-02-02 13:31:52 +00:00
|
|
|
|
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,
|
2015-05-20 07:07:54 +00:00
|
|
|
bool is_strong,
|
2014-11-10 18:03:50 +00:00
|
|
|
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
|
|
|
|
|
|
|
// Creates a function initialized with a shared part.
|
|
|
|
Handle<JSFunction> NewFunction(Handle<Map> map,
|
|
|
|
Handle<SharedFunctionInfo> info,
|
|
|
|
Handle<Context> context,
|
|
|
|
PretenureFlag pretenure = TENURED);
|
2016-01-29 18:57:26 +00:00
|
|
|
|
|
|
|
// Create a JSArray with no elements and no length.
|
|
|
|
Handle<JSArray> NewJSArray(ElementsKind elements_kind,
|
|
|
|
Strength strength = Strength::WEAK,
|
|
|
|
PretenureFlag pretenure = NOT_TENURED);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#endif // V8_FACTORY_H_
|