[bigint] Introduce BigInt type.

BigInt is a new primitive type of arbitrary precision integers,
proposed in https://tc39.github.io/proposal-bigint.

This CL introduces a corresponding instance type, map, and C++
class to V8 and adds BigInt support to a few operations (see the
test file). Much more is to come. Also, the concrete representation
of BigInts is not yet fixed, currently a BigInt is simply a wrapped
Smi.

Bug: v8:6791
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Ia2901948efd7808f17cfc945f0d56e23e8ae0b45
Reviewed-on: https://chromium-review.googlesource.com/657022
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47956}
This commit is contained in:
Georg Neis 2017-09-11 15:16:27 +02:00 committed by Commit Bot
parent 5afca6b14e
commit 0c246c33a3
31 changed files with 731 additions and 254 deletions

View File

@ -1769,6 +1769,9 @@ v8_source_set("v8_base") {
"src/objects.h",
"src/objects/arguments-inl.h",
"src/objects/arguments.h",
"src/objects/bigint-inl.h",
"src/objects/bigint.cc",
"src/objects/bigint.h",
"src/objects/code-cache-inl.h",
"src/objects/code-cache.h",
"src/objects/compilation-cache-inl.h",
@ -1901,6 +1904,7 @@ v8_source_set("v8_base") {
"src/runtime-profiler.h",
"src/runtime/runtime-array.cc",
"src/runtime/runtime-atomics.cc",
"src/runtime/runtime-bigint.cc",
"src/runtime/runtime-classes.cc",
"src/runtime/runtime-collections.cc",
"src/runtime/runtime-compiler.cc",

View File

@ -9076,11 +9076,11 @@ class Internals {
static const int kNodeIsIndependentShift = 3;
static const int kNodeIsActiveShift = 4;
static const int kJSApiObjectType = 0xbe;
static const int kJSObjectType = 0xbf;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x82;
static const int kForeignType = 0x86;
static const int kOddballType = 0x83;
static const int kForeignType = 0x87;
static const int kJSApiObjectType = 0xbf;
static const int kJSObjectType = 0xc0;
static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3;

View File

@ -4152,6 +4152,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_dynamic_import)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_template_escapes)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrict_constructor_return)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_strict_legacy_accessor_builtins)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_bigint)
void InstallPublicSymbol(Factory* factory, Handle<Context> native_context,
const char* name, Handle<Symbol> value) {

View File

@ -1819,8 +1819,8 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) {
{
VARIABLE(search_num, MachineRepresentation::kFloat64);
Label ident_loop(this, &index_var), heap_num_loop(this, &search_num),
string_loop(this), undef_loop(this, &index_var), not_smi(this),
not_heap_num(this);
string_loop(this), bigint_loop(this, &index_var),
undef_loop(this, &index_var), not_smi(this), not_heap_num(this);
GotoIfNot(TaggedIsSmi(search_element), &not_smi);
search_num.Bind(SmiToFloat64(CAST(search_element)));
@ -1838,6 +1838,7 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) {
BIND(&not_heap_num);
Node* search_type = LoadMapInstanceType(map);
GotoIf(IsStringInstanceType(search_type), &string_loop);
GotoIf(IsBigIntInstanceType(search_type), &bigint_loop);
Goto(&ident_loop);
BIND(&ident_loop);
@ -1942,6 +1943,18 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) {
Increment(&index_var);
Goto(&next_iteration);
}
BIND(&bigint_loop);
{
GotoIfNot(UintPtrLessThan(index_var.value(), array_length),
&return_not_found);
Node* element_k = LoadFixedArrayElement(elements, index_var.value());
TNode<Object> result = CallRuntime(Runtime::kBigIntEqual, context,
search_element, element_k);
GotoIf(WordEqual(result, TrueConstant()), &return_found);
Increment(&index_var);
Goto(&bigint_loop);
}
}
BIND(&if_packed_doubles);

View File

