Skip to content

Commit ad27629

Browse files
derekxu16Commit Queue
authored andcommitted
[VM] Delete streamable_ field from UntaggedUserTag
TEST=CI Issue: #61267 Change-Id: I5ae405b2edbe478b6a14aa2416e8e4ee590349cf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445520 Reviewed-by: Ben Konyi <[email protected]> Commit-Queue: Derek Xu <[email protected]>
1 parent f11e982 commit ad27629

File tree

11 files changed

+34
-225
lines changed

11 files changed

+34
-225
lines changed

runtime/lib/vmservice.cc

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -140,74 +140,4 @@ DEFINE_NATIVE_ENTRY(VMService_CancelStream, 0, 1) {
140140
return Object::null();
141141
}
142142

143-
#ifndef PRODUCT
144-
class UserTagIsolatesVisitor : public IsolateVisitor {
145-
public:
146-
UserTagIsolatesVisitor(Thread* thread,
147-
const GrowableObjectArray* user_tags,
148-
bool set_streamable)
149-
: IsolateVisitor(),
150-
thread_(thread),
151-
user_tags_(user_tags),
152-
set_streamable_(set_streamable) {}
153-
154-
virtual void VisitIsolate(Isolate* isolate) {
155-
if (Isolate::IsVMInternalIsolate(isolate)) {
156-
return;
157-
}
158-
Zone* zone = thread_->zone();
159-
UserTag& tag = UserTag::Handle(zone);
160-
String& label = String::Handle(zone);
161-
for (intptr_t i = 0; i < user_tags_->Length(); ++i) {
162-
label ^= user_tags_->At(i);
163-
tag ^= UserTag::FindTagInIsolate(isolate, thread_, label);
164-
if (!tag.IsNull()) {
165-
tag.set_streamable(set_streamable_);
166-
}
167-
}
168-
}
169-
170-
private:
171-
Thread* thread_;
172-
const GrowableObjectArray* user_tags_;
173-
bool set_streamable_;
174-
175-
DISALLOW_COPY_AND_ASSIGN(UserTagIsolatesVisitor);
176-
};
177-
#endif // !PRODUCT
178-
179-
// TODO(derekxu16): This function is now dead code and should be cleaned up.
180-
DEFINE_NATIVE_ENTRY(VMService_AddUserTagsToStreamableSampleList, 0, 1) {
181-
#ifndef PRODUCT
182-
GET_NON_NULL_NATIVE_ARGUMENT(GrowableObjectArray, user_tags,
183-
arguments->NativeArgAt(0));
184-
185-
Object& obj = Object::Handle();
186-
for (intptr_t i = 0; i < user_tags.Length(); ++i) {
187-
obj = user_tags.At(i);
188-
UserTags::AddStreamableTagName(obj.ToCString());
189-
}
190-
UserTagIsolatesVisitor visitor(thread, &user_tags, true);
191-
Isolate::VisitIsolates(&visitor);
192-
#endif
193-
return Object::null();
194-
}
195-
196-
// TODO(derekxu16): This function is now dead code and should be cleaned up.
197-
DEFINE_NATIVE_ENTRY(VMService_RemoveUserTagsFromStreamableSampleList, 0, 1) {
198-
#ifndef PRODUCT
199-
GET_NON_NULL_NATIVE_ARGUMENT(GrowableObjectArray, user_tags,
200-
arguments->NativeArgAt(0));
201-
202-
Object& obj = Object::Handle();
203-
for (intptr_t i = 0; i < user_tags.Length(); ++i) {
204-
obj = user_tags.At(i);
205-
UserTags::RemoveStreamableTagName(obj.ToCString());
206-
}
207-
UserTagIsolatesVisitor visitor(thread, &user_tags, false);
208-
Isolate::VisitIsolates(&visitor);
209-
#endif
210-
return Object::null();
211-
}
212-
213143
} // namespace dart

