From d5be67a58c5d0fb32b1a75ec00bf6402820fc59e Mon Sep 17 00:00:00 2001 From: Z Duong Nguyen-Huu Date: Thu, 14 Mar 2019 14:10:37 -0700 Subject: [PATCH] Torquefy Oddball, PropertyArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: v8:8952 Change-Id: I07b3491e644634f9712e89d1566718084a3686d4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1518812 Reviewed-by: Jakob Gruber Reviewed-by: Simon Zünd Commit-Queue: Z Nguyen-Huu Cr-Commit-Position: refs/heads/master@{#60307} --- src/builtins/base.tq | 10 +++++++++- src/objects-debug.cc | 3 +++ src/objects/oddball.h | 22 ++++++---------------- src/objects/property-array.h | 12 ++++-------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/builtins/base.tq b/src/builtins/base.tq index 18adf62d12..f785c40e6d 100644 --- a/src/builtins/base.tq +++ b/src/builtins/base.tq @@ -60,7 +60,13 @@ type Code extends AbstractCode generates 'TNode'; type BuiltinPtr extends Smi generates 'TNode'; type Context extends HeapObject generates 'TNode'; type NativeContext extends Context; -type Oddball extends HeapObject generates 'TNode'; +extern class Oddball extends HeapObject { + to_number_raw: float64; + to_string: String; + to_number: Number; + type_of: String; + kind: Smi; +} type HeapNumber extends HeapObject generates 'TNode'; type Number = Smi | HeapNumber; type BigInt extends HeapObject generates 'TNode'; @@ -456,6 +462,8 @@ extern class ObjectTemplateInfo extends TemplateInfo { data: Object; } +extern class PropertyArray extends HeapObject { length_and_hash: Smi; } + type JSDataView extends JSArrayBufferView generates 'TNode'; type InstanceType generates 'TNode' constexpr 'InstanceType'; diff --git a/src/objects-debug.cc b/src/objects-debug.cc index f11baa1163..eeb5174e54 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -737,6 +737,7 @@ void PropertyArray::PropertyArrayVerify(Isolate* isolate) { Object e = get(i); Object::VerifyPointer(isolate, e); } + VerifySmiField(kLengthAndHashOffset); } void FixedDoubleArray::FixedDoubleArrayVerify(Isolate* isolate) { @@ -1197,6 +1198,8 @@ void Oddball::OddballVerify(Isolate* isolate) { } else { UNREACHABLE(); } + CHECK(to_string()->IsString()); + CHECK(type_of()->IsString()); } void Cell::CellVerify(Isolate* isolate) { diff --git a/src/objects/oddball.h b/src/objects/oddball.h index 8f6adf9743..5a47fa3967 100644 --- a/src/objects/oddball.h +++ b/src/objects/oddball.h @@ -6,6 +6,7 @@ #define V8_OBJECTS_ODDBALL_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" @@ -47,22 +48,11 @@ class Oddball : public HeapObject { const char* to_string, Handle to_number, const char* type_of, byte kind); - // Layout description. -#define ODDBALL_FIELDS(V) \ - V(kToNumberRawOffset, kDoubleSize) \ - /* Tagged fields. */ \ - V(kTaggedFieldsStartOffset, 0) \ - V(kToStringOffset, kTaggedSize) \ - V(kToNumberOffset, kTaggedSize) \ - V(kTypeOfOffset, kTaggedSize) \ - V(kTaggedFieldsEndOffset, 0) \ - /* Raw data but still encoded as Smi. */ \ - V(kKindOffset, kTaggedSize) \ - /* Total size. */ \ - V(kSize, 0) - - DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, ODDBALL_FIELDS) -#undef ODDBALL_FIELDS + DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, + TORQUE_GENERATED_ODDBALL_FIELDS) + // TODO(v8:8989): [torque] Support marker constants. + static const int kTaggedFieldsStartOffset = kToStringOffset; + static const int kTaggedFieldsEndOffset = kKindOffset; static const byte kFalse = 0; static const byte kTrue = 1; diff --git a/src/objects/property-array.h b/src/objects/property-array.h index c1ac27fb72..9d8d714ce6 100644 --- a/src/objects/property-array.h +++ b/src/objects/property-array.h @@ -6,6 +6,7 @@ #define V8_OBJECTS_PROPERTY_ARRAY_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" @@ -47,14 +48,9 @@ class PropertyArray : public HeapObject { DECL_PRINTER(PropertyArray) DECL_VERIFIER(PropertyArray) -// Layout description. -#define PROPERTY_ARRAY_FIELDS(V) \ - V(kLengthAndHashOffset, kTaggedSize) \ - /* Header size. */ \ - V(kHeaderSize, 0) - - DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, PROPERTY_ARRAY_FIELDS) -#undef PROPERTY_ARRAY_FIELDS + DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, + TORQUE_GENERATED_PROPERTY_ARRAY_FIELDS) + static const int kHeaderSize = kSize; // Garbage collection support. typedef FlexibleBodyDescriptor BodyDescriptor;