Skip to content

Commit cb46310

Browse files
isheludkoCommit Bot
authored andcommitted
[runtime] Extend InstanceType to uint16_t range of values.
Bug: v8:5799 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Iff62cf07d85b48975d7a21da388bbf6addeb56f1 Reviewed-on: https://chromium-review.googlesource.com/781633 Commit-Queue: Igor Sheludko <ishell@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#49589}
1 parent 9a0908a commit cb46310

20 files changed

Lines changed: 71 additions & 44 deletions

include/v8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9152,7 +9152,7 @@ class Internals {
91529152
V8_INLINE static int GetInstanceType(const internal::Object* obj) {
91539153
typedef internal::Object O;
91549154
O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
9155-
return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
9155+
return ReadField<uint16_t>(map, kMapInstanceTypeOffset);
91569156
}
91579157

91589158
V8_INLINE static int GetOddballKind(const internal::Object* obj) {

src/arm/macro-assembler-arm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ void MacroAssembler::CompareObjectType(Register object,
15801580
void MacroAssembler::CompareInstanceType(Register map,
15811581
Register type_reg,
15821582
InstanceType type) {
1583-
ldrb(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
1583+
ldrh(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
15841584
cmp(type_reg, Operand(type));
15851585
}
15861586

src/arm64/macro-assembler-arm64.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,12 +1678,9 @@ void MacroAssembler::AssertGeneratorObject(Register object) {
16781678
Register temp = temps.AcquireX();
16791679
Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
16801680

1681-
// Load instance type
1682-
Ldrb(temp, FieldMemOperand(temp, Map::kInstanceTypeOffset));
1683-
16841681
Label do_check;
1685-
// Check if JSGeneratorObject
1686-
Cmp(temp, JS_GENERATOR_OBJECT_TYPE);
1682+
// Load instance type and check if JSGeneratorObject
1683+
CompareInstanceType(temp, temp, JS_GENERATOR_OBJECT_TYPE);
16871684
B(eq, &do_check);
16881685

16891686
// Check if JSAsyncGeneratorObject
@@ -2712,7 +2709,7 @@ void MacroAssembler::CompareObjectType(Register object,
27122709
void MacroAssembler::CompareInstanceType(Register map,
27132710
Register type_reg,
27142711
InstanceType type) {
2715-
Ldrb(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
2712+
Ldrh(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
27162713
Cmp(type_reg, type);
27172714
}
27182715

src/builtins/mips/builtins-mips.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,8 +2315,7 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
23152315
__ JumpIfSmi(a1, &non_constructor);
23162316

23172317
// Dispatch based on instance type.
2318-
__ lw(t1, FieldMemOperand(a1, HeapObject::kMapOffset));
2319-
__ lbu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset));
2318+
__ GetObjectType(a1, t1, t2);
23202319
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
23212320
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE));
23222321

src/builtins/mips64/builtins-mips64.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,8 +2334,7 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
23342334
__ JumpIfSmi(a1, &non_constructor);
23352335

23362336
// Dispatch based on instance type.
2337-
__ Ld(t1, FieldMemOperand(a1, HeapObject::kMapOffset));
2338-
__ Lbu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset));
2337+
__ GetObjectType(a1, t1, t2);
23392338
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
23402339
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE));
23412340

src/code-stub-assembler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ TNode<Uint32T> CodeStubAssembler::LoadMapBitField3(SloppyTNode<Map> map) {
13301330

13311331
TNode<Int32T> CodeStubAssembler::LoadMapInstanceType(SloppyTNode<Map> map) {
13321332
return UncheckedCast<Int32T>(
1333-
LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8()));
1333+
LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint16()));
13341334
}
13351335

13361336
TNode<Int32T> CodeStubAssembler::LoadMapElementsKind(SloppyTNode<Map> map) {

src/compiler/access-builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ FieldAccess AccessBuilder::ForMapDescriptors() {
550550
FieldAccess AccessBuilder::ForMapInstanceType() {
551551
FieldAccess access = {
552552
kTaggedBase, Map::kInstanceTypeOffset, Handle<Name>(),
553-
MaybeHandle<Map>(), TypeCache::Get().kUint8, MachineType::Uint8(),
553+
MaybeHandle<Map>(), TypeCache::Get().kUint16, MachineType::Uint16(),
554554
kNoWriteBarrier};
555555
return access;
556556
}

src/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const int kMinUInt32 = 0;
151151
const int kUInt8Size = sizeof(uint8_t);
152152
const int kCharSize = sizeof(char);
153153
const int kShortSize = sizeof(short); // NOLINT
154+
const int kUInt16Size = sizeof(uint16_t);
154155
const int kIntSize = sizeof(int);
155156
const int kInt32Size = sizeof(int32_t);
156157
const int kInt64Size = sizeof(int64_t);

src/heap/heap.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,6 @@ AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
23982398
map->set_map_after_allocation(reinterpret_cast<Map*>(root(kMetaMapRootIndex)),
23992399
SKIP_WRITE_BARRIER);
24002400
map->set_instance_type(instance_type);
2401-
WRITE_BYTE_FIELD(map, Map::kSoonToBeInstanceTypeTooOffset, 0);
24022401
map->set_instance_size(instance_size);
24032402
// Initialize to only containing tagged fields.
24042403
if (FLAG_unbox_double_fields) {
@@ -2440,7 +2439,6 @@ AllocationResult Heap::AllocateMap(InstanceType instance_type,
24402439
map->set_prototype(null_value(), SKIP_WRITE_BARRIER);
24412440
map->set_constructor_or_backpointer(null_value(), SKIP_WRITE_BARRIER);
24422441
map->set_instance_size(instance_size);
2443-
WRITE_BYTE_FIELD(map, Map::kSoonToBeInstanceTypeTooOffset, 0);
24442442
if (map->IsJSObjectMap()) {
24452443
map->SetInObjectPropertiesStartInWords(instance_size / kPointerSize -
24462444
inobject_properties);

src/ia32/macro-assembler-ia32.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void MacroAssembler::CmpObjectType(Register heap_object,
483483

484484

485485
void MacroAssembler::CmpInstanceType(Register map, InstanceType type) {
486-
cmpb(FieldOperand(map, Map::kInstanceTypeOffset), Immediate(type));
486+
cmpw(FieldOperand(map, Map::kInstanceTypeOffset), Immediate(type));
487487
}
488488

489489
void MacroAssembler::AssertSmi(Register object) {

0 commit comments

Comments
 (0)