Commit a2dfb40e authored by Z Duong Nguyen-Huu's avatar Z Duong Nguyen-Huu Committed by Commit Bot

Torquefy HeapNumber, FreeSpace

Bug: v8:8952
Change-Id: I74eaa1148116dfc8d6720e8be4f59ce90c8df164
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1524664Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#60496}
parent 93716b9e
......@@ -10,6 +10,7 @@
#include 'src/objects.h'
#include 'src/objects/arguments.h'
#include 'src/objects/bigint.h'
#include 'src/objects/free-space.h'
#include 'src/objects/js-generator.h'
#include 'src/objects/js-promise.h'
#include 'src/objects/js-regexp-string-iterator.h'
......@@ -67,7 +68,7 @@ extern class Oddball extends HeapObject {
type_of: String;
kind: Smi;
}
type HeapNumber extends HeapObject generates 'TNode<HeapNumber>';
extern class HeapNumber extends HeapObject { value: float64; }
type Number = Smi | HeapNumber;
type BigInt extends HeapObject generates 'TNode<BigInt>';
type Numeric = Number | BigInt;
......@@ -337,6 +338,11 @@ extern class SloppyArgumentsElements extends FixedArray {}
type NumberDictionary extends HeapObject
generates 'TNode<NumberDictionary>';
extern class FreeSpace extends HeapObject {
size: Smi;
next: FreeSpace;
}
// %RawDownCast should *never* be used anywhere in Torque code except for
// in Torque-based UnsafeCast operators preceeded by an appropriate
// type assert()
......@@ -1422,7 +1428,6 @@ extern macro SmiFromInt32(int32): Smi;
extern macro SmiUntag(Smi): intptr;
extern macro SmiToInt32(Smi): int32;
extern macro RoundIntPtrToFloat64(intptr): float64;
extern macro LoadHeapNumberValue(HeapNumber): float64;
extern macro ChangeFloat32ToFloat64(float32): float64;
extern macro ChangeNumberToFloat64(Number): float64;
extern macro ChangeFloat64ToUintPtr(float64): uintptr;
......
......@@ -10436,7 +10436,8 @@ Node* CodeStubAssembler::PrepareValueForWriteToTypedArray(
// same layout as the HeapNumber for the HeapNumber::value field. This
// way we can also properly optimize stores of oddballs to typed arrays.
GotoIf(IsHeapNumber(var_input.value()), &if_heapnumber_or_oddball);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Branch(HasInstanceType(var_input.value(), ODDBALL_TYPE),
&if_heapnumber_or_oddball, &convert);
......
......@@ -1370,7 +1370,8 @@ Node* EffectControlLinearizer::LowerChangeTaggedToInt32(Node* node) {
__ Goto(&done, ChangeSmiToInt32(value));
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
vfalse = __ ChangeFloat64ToInt32(vfalse);
__ Goto(&done, vfalse);
......@@ -1390,7 +1391,8 @@ Node* EffectControlLinearizer::LowerChangeTaggedToUint32(Node* node) {
__ Goto(&done, ChangeSmiToInt32(value));
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
vfalse = __ ChangeFloat64ToUint32(vfalse);
__ Goto(&done, vfalse);
......@@ -1410,7 +1412,8 @@ Node* EffectControlLinearizer::LowerChangeTaggedToInt64(Node* node) {
__ Goto(&done, ChangeSmiToInt64(value));
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
vfalse = __ ChangeFloat64ToInt64(vfalse);
__ Goto(&done, vfalse);
......@@ -1434,7 +1437,8 @@ Node* EffectControlLinearizer::LowerChangeTaggedToTaggedSigned(Node* node) {
__ Goto(&done, value);
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
vfalse = __ ChangeFloat64ToInt32(vfalse);
vfalse = ChangeInt32ToSmi(vfalse);
......@@ -1457,7 +1461,8 @@ Node* EffectControlLinearizer::LowerTruncateTaggedToFloat64(Node* node) {
__ Goto(&done, vtrue);
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
__ Goto(&done, vfalse);
......@@ -2420,7 +2425,8 @@ Node* EffectControlLinearizer::BuildCheckedHeapNumberOrOddballToFloat64(
__ Word32Equal(instance_type, __ Int32Constant(ODDBALL_TYPE));
__ DeoptimizeIfNot(DeoptimizeReason::kNotANumberOrOddball, feedback,
check_oddball, frame_state);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
__ Goto(&check_done);
__ Bind(&check_done);
......@@ -2491,7 +2497,8 @@ Node* EffectControlLinearizer::LowerTruncateTaggedToWord32(Node* node) {
__ Goto(&done, ChangeSmiToInt32(value));
__ Bind(&if_not_smi);
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Node* vfalse = __ LoadField(AccessBuilder::ForHeapNumberValue(), value);
vfalse = __ TruncateFloat64ToWord32(vfalse);
__ Goto(&done, vfalse);
......@@ -3146,7 +3153,8 @@ Node* EffectControlLinearizer::LowerNewDoubleElements(Node* node) {
ChangeInt32ToSmi(length));
// Initialize the backing store with holes.
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
Node* limit = ChangeUint32ToUintPtr(length);
Node* the_hole =
__ LoadField(AccessBuilder::ForHeapNumberValue(), __ TheHoleConstant());
......
......@@ -492,7 +492,10 @@ void BytecodeArray::BytecodeArrayVerify(Isolate* isolate) {
VerifyHeapPointer(isolate, constant_pool());
}
void FreeSpace::FreeSpaceVerify(Isolate* isolate) { CHECK(IsFreeSpace()); }
void FreeSpace::FreeSpaceVerify(Isolate* isolate) {
CHECK(IsFreeSpace());
VerifySmiField(kSizeOffset);
}
void FeedbackCell::FeedbackCellVerify(Isolate* isolate) {
CHECK(IsFeedbackCell());
......
......@@ -4645,7 +4645,8 @@ Handle<Object> CacheInitialJSArrayMaps(Handle<Context> native_context,
return initial_map;
}
STATIC_ASSERT(Oddball::kToNumberRawOffset == HeapNumber::kValueOffset);
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
Oddball::kToNumberRawOffset);
void Oddball::Initialize(Isolate* isolate, Handle<Oddball> oddball,
const char* to_string, Handle<Object> to_number,
......
......@@ -6,6 +6,7 @@
#define V8_OBJECTS_FREE_SPACE_H_
#include "src/objects/heap-object.h"
#include "torque-generated/class-definitions-from-dsl.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -40,15 +41,8 @@ class FreeSpace : public HeapObject {
DECL_PRINTER(FreeSpace)
DECL_VERIFIER(FreeSpace)
// Layout description.
#define FREE_SPACE_FIELDS(V) \
V(kSizeOffset, kTaggedSize) \
V(kNextOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, FREE_SPACE_FIELDS)
#undef FREE_SPACE_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_FREE_SPACE_FIELDS)
OBJECT_CONSTRUCTORS(FreeSpace, HeapObject);
};
......
......@@ -459,6 +459,9 @@ class BitSetComputer {
// Size of the field defined by DEFINE_FIELD_OFFSET_CONSTANTS
#define FIELD_SIZE(Name) (Name##End + 1 - Name)
// Compare two offsets with static cast
#define STATIC_ASSERT_FIELD_OFFSETS_EQUAL(Offset1, Offset2) \
STATIC_ASSERT(static_cast<int>(Offset1) == Offset2)
// ----------------------------------------------------------------------------
// Hash function.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment