Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f3bf902

Browse files
author
Dart CI
committed
Version 2.18.0-121.0.dev
Merge commit '7ff9b2fb5e76cbb9d8bf745a9d70647a5d46a8a4' into 'dev'
2 parents 3818555 + 7ff9b2f commit f3bf902

File tree

6 files changed

+32
-132
lines changed

6 files changed

+32
-132
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ vars = {
8989
"charcode_rev": "84ea427711e24abf3b832923959caa7dd9a8514b",
9090
"chrome_rev": "19997",
9191
"cli_util_rev": "b0adbba89442b2ea6fef39c7a82fe79cb31e1168",
92-
"clock_rev": "5631a0612f4ac7e1b32f7c9a00fc7c00a41615e1",
92+
"clock_rev": "f594d86da123015186d5680b0d0e8255c52fc162",
9393
"collection_rev": "e1407da23b9f17400b3a905aafe2b8fa10db3d86",
9494
"convert_rev": "e063fdca4bebffecbb5e6aa5525995120982d9ce",
9595
"crypto_rev": "4297d240b0e1e780ec0a9eab23eaf1ad491f3e68",

runtime/vm/app_snapshot.cc

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,9 +1424,7 @@ class FieldSerializationCluster : public SerializationCluster {
14241424
}
14251425
// Write out either the initial static value or field offset.
14261426
if (Field::StaticBit::decode(field->untag()->kind_bits_)) {
1427-
const intptr_t field_id =
1428-
Smi::Value(field->untag()->host_offset_or_field_id());
1429-
s->Push(s->initial_field_table()->At(field_id));
1427+
s->Push(field->untag()->host_offset_or_field_id());
14301428
} else {
14311429
s->Push(Smi::New(Field::TargetOffsetOf(field)));
14321430
}
@@ -1472,10 +1470,7 @@ class FieldSerializationCluster : public SerializationCluster {
14721470

14731471
// Write out either the initial static value or field offset.
14741472
if (Field::StaticBit::decode(field->untag()->kind_bits_)) {
1475-
const intptr_t field_id =
1476-
Smi::Value(field->untag()->host_offset_or_field_id());
1477-
WriteFieldValue("static value", s->initial_field_table()->At(field_id));
1478-
s->WriteUnsigned(field_id);
1473+
WriteFieldValue("id", field->untag()->host_offset_or_field_id());
14791474
} else {
14801475
WriteFieldValue("offset", Smi::New(Field::TargetOffsetOf(field)));
14811476
}
@@ -1535,20 +1530,12 @@ class FieldDeserializationCluster : public DeserializationCluster {
15351530
#endif
15361531
field->untag()->kind_bits_ = d.Read<uint16_t>();
15371532

1538-
ObjectPtr value_or_offset = d.ReadRef();
1539-
if (Field::StaticBit::decode(field->untag()->kind_bits_)) {
1540-
const intptr_t field_id = d.ReadUnsigned();
1541-
d_->initial_field_table()->SetAt(
1542-
field_id, static_cast<InstancePtr>(value_or_offset));
1543-
field->untag()->host_offset_or_field_id_ = Smi::New(field_id);
1544-
} else {
1545-
field->untag()->host_offset_or_field_id_ =
1546-
Smi::RawCast(value_or_offset);
1533+
field->untag()->host_offset_or_field_id_ =
1534+
static_cast<SmiPtr>(d.ReadRef());
15471535
#if !defined(DART_PRECOMPILED_RUNTIME)
1548-
field->untag()->target_offset_ =
1549-
Smi::Value(field->untag()->host_offset_or_field_id());
1536+
field->untag()->target_offset_ =
1537+
Smi::Value(field->untag()->host_offset_or_field_id());
15501538
#endif // !defined(DART_PRECOMPILED_RUNTIME)
1551-
}
15521539
}
15531540
}
15541541

@@ -6019,6 +6006,12 @@ class ProgramSerializationRoots : public SerializationRoots {
60196006
s->Push(*p);
60206007
}
60216008

6009+
FieldTable* initial_field_table =
6010+
s->thread()->isolate_group()->initial_field_table();
6011+
for (intptr_t i = 0, n = initial_field_table->NumFieldIds(); i < n; i++) {
6012+
s->Push(initial_field_table->At(i));
6013+
}
6014+
60226015
dispatch_table_entries_ = object_store_->dispatch_table_code_entries();
60236016
// We should only have a dispatch table in precompiled mode.
60246017
ASSERT(dispatch_table_entries_.IsNull() || s->kind() == Snapshot::kFullAOT);
@@ -6043,6 +6036,14 @@ class ProgramSerializationRoots : public SerializationRoots {
60436036
s->WriteRootRef(*p, kObjectStoreFieldNames[p - from]);
60446037
}
60456038

6039+
FieldTable* initial_field_table =
6040+
s->thread()->isolate_group()->initial_field_table();
6041+
intptr_t n = initial_field_table->NumFieldIds();
6042+
s->WriteUnsigned(n);
6043+
for (intptr_t i = 0; i < n; i++) {
6044+
s->WriteRootRef(initial_field_table->At(i), "some-static-field");
6045+
}
6046+
60466047
// The dispatch table is serialized only for precompiled snapshots.
60476048
s->WriteDispatchTable(dispatch_table_entries_);
60486049
}
@@ -6087,6 +6088,14 @@ class ProgramDeserializationRoots : public DeserializationRoots {
60876088
*p = d->ReadRef();
60886089
}
60896090

