{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/221103884","pull_request_review_id":159674320,"id":221103884,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTEwMzg4NA==","diff_hunk":"@@ -0,0 +1,458 @@\n+//===--- SILConstants.h - SIL constant representation -----------*- C++ -*-===//\n+//\n+// This source file is part of the Swift.org open source project\n+//\n+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors\n+// Licensed under Apache License v2.0 with Runtime Library Exception\n+//\n+// See https://swift.org/LICENSE.txt for license information\n+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors\n+//\n+//===----------------------------------------------------------------------===//\n+//\n+// This defines an interface to represent SIL level structured constants in an\n+// memory efficient way.\n+//\n+//===----------------------------------------------------------------------===//\n+\n+#ifndef SWIFT_SIL_CONSTANTS_H\n+#define SWIFT_SIL_CONSTANTS_H\n+\n+#include \"swift/SIL/SILValue.h\"\n+\n+namespace swift {\n+class SingleValueInstruction;\n+class SILValue;\n+class SILBuilder;\n+class SerializedSILLoader;\n+\n+struct APFloatSymbolicValue;\n+struct APIntSymbolicValue;\n+struct ArraySymbolicValue;\n+struct DerivedAddressValue;\n+struct EnumWithPayloadSymbolicValue;\n+struct SymbolicValueMemoryObject;\n+struct UnknownSymbolicValue;\n+\n+/// When we fail to constant fold a value, this captures a reason why,\n+/// allowing the caller to produce a specific diagnostic.  The \"Unknown\"\n+/// SymbolicValue representation also includes a pointer to the SILNode in\n+/// question that was problematic.\n+enum class UnknownReason {\n+  // TODO: Eliminate the default code, by making classifications for each\n+  // failure mode.\n+  Default,\n+\n+  /// The constant expression was too big.  This is reported on a random\n+  /// instruction within the constexpr that triggered the issue.\n+  TooManyInstructions,\n+\n+  /// A control flow loop was found.\n+  Loop,\n+\n+  /// Integer overflow detected.\n+  Overflow,\n+\n+  /// Unspecified trap detected.\n+  Trap,\n+};\n+\n+/// This is the symbolic value tracked for each SILValue in a scope.  We\n+/// support multiple representational forms for the constant node in order to\n+/// avoid pointless memory bloat + copying.  This is intended to be a\n+/// light-weight POD type we can put in hash tables and pass around by-value.\n+///\n+/// Internally, this value has multiple ways to represent the same sorts of\n+/// symbolic values (e.g. to save memory).  It provides a simpler public\n+/// interface though.\n+class SymbolicValue {\n+private:\n+  enum RepresentationKind {\n+    /// This value is an alloc stack that is has not (yet) been initialized\n+    /// by flow-sensitive analysis.\n+    RK_UninitMemory,\n+\n+    /// This symbolic value cannot be determined, carries multiple values\n+    /// (i.e., varies dynamically at the top level), or is of some type that\n+    /// we cannot analyze and propagate (e.g. NSObject).\n+    ///\n+    RK_Unknown,\n+\n+    /// This value is known to be a metatype reference.  The type is stored\n+    /// in the \"metatype\" member.\n+    RK_Metatype,\n+\n+    /// This value is known to be a function reference, e.g. through\n+    /// function_ref directly, or a devirtualized method reference.\n+    RK_Function,\n+\n+    /// This value is represented with a bump-pointer allocated APInt.\n+    RK_Integer,\n+\n+    /// This value is represented with an inline integer representation.\n+    RK_IntegerInline,\n+\n+    /// This value is represented with a bump-pointer allocated APFloat.\n+    RK_Float,\n+\n+    /// This value is representation with an inline float representation.\n+    RK_Float32,\n+\n+    /// This value is representation with an inline double representation.\n+    RK_Float64,\n+\n+    /// This value is represented with a bump-pointer allocated char array\n+    /// representing a UTF-8 encoded string.\n+    RK_String,\n+\n+    /// This value is an array, struct, or tuple of constants.  This is\n+    /// tracked by the \"aggregate\" member of the value union.\n+    RK_Aggregate,\n+\n+    /// This value is an enum with no payload.\n+    RK_Enum,\n+\n+    /// This value is an enum with a payload.\n+    RK_EnumWithPayload,\n+\n+    /// This represents a direct reference to the address of a memory object.\n+    RK_DirectAddress,\n+\n+    /// This represents an index *into* a memory object.\n+    RK_DerivedAddress,\n+\n+    /// This represents an array value.\n+    RK_Array,\n+\n+    /// This represents an address of a memory object containing an array.\n+    RK_ArrayAddress,\n+  };\n+\n+  union {\n+    /// When the value is Unknown, this contains information about the\n+    /// unfoldable part of the computation.\n+    UnknownSymbolicValue *unknown;\n+\n+    /// This is always a SILType with an object category.  This is the value\n+    /// of the underlying instance type, not the MetatypeType.\n+    TypeBase *metatype;\n+\n+    SILFunction *function;\n+\n+    /// When this SymbolicValue is of \"Inst\" kind, this contains a\n+    /// pointer to the instruction whose value this holds.  This is known to\n+    /// be one of a closed set of constant instructions:\n+    ///    IntegerLiteralInst, FloatLiteralInst, StringLiteralInst\n+    SingleValueInstruction *inst;","path":"include/swift/SIL/SILConstants.h","position":146,"original_position":146,"commit_id":"ca8b6621f21b9289ed9795a74df9c077bccb79a4","original_commit_id":"ca8b6621f21b9289ed9795a74df9c077bccb79a4","user":{"login":"mhong","id":969799,"node_id":"MDQ6VXNlcjk2OTc5OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/969799?v=4","gravatar_id":"","url":"https://api.github.com/users/mhong","html_url":"https://github.com/mhong","followers_url":"https://api.github.com/users/mhong/followers","following_url":"https://api.github.com/users/mhong/following{/other_user}","gists_url":"https://api.github.com/users/mhong/gists{/gist_id}","starred_url":"https://api.github.com/users/mhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhong/subscriptions","organizations_url":"https://api.github.com/users/mhong/orgs","repos_url":"https://api.github.com/users/mhong/repos","events_url":"https://api.github.com/users/mhong/events{/privacy}","received_events_url":"https://api.github.com/users/mhong/received_events","type":"User","site_admin":false},"body":"You are right. I forgot to remove it from the branch code. @marcrasi please feel free to remove.","created_at":"2018-09-27T23:10:39Z","updated_at":"2018-09-27T23:10:39Z","html_url":"https://github.com/apple/swift/pull/19579#discussion_r221103884","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/19579","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/221103884"},"html":{"href":"https://github.com/apple/swift/pull/19579#discussion_r221103884"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/19579"}},"in_reply_to_id":221037059},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/19579","id":218517720,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE4NTE3NzIw","html_url":"https://github.com/apple/swift/pull/19579","diff_url":"https://github.com/apple/swift/pull/19579.diff","patch_url":"https://github.com/apple/swift/pull/19579.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/19579","number":19579,"state":"open","locked":false,"title":"Compile-time interpretation","user":{"login":"marcrasi","id":5945760,"node_id":"MDQ6VXNlcjU5NDU3NjA=","avatar_url":"https://avatars0.githubusercontent.com/u/5945760?v=4","gravatar_id":"","url":"https://api.github.com/users/marcrasi","html_url":"https://github.com/marcrasi","followers_url":"https://api.github.com/users/marcrasi/followers","following_url":"https://api.github.com/users/marcrasi/following{/other_user}","gists_url":"https://api.github.com/users/marcrasi/gists{/gist_id}","starred_url":"https://api.github.com/users/marcrasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcrasi/subscriptions","organizations_url":"https://api.github.com/users/marcrasi/orgs","repos_url":"https://api.github.com/users/marcrasi/repos","events_url":"https://api.github.com/users/marcrasi/events{/privacy}","received_events_url":"https://api.github.com/users/marcrasi/received_events","type":"User","site_admin":false},"body":"This brings the compile-time interpreter from the tensorflow branch into master, so that everyone can start using it. To make the interpreter testable, this also brings the `#assert` expression into master, hidden under a `-enable-experimental-static-assert` flag.\r\n\r\nSome possible issues that I noticed while bringing the code over:\r\n* This makes `SILModule::getSILLoader()` and `getWitnessMethodSubstitutions` public so that the interpreter can access them. Maybe we should do something more proper before merging this.\r\n* The `#assert` tests don't exercise all the interpreter functionality, because there are tensorflow tests in the tensorflow branch that exercise those parts. e.g. `decodeAllocUninitializedArray`, and possibly various other features that never got added to `#assert` tests. Could we leave these in without tests, and defer tests to when someone adds a compiler feature that exercises them?\r\n\r\nLet me know if you want this split into smaller parts for easier reviewing. It would probably make sense in 3 parts:\r\n1. `SILConstants`, ~1,300 lines\r\n2. The actual interpreter, ~2,000 lines\r\n3. `#assert`, ~500 lines","created_at":"2018-09-27T04:02:22Z","updated_at":"2018-09-27T23:10:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dcfe49f8df255f8edc2539d495da358c3f8d43bd","assignee":null,"assignees":[],"requested_reviewers":[{"login":"devincoughlin","id":2623655,"node_id":"MDQ6VXNlcjI2MjM2NTU=","avatar_url":"https://avatars1.githubusercontent.com/u/2623655?v=4","gravatar_id":"","url":"https://api.github.com/users/devincoughlin","html_url":"https://github.com/devincoughlin","followers_url":"https://api.github.com/users/devincoughlin/followers","following_url":"https://api.github.com/users/devincoughlin/following{/other_user}","gists_url":"https://api.github.com/users/devincoughlin/gists{/gist_id}","starred_url":"https://api.github.com/users/devincoughlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devincoughlin/subscriptions","organizations_url":"https://api.github.com/users/devincoughlin/orgs","repos_url":"https://api.github.com/users/devincoughlin/repos","events_url":"https://api.github.com/users/devincoughlin/events{/privacy}","received_events_url":"https://api.github.com/users/devincoughlin/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/19579/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/19579/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/19579/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/ca8b6621f21b9289ed9795a74df9c077bccb79a4","head":{"label":"marcrasi:const-evaluator","ref":"const-evaluator","sha":"ca8b6621f21b9289ed9795a74df9c077bccb79a4","user":{"login":"marcrasi","id":5945760,"node_id":"MDQ6VXNlcjU5NDU3NjA=","avatar_url":"https://avatars0.githubusercontent.com/u/5945760?v=4","gravatar_id":"","url":"https://api.github.com/users/marcrasi","html_url":"https://github.com/marcrasi","followers_url":"https://api.github.com/users/marcrasi/followers","following_url":"https://api.github.com/users/marcrasi/following{/other_user}","gists_url":"https://api.github.com/users/marcrasi/gists{/gist_id}","starred_url":"https://api.github.com/users/marcrasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcrasi/subscriptions","organizations_url":"https://api.github.com/users/marcrasi/orgs","repos_url":"https://api.github.com/users/marcrasi/repos","events_url":"https://api.github.com/users/marcrasi/events{/privacy}","received_events_url":"https://api.github.com/users/marcrasi/received_events","type":"User","site_admin":false},"repo":{"id":135738994,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU3Mzg5OTQ=","name":"swift","full_name":"marcrasi/swift","private":false,"owner":{"login":"marcrasi","id":5945760,"node_id":"MDQ6VXNlcjU5NDU3NjA=","avatar_url":"https://avatars0.githubusercontent.com/u/5945760?v=4","gravatar_id":"","url":"https://api.github.com/users/marcrasi","html_url":"https://github.com/marcrasi","followers_url":"https://api.github.com/users/marcrasi/followers","following_url":"https://api.github.com/users/marcrasi/following{/other_user}","gists_url":"https://api.github.com/users/marcrasi/gists{/gist_id}","starred_url":"https://api.github.com/users/marcrasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcrasi/subscriptions","organizations_url":"https://api.github.com/users/marcrasi/orgs","repos_url":"https://api.github.com/users/marcrasi/repos","events_url":"https://api.github.com/users/marcrasi/events{/privacy}","received_events_url":"https://api.github.com/users/marcrasi/received_events","type":"User","site_admin":false},"html_url":"https://github.com/marcrasi/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/marcrasi/swift","forks_url":"https://api.github.com/repos/marcrasi/swift/forks","keys_url":"https://api.github.com/repos/marcrasi/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marcrasi/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marcrasi/swift/teams","hooks_url":"https://api.github.com/repos/marcrasi/swift/hooks","issue_events_url":"https://api.github.com/repos/marcrasi/swift/issues/events{/number}","events_url":"https://api.github.com/repos/marcrasi/swift/events","assignees_url":"https://api.github.com/repos/marcrasi/swift/assignees{/user}","branches_url":"https://api.github.com/repos/marcrasi/swift/branches{/branch}","tags_url":"https://api.github.com/repos/marcrasi/swift/tags","blobs_url":"https://api.github.com/repos/marcrasi/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marcrasi/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marcrasi/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/marcrasi/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marcrasi/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/marcrasi/swift/languages","stargazers_url":"https://api.github.com/repos/marcrasi/swift/stargazers","contributors_url":"https://api.github.com/repos/marcrasi/swift/contributors","subscribers_url":"https://api.github.com/repos/marcrasi/swift/subscribers","subscription_url":"https://api.github.com/repos/marcrasi/swift/subscription","commits_url":"https://api.github.com/repos/marcrasi/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/marcrasi/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/marcrasi/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/marcrasi/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/marcrasi/swift/contents/{+path}","compare_url":"https://api.github.com/repos/marcrasi/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marcrasi/swift/merges","archive_url":"https://api.github.com/repos/marcrasi/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marcrasi/swift/downloads","issues_url":"https://api.github.com/repos/marcrasi/swift/issues{/number}","pulls_url":"https://api.github.com/repos/marcrasi/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/marcrasi/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/marcrasi/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marcrasi/swift/labels{/name}","releases_url":"https://api.github.com/repos/marcrasi/swift/releases{/id}","deployments_url":"https://api.github.com/repos/marcrasi/swift/deployments","created_at":"2018-06-01T16:13:26Z","updated_at":"2018-06-01T16:13:59Z","pushed_at":"2018-09-27T21:05:16Z","git_url":"git://github.com/marcrasi/swift.git","ssh_url":"git@github.com:marcrasi/swift.git","clone_url":"https://github.com/marcrasi/swift.git","svn_url":"https://github.com/marcrasi/swift","homepage":"https://swift.org/","size":343789,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"8c94b3818f650d589c563dfa67798e595a5f98fe","user":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":44838949,"node_id":"MDEwOlJlcG9zaXRvcnk0NDgzODk0OQ==","name":"swift","full_name":"apple/swift","private":false,"owner":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apple/swift","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2018-09-27T22:12:15Z","pushed_at":"2018-09-27T23:06:31Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org","size":345005,"stargazers_count":45329,"watchers_count":45329,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7170,"mirror_url":null,"archived":false,"open_issues_count":387,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":7170,"open_issues":387,"watchers":45329,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/19579"},"html":{"href":"https://github.com/apple/swift/pull/19579"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/19579"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/19579/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/19579/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/19579/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/ca8b6621f21b9289ed9795a74df9c077bccb79a4"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"mhong"}}