runtime/vm/bootstrap_natives.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ namespace dart {
293293
V(VMService_OnServerAddressChange, 1) \
294294
V(VMService_ListenStream, 2) \
295295
V(VMService_CancelStream, 1) \
296-
V(VMService_AddUserTagsToStreamableSampleList, 1) \
297-
V(VMService_RemoveUserTagsFromStreamableSampleList, 1) \
298296
V(Ffi_createNativeCallableListener, 2) \
299297
V(Ffi_createNativeCallableIsolateLocal, 3) \
300298
V(Ffi_createNativeCallableIsolateGroupBound, 2) \

runtime/vm/compiler/runtime_offsets_extracted.h

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

runtime/vm/dart.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ char* Dart::DartInit(const Dart_InitializeParams* params) {
373373
#endif
374374
IsolateGroup::Init();
375375
Isolate::InitVM();
376-
UserTags::Init();
377376
PortMap::Init();
378377
NativeMessageHandler::Init();
379378
Service::Init();
@@ -779,7 +778,6 @@ char* Dart::Cleanup() {
779778
ASSERT(Isolate::IsolateListLength() == 0);
780779
Service::Cleanup();
781780
PortMap::Cleanup();
782-
UserTags::Cleanup();
783781
IsolateGroup::Cleanup();
784782
ICData::Cleanup();
785783
ArgumentsDescriptor::Cleanup();

runtime/vm/object.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27796,7 +27796,6 @@ UserTagPtr UserTag::New(const String& label, Heap::Space space) {
2779627796
// No tag with label exists, create and register with isolate tag table.
2779727797
result = Object::Allocate<UserTag>(space);
2779827798
result.set_label(label);
27799-
result.set_streamable(UserTags::IsTagNameStreamable(label.ToCString()));
2780027799
AddTagToIsolate(thread, result);
2780127800
return result.ptr();
2780227801
}

runtime/vm/object.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13370,11 +13370,6 @@ class UserTag : public Instance {
1337013370
StoreNonPointer(&untag()->tag_, t);
1337113371
}
1337213372

13373-
bool streamable() const { return untag()->streamable(); }
13374-
void set_streamable(bool streamable) {
13375-
StoreNonPointer(&untag()->streamable_, streamable);
13376-
}
13377-
1337813373
static intptr_t tag_offset() { return OFFSET_OF(UntaggedUserTag, tag_); }
1337913374

1338013375
StringPtr label() const { return untag()->label(); }

runtime/vm/profiler.cc

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -775,21 +775,6 @@ void SampleBlockBuffer::FreeCompletedBlocks() {
775775
}
776776
}
777777

778-
bool SampleBlock::HasStreamableSamples(const GrowableObjectArray& tag_table,
779-
UserTag* tag) {
780-
for (intptr_t i = 0; i < capacity_; ++i) {
781-
Sample* sample = At(i);
782-
uword sample_tag = sample->user_tag();
783-
for (intptr_t j = 0; j < tag_table.Length(); ++j) {
784-
*tag ^= tag_table.At(j);
785-
if (tag->tag() == sample_tag && tag->streamable()) {
786-
return true;
787-
}
788-
}
789-
}
790-
return false;
791-
}
792-
793778
static void FlushSampleBlocks(Isolate* isolate) {
794779
ASSERT(isolate != nullptr);
795780

@@ -1910,37 +1895,7 @@ void SampleBlockProcessor::Cleanup() {
19101895
ASSERT(!thread_running_);
19111896
}
19121897

1913-
class StreamableSampleFilter : public SampleFilter {
1914-
public:
1915-
StreamableSampleFilter(Dart_Port port, const Isolate* isolate)
1916-
: SampleFilter(port, kNoTaskFilter, -1, -1, true), isolate_(isolate) {}
1917-
1918-
bool FilterSample(Sample* sample) override {
1919-
const UserTag& tag =
1920-
UserTag::Handle(UserTag::FindTagById(isolate_, sample->user_tag()));
1921-
return tag.streamable();
1922-
}
1923-
1924-
private:
1925-
const Isolate* isolate_;
1926-
};
1927-
1928-
void Profiler::ProcessCompletedBlocks(Isolate* isolate) {
1929-
if (!Service::profiler_stream.enabled()) return;
1930-
auto thread = Thread::Current();
1931-
if (Isolate::IsSystemIsolate(isolate)) return;
1932-
1933-
TIMELINE_DURATION(thread, Isolate, "Profiler::ProcessCompletedBlocks")
1934-
DisableThreadInterruptsScope dtis(thread);
1935-
StackZone zone(thread);
1936-
HandleScope handle_scope(thread);
1937-
StreamableSampleFilter filter(isolate->main_port(), isolate);
1938-
Profile profile;
1939-
profile.Build(thread, isolate, &filter, Profiler::sample_block_buffer());
1940-
ServiceEvent event(isolate, ServiceEvent::kCpuSamples);
1941-
event.set_cpu_profile(&profile);
1942-
Service::HandleEvent(&event);
1943-
}
1898+
void Profiler::ProcessCompletedBlocks(Isolate* isolate) {}
19441899

19451900
void Profiler::IsolateShutdown(Thread* thread) {
19461901
FlushSampleBlocks(thread->isolate());

runtime/vm/profiler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ class Profiler : public AllStatic {
9595
}
9696
inline static intptr_t Size();
9797

98+
// This function is currently a no-op, but should not be fully deleted
99+
// because it will be used to implement
100+
// go/dart-universal-observability-for-tools.
98101
static void ProcessCompletedBlocks(Isolate* isolate);
99102
static void IsolateShutdown(Thread* thread);
100103

@@ -722,8 +725,6 @@ class SampleBlock : public SampleBuffer {
722725
}
723726

724727
protected:
725-
bool HasStreamableSamples(const GrowableObjectArray& tag_table, UserTag* tag);
726-
727728
enum State : uint32_t {
728729
kFree,
729730
kSampling, // I.e., writing.

runtime/vm/raw_object.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,14 +3787,10 @@ class UntaggedUserTag : public UntaggedInstance {
37873787
// Isolate unique tag.
37883788
uword tag_;
37893789

3790-
// Should CPU samples with this tag be streamed?
3791-
bool streamable_;
3792-
37933790
friend class Object;
37943791

37953792
public:
37963793
uword tag() const { return tag_; }
3797-
bool streamable() const { return streamable_; }
37983794
};
37993795

38003796
class UntaggedFutureOr : public UntaggedInstance {

runtime/vm/tags.cc

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
namespace dart {
1515

16-
MallocGrowableArray<const char*> UserTags::subscribed_tags_(4);
17-
Mutex* UserTags::subscribed_tags_lock_ = nullptr;
18-
1916
const char* VMTag::TagName(uword tag) {
2017
if (IsNativeEntryTag(tag)) {
2118
const uint8_t* native_reverse_lookup = NativeEntry::ResolveSymbol(tag);
@@ -147,55 +144,4 @@ const char* UserTags::TagName(Thread* thread, Isolate* isolate, uword tag_id) {
147144
return label.ToCString();
148145
}
149146

150-
void UserTags::AddStreamableTagName(const char* tag) {
151-
MutexLocker ml(subscribed_tags_lock_);
152-
// Check this tag isn't already in the subscription list.
153-
for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
154-
if (strcmp(tag, subscribed_tags_.At(i)) == 0) {
155-
return;
156-
}
157-
}
158-
subscribed_tags_.Add(Utils::StrDup(tag));
159-
}
160-
161-
void UserTags::RemoveStreamableTagName(const char* tag) {
162-
MutexLocker ml(subscribed_tags_lock_);
163-
bool found = false;
164-
for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
165-
if (strcmp(tag, subscribed_tags_.At(i)) == 0) {
166-
free(const_cast<char*>(subscribed_tags_.At(i)));
167-
subscribed_tags_.RemoveAt(i);
168-
found = true;
169-
break;
170-
}
171-
}
172-
ASSERT(found);
173-
}
174-
175-
bool UserTags::IsTagNameStreamable(const char* tag) {
176-
MutexLocker ml(subscribed_tags_lock_);
177-
for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
178-
if (strcmp(tag, subscribed_tags_.At(i)) == 0) {
179-
return true;
180-
}
181-
}
182-
return false;
183-
}
184-
185-
void UserTags::Init() {
186-
subscribed_tags_lock_ = new Mutex();
187-
}
188-
189-
void UserTags::Cleanup() {
190-
{
191-
MutexLocker ml(subscribed_tags_lock_);
192-
for (intptr_t i = 0; i < subscribed_tags_.length(); ++i) {
193-
free(const_cast<char*>(subscribed_tags_.At(i)));
194-
}
195-
subscribed_tags_.Clear();
196-
}
197-
delete subscribed_tags_lock_;
198-
subscribed_tags_lock_ = nullptr;
199-
}
200-
201147
} // namespace dart

0 commit comments

Comments
 (0)