6091+
FieldTable* initial_field_table =
6092+
d->thread()->isolate_group()->initial_field_table();
6093+
intptr_t n = d->ReadUnsigned();
6094+
initial_field_table->AllocateIndex(n - 1);
6095+
for (intptr_t i = 0; i < n; i++) {
6096+
initial_field_table->SetAt(i, d->ReadRef());
6097+
}
6098+
60906099
// Deserialize dispatch table (when applicable)
60916100
d->ReadDispatchTable();
60926101
}
@@ -6303,7 +6312,6 @@ Serializer::Serializer(Thread* thread,
63036312
num_base_objects_(0),
63046313
num_written_objects_(0),
63056314
next_ref_index_(kFirstReference),
6306-
initial_field_table_(thread->isolate_group()->initial_field_table()),
63076315
vm_(vm),
63086316
profile_writer_(profile_writer)
63096317
#if defined(SNAPSHOT_BACKTRACE)
@@ -7508,12 +7516,6 @@ ZoneGrowableArray<Object*>* Serializer::Serialize(SerializationRoots* roots) {
75087516
WriteUnsigned(num_base_objects_);
75097517
WriteUnsigned(num_objects);
75107518
WriteUnsigned(clusters.length());
7511-
// TODO(dartbug.com/36097): Not every snapshot carries the field table.
7512-
if (current_loading_unit_id_ <= LoadingUnit::kRootId) {
7513-
WriteUnsigned(initial_field_table_->NumFieldIds());
7514-
} else {
7515-
WriteUnsigned(0);
7516-
}
75177519
ASSERT((instructions_table_len_ == 0) || FLAG_precompiled_mode);
75187520
WriteUnsigned(instructions_table_len_);
75197521
WriteUnsigned(instructions_table_rodata_offset_);
@@ -7800,7 +7802,6 @@ Deserializer::Deserializer(Thread* thread,
78007802
refs_(nullptr),
78017803
next_ref_index_(kFirstReference),
78027804
clusters_(nullptr),
7803-
initial_field_table_(thread->isolate_group()->initial_field_table()),
78047805
is_non_root_unit_(is_non_root_unit),
78057806
instructions_table_(InstructionsTable::Handle(thread->zone())) {
78067807
if (Snapshot::IncludesCode(kind)) {
@@ -8316,17 +8317,12 @@ void Deserializer::Deserialize(DeserializationRoots* roots) {
83168317
num_base_objects_ = ReadUnsigned();
83178318
num_objects_ = ReadUnsigned();
83188319
num_clusters_ = ReadUnsigned();
8319-
const intptr_t initial_field_table_len = ReadUnsigned();
83208320
const intptr_t instructions_table_len = ReadUnsigned();
83218321
const uint32_t instruction_table_data_offset = ReadUnsigned();
83228322
USE(instruction_table_data_offset);
83238323

83248324
clusters_ = new DeserializationCluster*[num_clusters_];
83258325
refs = Array::New(num_objects_ + kFirstReference, Heap::kOld);
8326-
if (initial_field_table_len > 0) {
8327-
initial_field_table_->AllocateIndex(initial_field_table_len - 1);
8328-
ASSERT_EQUAL(initial_field_table_->NumFieldIds(), initial_field_table_len);
8329-
}
83308326

83318327
#if defined(DART_PRECOMPILED_RUNTIME)
83328328
if (instructions_table_len > 0) {

runtime/vm/app_snapshot.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ class Serializer : public ThreadStackResource {
266266
ZoneGrowableArray<Object*>* Serialize(SerializationRoots* roots);
267267
void PrintSnapshotSizes();
268268

269-
FieldTable* initial_field_table() const { return initial_field_table_; }
270-
271269
NonStreamingWriteStream* stream() { return stream_; }
272270
intptr_t bytes_written() { return stream_->bytes_written(); }
273271
intptr_t bytes_heap_allocated() { return bytes_heap_allocated_; }
@@ -516,7 +514,6 @@ class Serializer : public ThreadStackResource {
516514
intptr_t num_base_objects_;
517515
intptr_t num_written_objects_;
518516
intptr_t next_ref_index_;
519-
FieldTable* initial_field_table_;
520517

521518
intptr_t dispatch_table_size_ = 0;
522519
intptr_t bytes_heap_allocated_ = 0;
@@ -716,7 +713,6 @@ class Deserializer : public ThreadStackResource {
716713
return kind_;
717714
#endif
718715
}
719-
FieldTable* initial_field_table() const { return initial_field_table_; }
720716
bool is_non_root_unit() const { return is_non_root_unit_; }
721717
void set_code_start_index(intptr_t value) { code_start_index_ = value; }
722718
intptr_t code_start_index() const { return code_start_index_; }
@@ -810,7 +806,6 @@ class Deserializer : public ThreadStackResource {
810806
intptr_t code_stop_index_ = 0;
811807
intptr_t instructions_index_ = 0;
812808
DeserializationCluster** clusters_;
813-
FieldTable* initial_field_table_;
814809
const bool is_non_root_unit_;
815810
InstructionsTable& instructions_table_;
816811
};

sdk/lib/_internal/js_dev_runtime/private/js_number.dart

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ class JSNumber extends Interceptor implements int, double {
435435

436436
@notNull
437437
static int _clz32(@notNull int uint32) {
438-
// TODO(sra): Use `Math.clz32(uint32)` (not available on IE11).
439-
return 32 - _bitCount(_spread(uint32));
438+
return JS('!', 'Math.clz32(#)', uint32);
440439
}
441440

442441
// Returns pow(this, e) % m.
@@ -581,54 +580,6 @@ class JSNumber extends Interceptor implements int, double {
581580
return _binaryGcd(x, y, false);
582581
}
583582

584-
// Assumes i is <= 32-bit and unsigned.
585-
@notNull
586-
static int _bitCount(@notNull int i) {
587-
// See "Hacker's Delight", section 5-1, "Counting 1-Bits".
588-
589-
// The basic strategy is to use "divide and conquer" to
590-
// add pairs (then quads, etc.) of bits together to obtain
591-
// sub-counts.
592-
//
593-
// A straightforward approach would look like:
594-
//
595-
// i = (i & 0x55555555) + ((i >> 1) & 0x55555555);
596-
// i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
597-
// i = (i & 0x0F0F0F0F) + ((i >> 4) & 0x0F0F0F0F);
598-
// i = (i & 0x00FF00FF) + ((i >> 8) & 0x00FF00FF);
599-
// i = (i & 0x0000FFFF) + ((i >> 16) & 0x0000FFFF);
600-
//
601-
// The code below removes unnecessary &'s and uses a
602-
// trick to remove one instruction in the first line.
603-
604-
i = _shru(i, 0) - (_shru(i, 1) & 0x55555555);
605-
i = (i & 0x33333333) + (_shru(i, 2) & 0x33333333);
606-
i = 0x0F0F0F0F & (i + _shru(i, 4));
607-
i += _shru(i, 8);
608-
i += _shru(i, 16);
609-
return (i & 0x0000003F);
610-
}
611-
612-
@notNull
613-
static int _shru(int value, int shift) =>
614-
JS<int>('!', '# >>> #', value, shift);
615-
@notNull
616-
static int _shrs(int value, int shift) =>
617-
JS<int>('!', '# >> #', value, shift);
618-
@notNull
619-
static int _ors(int a, int b) => JS<int>('!', '# | #', a, b);
620-
621-
// Assumes i is <= 32-bit
622-
@notNull
623-
static int _spread(@notNull int i) {
624-
i = _ors(i, _shrs(i, 1));
625-
i = _ors(i, _shrs(i, 2));
626-
i = _ors(i, _shrs(i, 4));
627-
i = _ors(i, _shrs(i, 8));
628-
i = _shru(_ors(i, _shrs(i, 16)), 0);
629-
return i;
630-
}
631-
632583
@notNull
633584
int operator ~() => JS<int>('!', r'(~#) >>> 0', this);
634585
}

sdk/lib/_internal/js_runtime/lib/js_number.dart

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ class JSInt extends JSNumber implements int {
531531
}
532532

533533
static int _clz32(int uint32) {
534-
// TODO(sra): Use `Math.clz32(uint32)` (not available on IE11).
535-
return 32 - _bitCount(_spread(uint32));
534+
return JS('JSUInt31', 'Math.clz32(#)', uint32);
536535
}
537536

538537
// Returns pow(this, e) % m.
@@ -684,47 +683,6 @@ class JSInt extends JSNumber implements int {
684683
return _binaryGcd(x, y, false);
685684
}
686685

687-
// Assumes i is <= 32-bit and unsigned.
688-
static int _bitCount(int i) {
689-
// See "Hacker's Delight", section 5-1, "Counting 1-Bits".
690-
691-
// The basic strategy is to use "divide and conquer" to
692-
// add pairs (then quads, etc.) of bits together to obtain
693-
// sub-counts.
694-
//
695-
// A straightforward approach would look like:
696-
//
697-
// i = (i & 0x55555555) + ((i >> 1) & 0x55555555);
698-
// i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
699-
// i = (i & 0x0F0F0F0F) + ((i >> 4) & 0x0F0F0F0F);
700-
// i = (i & 0x00FF00FF) + ((i >> 8) & 0x00FF00FF);
701-
// i = (i & 0x0000FFFF) + ((i >> 16) & 0x0000FFFF);
702-
//
703-
// The code below removes unnecessary &'s and uses a
704-
// trick to remove one instruction in the first line.
705-
706-
i = _shru(i, 0) - (_shru(i, 1) & 0x55555555);
707-
i = (i & 0x33333333) + (_shru(i, 2) & 0x33333333);
708-
i = 0x0F0F0F0F & (i + _shru(i, 4));
709-
i += _shru(i, 8);
710-
i += _shru(i, 16);
711-
return (i & 0x0000003F);
712-
}
713-
714-
static int _shru(int value, int shift) => JS('int', '# >>> #', value, shift);
715-
static int _shrs(int value, int shift) => JS('int', '# >> #', value, shift);
716-
static int _ors(int a, int b) => JS('int', '# | #', a, b);
717-
718-
// Assumes i is <= 32-bit
719-
static int _spread(int i) {
720-
i = _ors(i, _shrs(i, 1));
721-
i = _ors(i, _shrs(i, 2));
722-
i = _ors(i, _shrs(i, 4));
723-
i = _ors(i, _shrs(i, 8));
724-
i = _shru(_ors(i, _shrs(i, 16)), 0);
725-
return i;
726-
}
727-
728686
Type get runtimeType => int;
729687

730688
int operator ~() => JS('JSUInt32', r'(~#) >>> 0', this);

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 18
2929
PATCH 0
30-
PRERELEASE 120
30+
PRERELEASE 121
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)