Skip to content

Commit

Permalink
Revert "WebAssembly: add a ton of logging when looking up metadata"
Browse files Browse the repository at this point in the history
Don't need logging anymore.

This reverts commit 065ab6f61c80c2573d72e1572c751914d42f7a61.
  • Loading branch information
zhuowei committed May 10, 2019
1 parent 81d21a3 commit 179b67e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 50 deletions.
28 changes: 0 additions & 28 deletions stdlib/public/runtime/MetadataLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,47 +276,19 @@ _findExtendedTypeContextDescriptor(const ExtensionContextDescriptor *extension,
/// buildContextDescriptorMangling in MetadataReader.
bool swift::_isCImportedTagType(const TypeContextDescriptor *type,
const ParsedTypeIdentity &identity) {
fprintf(stderr, "trying to dump type %p\n", type);
fprintf(stderr, "name: %s\n", type->Name.get());
fprintf(stderr, "trying to dump identity %p\n", &identity);
fprintf(stderr, "User facing name: %s\n", identity.UserFacingName.str().c_str());
fprintf(stderr, "ok, let's go\n");
// Tag types are always imported as structs or enums.
if (type->getKind() != ContextDescriptorKind::Enum &&
type->getKind() != ContextDescriptorKind::Struct)
return false;

fprintf(stderr, "is it a c typedef\n");

// Not a typedef imported as a nominal type.
if (identity.isCTypedef())
return false;

fprintf(stderr, "is related entity\n");

// Not a related entity.
if (identity.isAnyRelatedEntity())
return false;

fprintf(stderr, "is c imported context\n");
fprintf(stderr, "type's parent, raw: %x\n", *((unsigned int*)&type->Parent));
fprintf(stderr, "type's parent: %p\n", type->Parent.get());
// fprintf(stderr, "type's parent name: %s\n", type->Parent->Name.get());
fprintf(stderr, "trying to get module context\n");

for (auto cur = type->Parent.get(); true; cur = cur->Parent.get()) {
fprintf(stderr, "cur %p\n", cur);
fprintf(stderr, "cur %x\n", (unsigned int)cur->getKind());
if (auto module = dyn_cast<ModuleContextDescriptor>(cur)) {
fprintf(stderr, "found\n");
break;
}
}

fprintf(stderr, "type's parent module context: %p\n", type->Parent->getModuleContext());
fprintf(stderr, "trying to get name\n");
fprintf(stderr, "type's parent module context name: %s\n", type->Parent->getModuleContext()->Name.get());

// Imported from C.
return type->Parent->isCImportedContext();
}
Expand Down
25 changes: 3 additions & 22 deletions stdlib/public/runtime/ProtocolConformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ static const ProtocolConformanceDescriptor *
swift_conformsToSwiftProtocolImpl(const Metadata * const type,
const ProtocolDescriptor *protocol,
StringRef module) {
fprintf(stderr, "in impl2\n");
auto &C = Conformances.get();

// See if we have a cached conformance. The ConcurrentMap data structure
Expand All @@ -572,25 +571,17 @@ swift_conformsToSwiftProtocolImpl(const Metadata * const type,
C.cacheFailure(type, protocol, snapshot.count());
return nullptr;
}
fprintf(stderr, "got to really scan\n");

// Really scan conformance records.
for (size_t i = startIndex; i < endIndex; i++) {
fprintf(stderr, "index = %lx\n", (unsigned long)i);
auto &section = snapshot.Start[i];
// Eagerly pull records for nondependent witnesses into our cache.
for (const auto &record : section) {
fprintf(stderr, "got a record\n");
auto descriptorPtr = record.get();
auto &descriptor = *descriptorPtr;
fprintf(stderr, "got the descriptor: %p\n", descriptorPtr);
fprintf(stderr, "got the protocol: %p\n", descriptor.getProtocol());
descriptor.getProtocol()->dump();
fprintf(stderr, "got it\n");
auto &descriptor = *record.get();

// We only care about conformances for this protocol.
if (descriptor.getProtocol() != protocol)
continue;
fprintf(stderr, "about to get matching type\n");

// If there's a matching type, record the positive result.
ConformanceCandidate candidate(descriptor);
Expand All @@ -605,7 +596,6 @@ swift_conformsToSwiftProtocolImpl(const Metadata * const type,
}

// Conformance scan is complete.
fprintf(stderr, "about to update cache\n");

// Search the cache once more, and this time update the cache if necessary.
FoundConformance = searchInConformanceCache(type, protocol);
Expand All @@ -620,21 +610,12 @@ swift_conformsToSwiftProtocolImpl(const Metadata * const type,
static const WitnessTable *
swift_conformsToProtocolImpl(const Metadata * const type,
const ProtocolDescriptor *protocol) {
// WebAssembly: logging pls
fprintf(stderr, "swift_conformsToProtocolImpl: %p %p\n", type, protocol);
protocol->dump();
fprintf(stderr, "trying to dump the type now\n");
type->dump();
fprintf(stderr, "dumped the type\n");
// end WebAssembly
auto description =
swift_conformsToSwiftProtocol(type, protocol, StringRef());
if (!description)
return nullptr;
description->getProtocol()->dump();

auto retval = description->getWitnessTable(type);
return retval;
return description->getWitnessTable(type);
}

const ContextDescriptor *
Expand Down

0 comments on commit 179b67e

Please sign in to comment.