@ -84,6 +84,17 @@ class CollectionsBuiltinsAssembler : public CodeStubAssembler {
Label* entry_found,
Label* not_found);
// Specialization for bigints.
// The {result} variable will contain the entry index if the key was found,
// or the hash code otherwise.
void SameValueZeroBigInt(Node* key, Node* candidate_key, Label* if_same,
Label* if_not_same);
template <typename CollectionType>
void FindOrderedHashTableEntryForBigIntKey(Node* context, Node* table,
Node* key, Variable* result,
Label* entry_found,
Label* not_found);
// Specialization for string.
// The {result} variable will contain the entry index if the key was found,
// or the hash code otherwise.
@ -558,6 +569,21 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForHeapNumberKey(
result, entry_found, not_found);
}
template <typename CollectionType>
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForBigIntKey(
Node* context, Node* table, Node* key, Variable* result, Label* entry_found,
Label* not_found) {
Node* hash = CallGetHashRaw(key);
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
result->Bind(hash);
FindOrderedHashTableEntry<CollectionType>(
table, hash,
[&](Node* other_key, Label* if_same, Label* if_not_same) {
SameValueZeroBigInt(key, other_key, if_same, if_not_same);
},
result, entry_found, not_found);
}
template <typename CollectionType>
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForOtherKey(
Node* context, Node* table, Node* key, Variable* result, Label* entry_found,
@ -605,6 +631,20 @@ void CollectionsBuiltinsAssembler::SameValueZeroString(Node* context,
if_same, if_not_same);
}
void CollectionsBuiltinsAssembler::SameValueZeroBigInt(Node* key,
Node* candidate_key,
Label* if_same,
Label* if_not_same) {
CSA_ASSERT(this, IsBigInt(key));
GotoIf(TaggedIsSmi(candidate_key), if_not_same);
GotoIfNot(IsBigInt(candidate_key), if_not_same);
Branch(WordEqual(CallRuntime(Runtime::kBigIntEqual, NoContextConstant(), key,
candidate_key),
TrueConstant()),
if_same, if_not_same);
}
void CollectionsBuiltinsAssembler::SameValueZeroHeapNumber(Node* key_float,
Node* candidate_key,
Label* if_same,
@ -1409,11 +1449,12 @@ TF_BUILTIN(SetHas, CollectionsBuiltinsAssembler) {
IntPtrConstant(0));
VARIABLE(result, MachineRepresentation::kTaggedSigned, IntPtrConstant(0));
Label if_key_smi(this), if_key_string(this), if_key_heap_number(this),
entry_found(this), not_found(this), done(this);
if_key_bigint(this), entry_found(this), not_found(this), done(this);
GotoIf(TaggedIsSmi(key), &if_key_smi);
GotoIf(IsString(key), &if_key_string);
GotoIf(IsHeapNumber(key), &if_key_heap_number);
GotoIf(IsBigInt(key), &if_key_bigint);
FindOrderedHashTableEntryForOtherKey<OrderedHashSet>(
context, table, key, &entry_start_position, &entry_found, &not_found);
@ -1436,6 +1477,12 @@ TF_BUILTIN(SetHas, CollectionsBuiltinsAssembler) {
context, table, key, &entry_start_position, &entry_found, &not_found);
}
BIND(&if_key_bigint);
{
FindOrderedHashTableEntryForBigIntKey<OrderedHashSet>(
context, table, key, &entry_start_position, &entry_found, &not_found);
}
BIND(&entry_found);
Return(TrueConstant());
@ -1596,11 +1643,13 @@ template <typename CollectionType>
void CollectionsBuiltinsAssembler::TryLookupOrderedHashTableIndex(
Node* const table, Node* const key, Node* const context, Variable* result,
Label* if_entry_found, Label* if_not_found) {
Label if_key_smi(this), if_key_string(this), if_key_heap_number(this);
Label if_key_smi(this), if_key_string(this), if_key_heap_number(this),
if_key_bigint(this);
GotoIf(TaggedIsSmi(key), &if_key_smi);
GotoIf(IsString(key), &if_key_string);
GotoIf(IsHeapNumber(key), &if_key_heap_number);
GotoIf(IsBigInt(key), &if_key_bigint);
FindOrderedHashTableEntryForOtherKey<CollectionType>(
context, table, key, result, if_entry_found, if_not_found);
@ -1622,6 +1671,12 @@ void CollectionsBuiltinsAssembler::TryLookupOrderedHashTableIndex(
FindOrderedHashTableEntryForHeapNumberKey<CollectionType>(
context, table, key, result, if_entry_found, if_not_found);
}
BIND(&if_key_bigint);
{
FindOrderedHashTableEntryForBigIntKey<CollectionType>(
context, table, key, result, if_entry_found, if_not_found);
}
}
TF_BUILTIN(MapLookupHashIndex, CollectionsBuiltinsAssembler) {

View File

@ -992,22 +992,21 @@ Node* CodeStubAssembler::IsRegularHeapObjectSize(Node* size) {
void CodeStubAssembler::BranchIfToBooleanIsTrue(Node* value, Label* if_true,
Label* if_false) {
Label if_valueissmi(this), if_valueisnotsmi(this),
if_valueisheapnumber(this, Label::kDeferred);
Label if_smi(this), if_notsmi(this), if_heapnumber(this, Label::kDeferred),
if_bigint(this, Label::kDeferred);
// Rule out false {value}.
GotoIf(WordEqual(value, BooleanConstant(false)), if_false);
// Check if {value} is a Smi or a HeapObject.
Branch(TaggedIsSmi(value), &if_valueissmi, &if_valueisnotsmi);
Branch(TaggedIsSmi(value), &if_smi, &if_notsmi);
BIND(&if_valueissmi);
BIND(&if_smi);
{
// The {value} is a Smi, only need to check against zero.
BranchIfSmiEqual(value, SmiConstant(0), if_false, if_true);
}
BIND(&if_valueisnotsmi);
BIND(&if_notsmi);
{
// Check if {value} is the empty string.
GotoIf(IsEmptyString(value), if_false);
@ -1021,9 +1020,10 @@ void CodeStubAssembler::BranchIfToBooleanIsTrue(Node* value, Label* if_true,
// We still need to handle numbers specially, but all other {value}s
// that make it here yield true.
Branch(IsHeapNumberMap(value_map), &if_valueisheapnumber, if_true);
GotoIf(IsHeapNumberMap(value_map), &if_heapnumber);
Branch(IsBigInt(value), &if_bigint, if_true);
BIND(&if_valueisheapnumber);
BIND(&if_heapnumber);
{
// Load the floating point value of {value}.
Node* value_value = LoadObjectField(value, HeapNumber::kValueOffset,
@ -1033,6 +1033,14 @@ void CodeStubAssembler::BranchIfToBooleanIsTrue(Node* value, Label* if_true,
Branch(Float64LessThan(Float64Constant(0.0), Float64Abs(value_value)),
if_true, if_false);
}
BIND(&if_bigint);
{
Node* result =
CallRuntime(Runtime::kBigIntToBoolean, NoContextConstant(), value);
CSA_ASSERT(this, IsBoolean(result));
Branch(WordEqual(result, BooleanConstant(true)), if_true, if_false);
}
}
}
@ -3810,6 +3818,14 @@ Node* CodeStubAssembler::IsSymbol(Node* object) {
return IsSymbolMap(LoadMap(object));
}
Node* CodeStubAssembler::IsBigIntInstanceType(Node* instance_type) {
return Word32Equal(instance_type, Int32Constant(BIGINT_TYPE));
}
Node* CodeStubAssembler::IsBigInt(Node* object) {
return IsBigIntInstanceType(LoadInstanceType(object));
}
Node* CodeStubAssembler::IsPrimitiveInstanceType(Node* instance_type) {
return Int32LessThanOrEqual(instance_type,
Int32Constant(LAST_PRIMITIVE_TYPE));
@ -8518,6 +8534,7 @@ Node* CodeStubAssembler::Equal(Node* lhs, Node* rhs, Node* context,
BIND(&if_lhsisreceiver);
{
CSA_ASSERT(this, IsJSReceiverInstanceType(lhs_instance_type));
// Check if the {rhs} is also a JSReceiver.
Label if_rhsisreceiver(this), if_rhsisnotreceiver(this);
STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
@ -8632,6 +8649,12 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs,
// } else {
// return false;
// }
// } else if (lhs->IsBigInt()) {
// if (rhs->IsBigInt()) {
// return %BigIntEqual(lhs, rhs);
// } else {
// return false;
// }
// } else {
// return false;
// }
@ -8668,8 +8691,8 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs,
BIND(&if_notsame);
{
// The {lhs} and {rhs} reference different objects, yet for Smi, HeapNumber
// and String they can still be considered equal.
// The {lhs} and {rhs} reference different objects, yet for Smi, HeapNumber,
// BigInt and String they can still be considered equal.
if (var_type_feedback != nullptr) {
var_type_feedback->Bind(SmiConstant(CompareOperationFeedback::kAny));
@ -8787,6 +8810,38 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs,
}
BIND(&if_lhsisnotstring);
// Check if {lhs} is a BigInt.
Label if_lhsisbigint(this), if_lhsisnotbigint(this);
Branch(IsBigIntInstanceType(lhs_instance_type), &if_lhsisbigint,
&if_lhsisnotbigint);
BIND(&if_lhsisbigint);
{
// Check if {rhs} is also a BigInt.
Label if_rhsisbigint(this, Label::kDeferred),
if_rhsisnotbigint(this);
Branch(IsBigIntInstanceType(rhs_instance_type), &if_rhsisbigint,
&if_rhsisnotbigint);
BIND(&if_rhsisbigint);
{
if (var_type_feedback != nullptr) {
CSA_ASSERT(
this,
WordEqual(var_type_feedback->value(),
SmiConstant(CompareOperationFeedback::kAny)));
}
result.Bind(CallRuntime(Runtime::kBigIntEqual,
NoContextConstant(), lhs, rhs));
Goto(&end);
}
BIND(&if_rhsisnotbigint);
Goto(&if_notequal);
}
BIND(&if_lhsisnotbigint);
if (var_type_feedback != nullptr) {
Label if_lhsissymbol(this), if_lhsisreceiver(this);
GotoIf(IsJSReceiverInstanceType(lhs_instance_type),
@ -9117,7 +9172,7 @@ Node* CodeStubAssembler::Typeof(Node* value) {
Label return_number(this, Label::kDeferred), if_oddball(this),
return_function(this), return_undefined(this), return_object(this),
return_string(this), return_result(this);
return_string(this), return_bigint(this), return_result(this);
GotoIf(TaggedIsSmi(value), &return_number);
@ -9144,6 +9199,8 @@ Node* CodeStubAssembler::Typeof(Node* value) {
GotoIf(IsStringInstanceType(instance_type), &return_string);
GotoIf(IsBigIntInstanceType(instance_type), &return_bigint);
CSA_ASSERT(this, Word32Equal(instance_type, Int32Constant(SYMBOL_TYPE)));
result_var.Bind(HeapConstant(isolate()->factory()->symbol_string()));
Goto(&return_result);
@ -9185,6 +9242,12 @@ Node* CodeStubAssembler::Typeof(Node* value) {
Goto(&return_result);
}
BIND(&return_bigint);
{
result_var.Bind(HeapConstant(isolate()->factory()->bigint_string()));
Goto(&return_result);
}
BIND(&return_result);
return result_var.value();
}

View File

@ -936,6 +936,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* IsString(Node* object);
Node* IsSymbolInstanceType(Node* instance_type);
Node* IsSymbol(Node* object);
Node* IsBigIntInstanceType(Node* instance_type);
Node* IsBigInt(Node* object);
Node* IsUnseededNumberDictionary(Node* object);
Node* IsWeakCell(Node* object);
Node* IsUndetectableMap(Node* map);

View File

@ -276,6 +276,7 @@ Type::bitset BitsetType::Lub(i::Map* map) {
case MODULE_TYPE:
case MODULE_INFO_ENTRY_TYPE:
case CELL_TYPE:
case BIGINT_TYPE:
return kOtherInternal;
// Remaining instance types are unsupported for now. If any of them do

View File

@ -37,11 +37,13 @@ function Stringify(x, depth) {
case "boolean":
case "number":
case "function":
case "symbol":
return x.toString();
case "string":
return "\"" + x.toString() + "\"";
case "symbol":
return x.toString();
case "bigint":
// TODO(neis): Use x.toString() once we have it.
return String(x) + "n";
case "object":
if (IS_NULL(x)) return "null";
if (x.constructor && x.constructor.name === "Array") {

View File

@ -289,6 +289,9 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
V(StringTrim) \
V(SubString) \
V(RegExpInternalReplace) \
/* BigInts */ \
V(BigIntEqual) \
V(BigIntToBoolean) \
/* Literals */ \
V(CreateArrayLiteral) \
V(CreateObjectLiteral) \

View File

@ -3752,6 +3752,7 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
case SCRIPT_TYPE:
case CODE_TYPE:
case PROPERTY_CELL_TYPE:
case BIGINT_TYPE:
case MODULE_TYPE:
case MODULE_INFO_ENTRY_TYPE:
case FREE_SPACE_TYPE:

View File

@ -14,6 +14,7 @@
#include "src/conversions.h"
#include "src/isolate-inl.h"
#include "src/macro-assembler.h"
#include "src/objects/bigint-inl.h"
#include "src/objects/debug-objects-inl.h"
#include "src/objects/frame-array-inl.h"
#include "src/objects/module.h"
@ -1395,6 +1396,11 @@ Handle<HeapNumber> Factory::NewHeapNumber(MutableMode mode,
HeapNumber);
}
Handle<BigInt> Factory::NewBigInt(PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateBigInt(pretenure),
BigInt);
}
Handle<Object> Factory::NewError(Handle<JSFunction> constructor,
MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,

View File

@ -19,6 +19,7 @@ namespace v8 {
namespace internal {
class AliasedArgumentsEntry;
class BigInt;
class BreakPointInfo;
class BreakPoint;
class BoilerplateDescription;
@ -473,6 +474,8 @@ class V8_EXPORT_PRIVATE Factory final {
Handle<HeapNumber> NewHeapNumber(MutableMode mode,
PretenureFlag pretenure = NOT_TENURED);
Handle<BigInt> NewBigInt(PretenureFlag pretenure = NOT_TENURED);
Handle<JSWeakMap> NewJSWeakMap();
Handle<JSObject> NewArgumentsObject(Handle<JSFunction> callee, int length);

View File

@ -193,7 +193,8 @@ DEFINE_IMPLICATION(es_staging, harmony)
V(harmony_array_prototype_values, "harmony Array.prototype.values") \
V(harmony_function_sent, "harmony function.sent") \
V(harmony_do_expressions, "harmony do-expressions") \
V(harmony_class_fields, "harmony public fields in class literals")
V(harmony_class_fields, "harmony public fields in class literals") \
V(harmony_bigint, "harmony arbitrary precision integers")
#ifdef V8_INTL_SUPPORT
#define HARMONY_INPROGRESS(V) \

View File

@ -27,6 +27,7 @@
V(object_to_string, "[object Object]") \
V(regexp_to_string, "[object RegExp]") \
V(string_to_string, "[object String]") \
V(bigint_string, "bigint") \
V(bind_string, "bind") \
V(boolean_string, "boolean") \
V(Boolean_string, "Boolean") \

View File

@ -2468,6 +2468,19 @@ AllocationResult Heap::AllocateHeapNumber(MutableMode mode,
return result;
}
AllocationResult Heap::AllocateBigInt(PretenureFlag pretenure) {
STATIC_ASSERT(BigInt::kSize <= kMaxRegularHeapObjectSize);
HeapObject* result = nullptr;
{
AllocationSpace space = SelectSpace(pretenure);
AllocationResult allocation = AllocateRaw(BigInt::kSize, space);
if (!allocation.To(&result)) return allocation;
}
result->set_map_after_allocation(bigint_map(), SKIP_WRITE_BARRIER);
return result;
}
AllocationResult Heap::AllocateCell(Object* value) {
int size = Cell::kSize;
STATIC_ASSERT(Cell::kSize <= kMaxRegularHeapObjectSize);

View File

@ -111,6 +111,7 @@ using v8::MemoryPressureLevel;
V(Map, one_closure_cell_map, OneClosureCellMap) \
V(Map, many_closures_cell_map, ManyClosuresCellMap) \
V(Map, property_array_map, PropertyArrayMap) \
V(Map, bigint_map, BigIntMap) \
/* String maps */ \
V(Map, native_source_string_map, NativeSourceStringMap) \
V(Map, string_map, StringMap) \
@ -265,6 +266,7 @@ using v8::MemoryPressureLevel;
V(ArrayBufferNeuteringProtector) \
V(ArrayIteratorProtector) \
V(ArrayProtector) \
V(BigIntMap) \
V(BlockContextMap) \
V(BooleanMap) \
V(ByteArrayMap) \
@ -1980,6 +1982,8 @@ class Heap {
MUST_USE_RESULT AllocationResult AllocateHeapNumber(
MutableMode mode = IMMUTABLE, PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT AllocationResult AllocateBigInt(PretenureFlag pretenure);
// Allocates a byte array of the specified length
MUST_USE_RESULT AllocationResult
AllocateByteArray(int length, PretenureFlag pretenure = NOT_TENURED);

View File

@ -229,6 +229,7 @@ bool Heap::CreateInitialMaps() {
ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception);
ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, optimized_out);
ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, stale_register);
ALLOCATE_MAP(BIGINT_TYPE, BigInt::kSize, bigint);
for (unsigned i = 0; i < arraysize(string_type_table); i++) {
const StringTypeTable& entry = string_type_table[i];

View File

@ -522,6 +522,7 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) {
case FILLER_TYPE:
case BYTE_ARRAY_TYPE:
case FREE_SPACE_TYPE:
case BIGINT_TYPE:
return ReturnType();
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \

View File

@ -13,6 +13,7 @@
#include "src/layout-descriptor.h"
#include "src/macro-assembler.h"
#include "src/objects-inl.h"
#include "src/objects/bigint-inl.h"
#include "src/objects/debug-objects-inl.h"
#include "src/objects/literal-objects.h"
#include "src/objects/module.h"
@ -72,6 +73,9 @@ void HeapObject::HeapObjectVerify() {
case MUTABLE_HEAP_NUMBER_TYPE:
HeapNumber::cast(this)->HeapNumberVerify();
break;
case BIGINT_TYPE:
BigInt::cast(this)->BigIntVerify();
break;
case HASH_TABLE_TYPE:
case FIXED_ARRAY_TYPE:
FixedArray::cast(this)->FixedArrayVerify();
@ -1209,6 +1213,8 @@ void AsyncGeneratorRequest::AsyncGeneratorRequestVerify() {
next()->ObjectVerify();
}
void BigInt::BigIntVerify() { CHECK(IsBigInt()); }
void JSModuleNamespace::JSModuleNamespaceVerify() {
CHECK(IsJSModuleNamespace());
VerifyPointer(module());

View File

@ -33,6 +33,7 @@
#include "src/lookup.h"
#include "src/objects.h"
#include "src/objects/arguments-inl.h"
#include "src/objects/bigint-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/hash-table.h"
#include "src/objects/literal-objects.h"
@ -542,6 +543,7 @@ CAST_ACCESSOR(AllocationMemento)
CAST_ACCESSOR(AllocationSite)
CAST_ACCESSOR(ArrayList)
CAST_ACCESSOR(AsyncGeneratorRequest)
CAST_ACCESSOR(BigInt)
CAST_ACCESSOR(BoilerplateDescription)
CAST_ACCESSOR(ByteArray)
CAST_ACCESSOR(BytecodeArray)

View File

@ -255,6 +255,9 @@ MaybeHandle<String> Object::ConvertToString(Isolate* isolate,
THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kSymbolToString),
String);
}
if (input->IsBigInt()) {
return BigInt::ToString(Handle<BigInt>::cast(input));
}
ASSIGN_RETURN_ON_EXCEPTION(
isolate, input, JSReceiver::ToPrimitive(Handle<JSReceiver>::cast(input),
ToPrimitiveHint::kString),
@ -2306,8 +2309,6 @@ Map* Object::GetPrototypeChainRootMap(Isolate* isolate) const {
return native_context->number_function()->initial_map();
}
// The object is either a number, a string, a symbol, a boolean, a real JS
// object, or a Harmony proxy.
const HeapObject* heap_object = HeapObject::cast(this);
return heap_object->map()->GetPrototypeChainRootMap(isolate);
}
@ -2356,8 +2357,11 @@ Object* GetSimpleHash(Object* object) {
uint32_t hash = Oddball::cast(object)->to_string()->Hash();
return Smi::FromInt(hash);
}
if (object->IsBigInt()) {
uint32_t hash = ComputeIntegerHash(BigInt::cast(object)->value());
return Smi::FromInt(hash & Smi::kMaxValue);
}
DCHECK(object->IsJSReceiver());
// Simply return the receiver as it is guaranteed to not be a SMI.
return object;
}
@ -2408,6 +2412,9 @@ bool Object::SameValue(Object* other) {
if (IsString() && other->IsString()) {
return String::cast(this)->Equals(String::cast(other));
}
if (IsBigInt() && other->IsBigInt()) {
return BigInt::cast(this)->Equals(BigInt::cast(other));
}
return false;
}
@ -3161,6 +3168,7 @@ VisitorId Map::GetVisitorId(Map* map) {
case FOREIGN_TYPE:
case HEAP_NUMBER_TYPE:
case MUTABLE_HEAP_NUMBER_TYPE:
case BIGINT_TYPE:
return kVisitDataObject;
case FIXED_UINT8_ARRAY_TYPE:
@ -12923,6 +12931,7 @@ bool CanSubclassHaveInobjectProperties(InstanceType instance_type) {
case JS_WEAK_SET_TYPE:
return true;
case BIGINT_TYPE:
case BYTECODE_ARRAY_TYPE:
case BYTE_ARRAY_TYPE:
case CELL_TYPE:

View File

@ -126,6 +126,7 @@
// - ExternalTwoByteInternalizedString
// - Symbol
// - HeapNumber
// - BigInt
// - Cell
// - PropertyCell
// - PropertyArray
@ -324,6 +325,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
\
V(SYMBOL_TYPE) \
V(HEAP_NUMBER_TYPE) \
V(BIGINT_TYPE) \
V(ODDBALL_TYPE) \
\
V(MAP_TYPE) \
@ -673,6 +675,7 @@ enum InstanceType : uint8_t {
// Other primitives (cannot contain non-map-word pointers to heap objects).
HEAP_NUMBER_TYPE,
BIGINT_TYPE,
ODDBALL_TYPE, // LAST_PRIMITIVE_TYPE
// Objects allocated in their own spaces (never in new space).
@ -971,6 +974,7 @@ template <class C> inline bool Is(Object* obj);
V(AbstractCode) \
V(AccessCheckNeeded) \
V(ArrayList) \
V(BigInt) \
V(BoilerplateDescription) \
V(Boolean) \
V(BreakPoint) \

26
src/objects/bigint-inl.h Normal file
View File

@ -0,0 +1,26 @@
// Copyright 2017 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.
#ifndef V8_OBJECTS_BIGINT_INL_H_
#define V8_OBJECTS_BIGINT_INL_H_
#include "src/objects/bigint.h"
#include "src/objects.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
SMI_ACCESSORS(BigInt, value, kValueOffset)
TYPE_CHECKER(BigInt, BIGINT_TYPE)
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_BIGINT_INL_H_

33
src/objects/bigint.cc Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2017 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.
#include "src/objects/bigint.h"
#include "src/objects-inl.h"
namespace v8 {
namespace internal {
#ifdef OBJECT_PRINT
void BigInt::BigIntPrint(std::ostream& os) {
DisallowHeapAllocation no_gc;
HeapObject::PrintHeader(os, "BigInt");
os << "- value: " << value();
os << "\n";
}
#endif // OBJECT_PRINT
bool BigInt::Equals(BigInt* other) const {
DisallowHeapAllocation no_gc;
return value() == other->value();
}
Handle<String> BigInt::ToString(Handle<BigInt> bigint) {
Isolate* isolate = bigint->GetIsolate();
Handle<Object> number = isolate->factory()->NewNumberFromInt(bigint->value());
return isolate->factory()->NumberToString(number);
}
} // namespace internal
} // namespace v8

43
src/objects/bigint.h Normal file
View File

@ -0,0 +1,43 @@
// Copyright 2017 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.
#ifndef V8_OBJECTS_BIGINT_H_
#define V8_OBJECTS_BIGINT_H_
#include "src/globals.h"
#include "src/objects.h"
#include "src/utils.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
// UNDER CONSTRUCTION!
// Arbitrary precision integers in JavaScript.
class BigInt : public HeapObject {
public:
DECL_CAST(BigInt)
DECL_VERIFIER(BigInt)
DECL_PRINTER(BigInt)
DECL_INT_ACCESSORS(value)
static const int kValueOffset = HeapObject::kHeaderSize;
static const int kSize = kValueOffset + kPointerSize;
bool Equals(BigInt* other) const;
static Handle<String> ToString(Handle<BigInt> bigint);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BigInt);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_BIGINT_H_

View File

@ -0,0 +1,52 @@
// Copyright 2017 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.
#include "src/runtime/runtime-utils.h"
#include "src/arguments.h"
#include "src/counters.h"
#include "src/objects-inl.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_BigInt) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_SMI_ARG_CHECKED(value, 0);
// For the moment, this is the only way to create a BigInt.
// Since we currently don't want ClusterFuzz to generate BigInts, we always
// throw here if the --harmony-bigint flag is disabled. (All --harmony-* flags
// are blacklisted for ClusterFuzz.)
if (!FLAG_harmony_bigint) {
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
NewTypeError(MessageTemplate::kUnsupported));
}
Handle<BigInt> result = isolate->factory()->NewBigInt();
result->set_value(value);
return *result;
}
RUNTIME_FUNCTION(Runtime_BigIntEqual) {
SealHandleScope shs(isolate);
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
bool result = lhs->IsBigInt() && rhs->IsBigInt() &&
BigInt::cast(*lhs)->Equals(BigInt::cast(*rhs));
return *isolate->factory()->ToBoolean(result);
}
RUNTIME_FUNCTION(Runtime_BigIntToBoolean) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(BigInt, bigint, 0);
return *isolate->factory()->ToBoolean(bigint->value());
}
} // namespace internal
} // namespace v8

View File

@ -68,6 +68,11 @@ namespace internal {
F(AtomicsNumWaitersForTesting, 2, 1) \
F(SetAllowAtomicsWait, 1, 1)
#define FOR_EACH_INTRINSIC_BIGINT(F) \
F(BigInt, 1, 1) \
F(BigIntEqual, 2, 1) \
F(BigIntToBoolean, 1, 1)
#define FOR_EACH_INTRINSIC_CLASSES(F) \
F(ThrowUnsupportedSuperError, 0, 1) \
F(ThrowConstructorNonCallableError, 1, 1) \
@ -673,6 +678,7 @@ namespace internal {
FOR_EACH_INTRINSIC_IC(F) \
FOR_EACH_INTRINSIC_ARRAY(F) \
FOR_EACH_INTRINSIC_ATOMICS(F) \
FOR_EACH_INTRINSIC_BIGINT(F) \
FOR_EACH_INTRINSIC_CLASSES(F) \
FOR_EACH_INTRINSIC_COLLECTIONS(F) \
FOR_EACH_INTRINSIC_COMPILER(F) \

View File

@ -1160,6 +1160,9 @@
'objects.h',
'objects/arguments-inl.h',
'objects/arguments.h',
'objects/bigint-inl.h',
'objects/bigint.cc',
'objects/bigint.h',
'objects/code-cache.h',
'objects/code-cache-inl.h',
'objects/compilation-cache.h',
@ -1292,6 +1295,7 @@
'runtime-profiler.h',
'runtime/runtime-array.cc',
'runtime/runtime-atomics.cc',
'runtime/runtime-bigint.cc',
'runtime/runtime-classes.cc',
'runtime/runtime-collections.cc',
'runtime/runtime-compiler.cc',

View File

@ -0,0 +1,115 @@
// Copyright 2017 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.
// Flags: --allow-natives-syntax --harmony-bigint --no-opt
'use strict'
const zero = %BigInt(0);
const another_zero = %BigInt(0);
const one = %BigInt(1);
const another_one = %BigInt(1);
// typeof
{
assertEquals(typeof zero, "bigint");
assertEquals(typeof one, "bigint");
}
{
// TODO(neis): Enable once --no-opt can be removed.
//
// function Typeof(x) { return typeof x }
// assertEquals(Typeof(zero), "bigint");
// assertEquals(Typeof(zero), "bigint");
// %OptimizeFunctionOnNextCall(Typeof);
// assertEquals(Typeof(zero), "bigint");
}
// ToString
{
assertEquals(String(zero), "0");
assertEquals(String(one), "1");
}
// ToBoolean
{
assertTrue(!zero);
assertFalse(!!zero);
assertTrue(!!!zero);
assertFalse(!one);
assertTrue(!!one);
assertFalse(!!!one);
}
// Strict equality
{
assertTrue(zero === zero);
assertFalse(zero !== zero);
assertTrue(zero === another_zero);
assertFalse(zero !== another_zero);
assertFalse(zero === one);
assertTrue(zero !== one);
assertTrue(one !== zero);
assertFalse(one === zero);
assertFalse(zero === 0);
assertTrue(zero !== 0);
assertFalse(0 === zero);
assertTrue(0 !== zero);
}
// SameValue
{
const obj = Object.defineProperty({}, 'foo',
{value: zero, writable: false, configurable: false});
assertTrue(Reflect.defineProperty(obj, 'foo', {value: zero}));
assertTrue(Reflect.defineProperty(obj, 'foo', {value: another_zero}));
assertFalse(Reflect.defineProperty(obj, 'foo', {value: one}));
}
// SameValueZero
{
assertTrue([zero].includes(zero));
assertTrue([zero].includes(another_zero));
assertFalse([zero].includes(+0));
assertFalse([zero].includes(-0));
assertFalse([+0].includes(zero));
assertFalse([-0].includes(zero));
assertTrue([one].includes(one));
assertTrue([one].includes(another_one));
assertFalse([one].includes(1));
assertFalse([1].includes(one));
}{
assertTrue(new Set([zero]).has(zero));
assertTrue(new Set([zero]).has(another_zero));
assertFalse(new Set([zero]).has(+0));
assertFalse(new Set([zero]).has(-0));
assertFalse(new Set([+0]).has(zero));
assertFalse(new Set([-0]).has(zero));
assertTrue(new Set([one]).has(one));
assertTrue(new Set([one]).has(another_one));
}{
assertTrue(new Map([[zero, 42]]).has(zero));
assertTrue(new Map([[zero, 42]]).has(another_zero));
assertFalse(new Map([[zero, 42]]).has(+0));
assertFalse(new Map([[zero, 42]]).has(-0));
assertFalse(new Map([[+0, 42]]).has(zero));
assertFalse(new Map([[-0, 42]]).has(zero));
assertTrue(new Map([[one, 42]]).has(one));
assertTrue(new Map([[one, 42]]).has(another_one));
}

View File

@ -31,243 +31,245 @@ INSTANCE_TYPES = {
114: "SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE",
128: "SYMBOL_TYPE",
129: "HEAP_NUMBER_TYPE",
130: "ODDBALL_TYPE",
131: "MAP_TYPE",
132: "CODE_TYPE",
133: "MUTABLE_HEAP_NUMBER_TYPE",
134: "FOREIGN_TYPE",
135: "BYTE_ARRAY_TYPE",
136: "BYTECODE_ARRAY_TYPE",
137: "FREE_SPACE_TYPE",
138: "FIXED_INT8_ARRAY_TYPE",
139: "FIXED_UINT8_ARRAY_TYPE",
140: "FIXED_INT16_ARRAY_TYPE",
141: "FIXED_UINT16_ARRAY_TYPE",
142: "FIXED_INT32_ARRAY_TYPE",
143: "FIXED_UINT32_ARRAY_TYPE",
144: "FIXED_FLOAT32_ARRAY_TYPE",
145: "FIXED_FLOAT64_ARRAY_TYPE",
146: "FIXED_UINT8_CLAMPED_ARRAY_TYPE",
147: "FIXED_DOUBLE_ARRAY_TYPE",
148: "FILLER_TYPE",
149: "ACCESSOR_INFO_TYPE",
150: "ACCESSOR_PAIR_TYPE",
151: "ACCESS_CHECK_INFO_TYPE",
152: "INTERCEPTOR_INFO_TYPE",
153: "FUNCTION_TEMPLATE_INFO_TYPE",
154: "OBJECT_TEMPLATE_INFO_TYPE",
155: "ALLOCATION_SITE_TYPE",
156: "ALLOCATION_MEMENTO_TYPE",
157: "SCRIPT_TYPE",
158: "ALIASED_ARGUMENTS_ENTRY_TYPE",
159: "PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE",
160: "PROMISE_REACTION_JOB_INFO_TYPE",
161: "PROMISE_CAPABILITY_TYPE",
162: "DEBUG_INFO_TYPE",
163: "STACK_FRAME_INFO_TYPE",
164: "PROTOTYPE_INFO_TYPE",
165: "TUPLE2_TYPE",
166: "TUPLE3_TYPE",
167: "CONTEXT_EXTENSION_TYPE",
168: "MODULE_TYPE",
169: "MODULE_INFO_ENTRY_TYPE",
170: "ASYNC_GENERATOR_REQUEST_TYPE",
171: "FIXED_ARRAY_TYPE",
172: "HASH_TABLE_TYPE",
173: "FEEDBACK_VECTOR_TYPE",
174: "TRANSITION_ARRAY_TYPE",
175: "PROPERTY_ARRAY_TYPE",
176: "SHARED_FUNCTION_INFO_TYPE",
177: "CELL_TYPE",
178: "WEAK_CELL_TYPE",
179: "PROPERTY_CELL_TYPE",
180: "SMALL_ORDERED_HASH_MAP_TYPE",
181: "SMALL_ORDERED_HASH_SET_TYPE",
182: "JS_PROXY_TYPE",
183: "JS_GLOBAL_OBJECT_TYPE",
184: "JS_GLOBAL_PROXY_TYPE",
185: "JS_MODULE_NAMESPACE_TYPE",
186: "JS_SPECIAL_API_OBJECT_TYPE",
187: "JS_VALUE_TYPE",
188: "JS_MESSAGE_OBJECT_TYPE",
189: "JS_DATE_TYPE",
190: "JS_API_OBJECT_TYPE",
191: "JS_OBJECT_TYPE",
192: "JS_ARGUMENTS_TYPE",
193: "JS_CONTEXT_EXTENSION_OBJECT_TYPE",
194: "JS_GENERATOR_OBJECT_TYPE",
195: "JS_ASYNC_GENERATOR_OBJECT_TYPE",
196: "JS_ARRAY_TYPE",
197: "JS_ARRAY_BUFFER_TYPE",
198: "JS_TYPED_ARRAY_TYPE",
199: "JS_DATA_VIEW_TYPE",
200: "JS_SET_TYPE",
201: "JS_MAP_TYPE",
202: "JS_SET_KEY_VALUE_ITERATOR_TYPE",
203: "JS_SET_VALUE_ITERATOR_TYPE",
204: "JS_MAP_KEY_ITERATOR_TYPE",
205: "JS_MAP_KEY_VALUE_ITERATOR_TYPE",
206: "JS_MAP_VALUE_ITERATOR_TYPE",
207: "JS_WEAK_MAP_TYPE",
208: "JS_WEAK_SET_TYPE",
209: "JS_PROMISE_TYPE",
210: "JS_REGEXP_TYPE",
211: "JS_ERROR_TYPE",
212: "JS_ASYNC_FROM_SYNC_ITERATOR_TYPE",
213: "JS_STRING_ITERATOR_TYPE",
214: "JS_TYPED_ARRAY_KEY_ITERATOR_TYPE",
215: "JS_FAST_ARRAY_KEY_ITERATOR_TYPE",
216: "JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE",
217: "JS_UINT8_ARRAY_KEY_VALUE_ITERATOR_TYPE",
218: "JS_INT8_ARRAY_KEY_VALUE_ITERATOR_TYPE",
219: "JS_UINT16_ARRAY_KEY_VALUE_ITERATOR_TYPE",
220: "JS_INT16_ARRAY_KEY_VALUE_ITERATOR_TYPE",
221: "JS_UINT32_ARRAY_KEY_VALUE_ITERATOR_TYPE",
222: "JS_INT32_ARRAY_KEY_VALUE_ITERATOR_TYPE",
223: "JS_FLOAT32_ARRAY_KEY_VALUE_ITERATOR_TYPE",
224: "JS_FLOAT64_ARRAY_KEY_VALUE_ITERATOR_TYPE",
225: "JS_UINT8_CLAMPED_ARRAY_KEY_VALUE_ITERATOR_TYPE",
226: "JS_FAST_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE",
227: "JS_FAST_HOLEY_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE",
228: "JS_FAST_ARRAY_KEY_VALUE_ITERATOR_TYPE",
229: "JS_FAST_HOLEY_ARRAY_KEY_VALUE_ITERATOR_TYPE",
230: "JS_FAST_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE",
231: "JS_FAST_HOLEY_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE",
232: "JS_GENERIC_ARRAY_KEY_VALUE_ITERATOR_TYPE",
233: "JS_UINT8_ARRAY_VALUE_ITERATOR_TYPE",
234: "JS_INT8_ARRAY_VALUE_ITERATOR_TYPE",
235: "JS_UINT16_ARRAY_VALUE_ITERATOR_TYPE",
236: "JS_INT16_ARRAY_VALUE_ITERATOR_TYPE",
237: "JS_UINT32_ARRAY_VALUE_ITERATOR_TYPE",
238: "JS_INT32_ARRAY_VALUE_ITERATOR_TYPE",
239: "JS_FLOAT32_ARRAY_VALUE_ITERATOR_TYPE",
240: "JS_FLOAT64_ARRAY_VALUE_ITERATOR_TYPE",
241: "JS_UINT8_CLAMPED_ARRAY_VALUE_ITERATOR_TYPE",
242: "JS_FAST_SMI_ARRAY_VALUE_ITERATOR_TYPE",
243: "JS_FAST_HOLEY_SMI_ARRAY_VALUE_ITERATOR_TYPE",
244: "JS_FAST_ARRAY_VALUE_ITERATOR_TYPE",
245: "JS_FAST_HOLEY_ARRAY_VALUE_ITERATOR_TYPE",
246: "JS_FAST_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE",
247: "JS_FAST_HOLEY_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE",
248: "JS_GENERIC_ARRAY_VALUE_ITERATOR_TYPE",
249: "WASM_INSTANCE_TYPE",
250: "WASM_MEMORY_TYPE",
251: "WASM_MODULE_TYPE",
252: "WASM_TABLE_TYPE",
253: "JS_BOUND_FUNCTION_TYPE",
254: "JS_FUNCTION_TYPE",
130: "BIGINT_TYPE",
131: "ODDBALL_TYPE",
132: "MAP_TYPE",
133: "CODE_TYPE",
134: "MUTABLE_HEAP_NUMBER_TYPE",
135: "FOREIGN_TYPE",
136: "BYTE_ARRAY_TYPE",
137: "BYTECODE_ARRAY_TYPE",
138: "FREE_SPACE_TYPE",
139: "FIXED_INT8_ARRAY_TYPE",
140: "FIXED_UINT8_ARRAY_TYPE",
141: "FIXED_INT16_ARRAY_TYPE",
142: "FIXED_UINT16_ARRAY_TYPE",
143: "FIXED_INT32_ARRAY_TYPE",
144: "FIXED_UINT32_ARRAY_TYPE",
145: "FIXED_FLOAT32_ARRAY_TYPE",
146: "FIXED_FLOAT64_ARRAY_TYPE",
147: "FIXED_UINT8_CLAMPED_ARRAY_TYPE",
148: "FIXED_DOUBLE_ARRAY_TYPE",
149: "FILLER_TYPE",
150: "ACCESSOR_INFO_TYPE",
151: "ACCESSOR_PAIR_TYPE",
152: "ACCESS_CHECK_INFO_TYPE",
153: "INTERCEPTOR_INFO_TYPE",
154: "FUNCTION_TEMPLATE_INFO_TYPE",
155: "OBJECT_TEMPLATE_INFO_TYPE",
156: "ALLOCATION_SITE_TYPE",
157: "ALLOCATION_MEMENTO_TYPE",
158: "SCRIPT_TYPE",
159: "ALIASED_ARGUMENTS_ENTRY_TYPE",
160: "PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE",
161: "PROMISE_REACTION_JOB_INFO_TYPE",
162: "PROMISE_CAPABILITY_TYPE",
163: "DEBUG_INFO_TYPE",
164: "STACK_FRAME_INFO_TYPE",
165: "PROTOTYPE_INFO_TYPE",
166: "TUPLE2_TYPE",
167: "TUPLE3_TYPE",
168: "CONTEXT_EXTENSION_TYPE",
169: "MODULE_TYPE",
170: "MODULE_INFO_ENTRY_TYPE",
171: "ASYNC_GENERATOR_REQUEST_TYPE",
172: "FIXED_ARRAY_TYPE",
173: "HASH_TABLE_TYPE",
174: "FEEDBACK_VECTOR_TYPE",
175: "TRANSITION_ARRAY_TYPE",
176: "PROPERTY_ARRAY_TYPE",
177: "SHARED_FUNCTION_INFO_TYPE",
178: "CELL_TYPE",
179: "WEAK_CELL_TYPE",
180: "PROPERTY_CELL_TYPE",
181: "SMALL_ORDERED_HASH_MAP_TYPE",
182: "SMALL_ORDERED_HASH_SET_TYPE",
183: "JS_PROXY_TYPE",
184: "JS_GLOBAL_OBJECT_TYPE",
185: "JS_GLOBAL_PROXY_TYPE",
186: "JS_MODULE_NAMESPACE_TYPE",
187: "JS_SPECIAL_API_OBJECT_TYPE",
188: "JS_VALUE_TYPE",
189: "JS_MESSAGE_OBJECT_TYPE",
190: "JS_DATE_TYPE",
191: "JS_API_OBJECT_TYPE",
192: "JS_OBJECT_TYPE",
193: "JS_ARGUMENTS_TYPE",
194: "JS_CONTEXT_EXTENSION_OBJECT_TYPE",
195: "JS_GENERATOR_OBJECT_TYPE",
196: "JS_ASYNC_GENERATOR_OBJECT_TYPE",
197: "JS_ARRAY_TYPE",
198: "JS_ARRAY_BUFFER_TYPE",
199: "JS_TYPED_ARRAY_TYPE",
200: "JS_DATA_VIEW_TYPE",
201: "JS_SET_TYPE",
202: "JS_MAP_TYPE",
203: "JS_SET_KEY_VALUE_ITERATOR_TYPE",
204: "JS_SET_VALUE_ITERATOR_TYPE",
205: "JS_MAP_KEY_ITERATOR_TYPE",
206: "JS_MAP_KEY_VALUE_ITERATOR_TYPE",
207: "JS_MAP_VALUE_ITERATOR_TYPE",
208: "JS_WEAK_MAP_TYPE",
209: "JS_WEAK_SET_TYPE",
210: "JS_PROMISE_TYPE",
211: "JS_REGEXP_TYPE",
212: "JS_ERROR_TYPE",
213: "JS_ASYNC_FROM_SYNC_ITERATOR_TYPE",
214: "JS_STRING_ITERATOR_TYPE",
215: "JS_TYPED_ARRAY_KEY_ITERATOR_TYPE",
216: "JS_FAST_ARRAY_KEY_ITERATOR_TYPE",
217: "JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE",
218: "JS_UINT8_ARRAY_KEY_VALUE_ITERATOR_TYPE",
219: "JS_INT8_ARRAY_KEY_VALUE_ITERATOR_TYPE",
220: "JS_UINT16_ARRAY_KEY_VALUE_ITERATOR_TYPE",
221: "JS_INT16_ARRAY_KEY_VALUE_ITERATOR_TYPE",
222: "JS_UINT32_ARRAY_KEY_VALUE_ITERATOR_TYPE",
223: "JS_INT32_ARRAY_KEY_VALUE_ITERATOR_TYPE",
224: "JS_FLOAT32_ARRAY_KEY_VALUE_ITERATOR_TYPE",
225: "JS_FLOAT64_ARRAY_KEY_VALUE_ITERATOR_TYPE",
226: "JS_UINT8_CLAMPED_ARRAY_KEY_VALUE_ITERATOR_TYPE",
227: "JS_FAST_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE",
228: "JS_FAST_HOLEY_SMI_ARRAY_KEY_VALUE_ITERATOR_TYPE",
229: "JS_FAST_ARRAY_KEY_VALUE_ITERATOR_TYPE",
230: "JS_FAST_HOLEY_ARRAY_KEY_VALUE_ITERATOR_TYPE",
231: "JS_FAST_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE",
232: "JS_FAST_HOLEY_DOUBLE_ARRAY_KEY_VALUE_ITERATOR_TYPE",
233: "JS_GENERIC_ARRAY_KEY_VALUE_ITERATOR_TYPE",
234: "JS_UINT8_ARRAY_VALUE_ITERATOR_TYPE",
235: "JS_INT8_ARRAY_VALUE_ITERATOR_TYPE",
236: "JS_UINT16_ARRAY_VALUE_ITERATOR_TYPE",
237: "JS_INT16_ARRAY_VALUE_ITERATOR_TYPE",
238: "JS_UINT32_ARRAY_VALUE_ITERATOR_TYPE",
239: "JS_INT32_ARRAY_VALUE_ITERATOR_TYPE",
240: "JS_FLOAT32_ARRAY_VALUE_ITERATOR_TYPE",
241: "JS_FLOAT64_ARRAY_VALUE_ITERATOR_TYPE",
242: "JS_UINT8_CLAMPED_ARRAY_VALUE_ITERATOR_TYPE",
243: "JS_FAST_SMI_ARRAY_VALUE_ITERATOR_TYPE",
244: "JS_FAST_HOLEY_SMI_ARRAY_VALUE_ITERATOR_TYPE",
245: "JS_FAST_ARRAY_VALUE_ITERATOR_TYPE",
246: "JS_FAST_HOLEY_ARRAY_VALUE_ITERATOR_TYPE",
247: "JS_FAST_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE",
248: "JS_FAST_HOLEY_DOUBLE_ARRAY_VALUE_ITERATOR_TYPE",
249: "JS_GENERIC_ARRAY_VALUE_ITERATOR_TYPE",
250: "WASM_INSTANCE_TYPE",
251: "WASM_MEMORY_TYPE",
252: "WASM_MODULE_TYPE",
253: "WASM_TABLE_TYPE",
254: "JS_BOUND_FUNCTION_TYPE",
255: "JS_FUNCTION_TYPE",
}
# List of known V8 maps.
KNOWN_MAPS = {
0x02201: (137, "FreeSpaceMap"),
0x02259: (131, "MetaMap"),
0x022b1: (130, "NullMap"),
0x02309: (171, "FixedArrayMap"),
0x02361: (148, "OnePointerFillerMap"),
0x023b9: (148, "TwoPointerFillerMap"),
0x02411: (130, "UninitializedMap"),
0x02201: (138, "FreeSpaceMap"),
0x02259: (132, "MetaMap"),
0x022b1: (131, "NullMap"),
0x02309: (172, "FixedArrayMap"),
0x02361: (149, "OnePointerFillerMap"),
0x023b9: (149, "TwoPointerFillerMap"),
0x02411: (131, "UninitializedMap"),
0x02469: (8, "OneByteInternalizedStringMap"),
0x024c1: (130, "UndefinedMap"),
0x024c1: (131, "UndefinedMap"),
0x02519: (129, "HeapNumberMap"),
0x02571: (130, "TheHoleMap"),
0x025c9: (130, "BooleanMap"),
0x02621: (135, "ByteArrayMap"),
0x02679: (171, "FixedCOWArrayMap"),
0x026d1: (172, "HashTableMap"),
0x02571: (131, "TheHoleMap"),
0x025c9: (131, "BooleanMap"),
0x02621: (136, "ByteArrayMap"),
0x02679: (172, "FixedCOWArrayMap"),
0x026d1: (173, "HashTableMap"),
0x02729: (128, "SymbolMap"),
0x02781: (72, "OneByteStringMap"),
0x027d9: (171, "ScopeInfoMap"),
0x02831: (176, "SharedFunctionInfoMap"),
0x02889: (132, "CodeMap"),
0x028e1: (171, "FunctionContextMap"),
0x02939: (177, "CellMap"),
0x02991: (178, "WeakCellMap"),
0x029e9: (179, "GlobalPropertyCellMap"),
0x02a41: (134, "ForeignMap"),
0x02a99: (174, "TransitionArrayMap"),
0x02af1: (130, "ArgumentsMarkerMap"),
0x02b49: (130, "ExceptionMap"),
0x02ba1: (130, "TerminationExceptionMap"),
0x02bf9: (130, "OptimizedOutMap"),
0x02c51: (130, "StaleRegisterMap"),
0x02ca9: (171, "NativeContextMap"),
0x02d01: (171, "ModuleContextMap"),
0x02d59: (171, "EvalContextMap"),
0x02db1: (171, "ScriptContextMap"),
0x02e09: (171, "BlockContextMap"),
0x02e61: (171, "CatchContextMap"),
0x02eb9: (171, "WithContextMap"),
0x02f11: (147, "FixedDoubleArrayMap"),
0x02f69: (133, "MutableHeapNumberMap"),
0x02fc1: (172, "OrderedHashTableMap"),
0x03019: (171, "SloppyArgumentsElementsMap"),
0x03071: (180, "SmallOrderedHashMapMap"),
0x030c9: (181, "SmallOrderedHashSetMap"),
0x03121: (188, "JSMessageObjectMap"),
0x03179: (136, "BytecodeArrayMap"),
0x031d1: (171, "ModuleInfoMap"),
0x03229: (177, "NoClosuresCellMap"),
0x03281: (177, "OneClosureCellMap"),
0x032d9: (177, "ManyClosuresCellMap"),
0x03331: (175, "PropertyArrayMap"),
0x03389: (64, "StringMap"),
0x033e1: (73, "ConsOneByteStringMap"),
0x03439: (65, "ConsStringMap"),
0x03491: (77, "ThinOneByteStringMap"),
0x034e9: (69, "ThinStringMap"),
0x03541: (67, "SlicedStringMap"),
0x03599: (75, "SlicedOneByteStringMap"),
0x035f1: (66, "ExternalStringMap"),
0x03649: (82, "ExternalStringWithOneByteDataMap"),
0x036a1: (74, "ExternalOneByteStringMap"),
0x036f9: (98, "ShortExternalStringMap"),
0x03751: (114, "ShortExternalStringWithOneByteDataMap"),
0x037a9: (0, "InternalizedStringMap"),
0x03801: (2, "ExternalInternalizedStringMap"),
0x03859: (18, "ExternalInternalizedStringWithOneByteDataMap"),
0x038b1: (10, "ExternalOneByteInternalizedStringMap"),
0x03909: (34, "ShortExternalInternalizedStringMap"),
0x03961: (50, "ShortExternalInternalizedStringWithOneByteDataMap"),
0x039b9: (42, "ShortExternalOneByteInternalizedStringMap"),
0x03a11: (106, "ShortExternalOneByteStringMap"),
0x03a69: (139, "FixedUint8ArrayMap"),
0x03ac1: (138, "FixedInt8ArrayMap"),
0x03b19: (141, "FixedUint16ArrayMap"),
0x03b71: (140, "FixedInt16ArrayMap"),
0x03bc9: (143, "FixedUint32ArrayMap"),
0x03c21: (142, "FixedInt32ArrayMap"),
0x03c79: (144, "FixedFloat32ArrayMap"),
0x03cd1: (145, "FixedFloat64ArrayMap"),
0x03d29: (146, "FixedUint8ClampedArrayMap"),
0x03d81: (157, "ScriptMap"),
0x03dd9: (173, "FeedbackVectorMap"),
0x03e31: (171, "DebugEvaluateContextMap"),
0x03e89: (171, "ScriptContextTableMap"),
0x03ee1: (172, "UnseededNumberDictionaryMap"),
0x03f39: (191, "ExternalMap"),
0x03f91: (106, "NativeSourceStringMap"),
0x03fe9: (165, "Tuple2Map"),
0x04041: (152, "InterceptorInfoMap"),
0x04099: (149, "AccessorInfoMap"),
0x040f1: (150, "AccessorPairMap"),
0x04149: (151, "AccessCheckInfoMap"),
0x041a1: (153, "FunctionTemplateInfoMap"),
0x041f9: (154, "ObjectTemplateInfoMap"),
0x04251: (155, "AllocationSiteMap"),
0x042a9: (156, "AllocationMementoMap"),
0x04301: (158, "AliasedArgumentsEntryMap"),
0x04359: (159, "PromiseResolveThenableJobInfoMap"),
0x043b1: (160, "PromiseReactionJobInfoMap"),
0x04409: (161, "PromiseCapabilityMap"),
0x04461: (162, "DebugInfoMap"),
0x044b9: (163, "StackFrameInfoMap"),
0x04511: (164, "PrototypeInfoMap"),
0x04569: (166, "Tuple3Map"),
0x045c1: (167, "ContextExtensionMap"),
0x04619: (168, "ModuleMap"),
0x04671: (169, "ModuleInfoEntryMap"),
0x046c9: (170, "AsyncGeneratorRequestMap"),
0x027d9: (172, "ScopeInfoMap"),
0x02831: (177, "SharedFunctionInfoMap"),
0x02889: (133, "CodeMap"),
0x028e1: (172, "FunctionContextMap"),
0x02939: (178, "CellMap"),
0x02991: (179, "WeakCellMap"),
0x029e9: (180, "GlobalPropertyCellMap"),
0x02a41: (135, "ForeignMap"),
0x02a99: (175, "TransitionArrayMap"),
0x02af1: (131, "ArgumentsMarkerMap"),
0x02b49: (131, "ExceptionMap"),
0x02ba1: (131, "TerminationExceptionMap"),
0x02bf9: (131, "OptimizedOutMap"),
0x02c51: (131, "StaleRegisterMap"),
0x02ca9: (172, "NativeContextMap"),
0x02d01: (172, "ModuleContextMap"),
0x02d59: (172, "EvalContextMap"),
0x02db1: (172, "ScriptContextMap"),
0x02e09: (172, "BlockContextMap"),
0x02e61: (172, "CatchContextMap"),
0x02eb9: (172, "WithContextMap"),
0x02f11: (148, "FixedDoubleArrayMap"),
0x02f69: (134, "MutableHeapNumberMap"),
0x02fc1: (173, "OrderedHashTableMap"),
0x03019: (172, "SloppyArgumentsElementsMap"),
0x03071: (181, "SmallOrderedHashMapMap"),
0x030c9: (182, "SmallOrderedHashSetMap"),
0x03121: (189, "JSMessageObjectMap"),
0x03179: (137, "BytecodeArrayMap"),
0x031d1: (172, "ModuleInfoMap"),
0x03229: (178, "NoClosuresCellMap"),
0x03281: (178, "OneClosureCellMap"),
0x032d9: (178, "ManyClosuresCellMap"),
0x03331: (176, "PropertyArrayMap"),
0x03389: (130, "BigIntMap"),
0x033e1: (64, "StringMap"),
0x03439: (73, "ConsOneByteStringMap"),
0x03491: (65, "ConsStringMap"),
0x034e9: (77, "ThinOneByteStringMap"),
0x03541: (69, "ThinStringMap"),
0x03599: (67, "SlicedStringMap"),
0x035f1: (75, "SlicedOneByteStringMap"),
0x03649: (66, "ExternalStringMap"),
0x036a1: (82, "ExternalStringWithOneByteDataMap"),
0x036f9: (74, "ExternalOneByteStringMap"),
0x03751: (98, "ShortExternalStringMap"),
0x037a9: (114, "ShortExternalStringWithOneByteDataMap"),
0x03801: (0, "InternalizedStringMap"),
0x03859: (2, "ExternalInternalizedStringMap"),
0x038b1: (18, "ExternalInternalizedStringWithOneByteDataMap"),
0x03909: (10, "ExternalOneByteInternalizedStringMap"),
0x03961: (34, "ShortExternalInternalizedStringMap"),
0x039b9: (50, "ShortExternalInternalizedStringWithOneByteDataMap"),
0x03a11: (42, "ShortExternalOneByteInternalizedStringMap"),
0x03a69: (106, "ShortExternalOneByteStringMap"),
0x03ac1: (140, "FixedUint8ArrayMap"),
0x03b19: (139, "FixedInt8ArrayMap"),
0x03b71: (142, "FixedUint16ArrayMap"),
0x03bc9: (141, "FixedInt16ArrayMap"),
0x03c21: (144, "FixedUint32ArrayMap"),
0x03c79: (143, "FixedInt32ArrayMap"),
0x03cd1: (145, "FixedFloat32ArrayMap"),
0x03d29: (146, "FixedFloat64ArrayMap"),
0x03d81: (147, "FixedUint8ClampedArrayMap"),
0x03dd9: (158, "ScriptMap"),
0x03e31: (174, "FeedbackVectorMap"),
0x03e89: (172, "DebugEvaluateContextMap"),
0x03ee1: (172, "ScriptContextTableMap"),
0x03f39: (173, "UnseededNumberDictionaryMap"),
0x03f91: (192, "ExternalMap"),
0x03fe9: (106, "NativeSourceStringMap"),
0x04041: (166, "Tuple2Map"),
0x04099: (153, "InterceptorInfoMap"),
0x040f1: (150, "AccessorInfoMap"),
0x04149: (151, "AccessorPairMap"),
0x041a1: (152, "AccessCheckInfoMap"),
0x041f9: (154, "FunctionTemplateInfoMap"),
0x04251: (155, "ObjectTemplateInfoMap"),
0x042a9: (156, "AllocationSiteMap"),
0x04301: (157, "AllocationMementoMap"),
0x04359: (159, "AliasedArgumentsEntryMap"),
0x043b1: (160, "PromiseResolveThenableJobInfoMap"),
0x04409: (161, "PromiseReactionJobInfoMap"),
0x04461: (162, "PromiseCapabilityMap"),
0x044b9: (163, "DebugInfoMap"),
0x04511: (164, "StackFrameInfoMap"),
0x04569: (165, "PrototypeInfoMap"),
0x045c1: (167, "Tuple3Map"),
0x04619: (168, "ContextExtensionMap"),
0x04671: (169, "ModuleMap"),
0x046c9: (170, "ModuleInfoEntryMap"),
0x04721: (171, "AsyncGeneratorRequestMap"),
}
# List of known V8 objects.