{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments/115577016","pull_request_review_id":37126949,"id":115577016,"diff_hunk":"@@ -9639,6 +9639,104 @@ namespace Js\n         return superCtor;\n     }\n \n+    Var JavascriptOperators::OP_ImportCall(__in JavascriptFunction *function, __in Var specifier, __in ScriptContext* scriptContext)\n+    {\n+        ModuleRecordBase *moduleRecordBase = nullptr;\n+        SourceTextModuleRecord *moduleRecord = nullptr;\n+\n+        FunctionBody* parentFuncBody = function->GetFunctionBody();\n+        JavascriptString *specifierString = nullptr;\n+\n+        try\n+        {\n+            specifierString = JavascriptConversion::ToString(specifier, scriptContext);\n+        }\n+        catch (const JavascriptException &err)\n+        {\n+            Var errorObject = err.GetAndClear()->GetThrownObject(scriptContext);\n+            AssertMsg(errorObject != nullptr, \"OP_ImportCall: null error object thrown by ToString(specifier)\");\n+            if (errorObject != nullptr)\n+            {\n+                return SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise(false, errorObject, scriptContext);\n+            }\n+\n+            Throw::InternalError();\n+        }\n+\n+        DWORD_PTR dwReferencingSourceContext = dwReferencingSourceContext = parentFuncBody->GetFunctionInfo()->GetFunctionProxy()->GetSourceContextInfo()->dwHostSourceContext;\n+        if (!parentFuncBody->IsES6ModuleCode() && dwReferencingSourceContext == Js::Constants::NoHostSourceContext)\n+        {\n+            // import() called from eval\n+            Assert(parentFuncBody->GetUtf8SourceInfo()->GetCallerUtf8SourceInfo() != nullptr);\n+            dwReferencingSourceContext = parentFuncBody->GetUtf8SourceInfo()->GetCallerUtf8SourceInfo()->GetSourceContextInfo()->dwHostSourceContext;\n+\n+            if (dwReferencingSourceContext == Js::Constants::NoHostSourceContext)\n+            {\n+                // Walk the call stack if caller function is neither module code nor having host source context\n+\n+                JavascriptFunction* caller = nullptr;\n+                Js::JavascriptStackWalker walker(scriptContext);\n+                walker.GetCaller(&caller);\n+\n+                do\n+                {\n+                    if (walker.GetCaller(&caller) && caller != nullptr && caller->IsScriptFunction())","path":"lib/Runtime/Language/JavascriptOperators.cpp","position":45,"original_position":45,"commit_id":"bae3e300043a65026096811a931402c3714fe61e","original_commit_id":"bae3e300043a65026096811a931402c3714fe61e","user":{"login":"akroshg","id":13008822,"avatar_url":"https://avatars0.githubusercontent.com/u/13008822?v=3","gravatar_id":"","url":"https://api.github.com/users/akroshg","html_url":"https://github.com/akroshg","followers_url":"https://api.github.com/users/akroshg/followers","following_url":"https://api.github.com/users/akroshg/following{/other_user}","gists_url":"https://api.github.com/users/akroshg/gists{/gist_id}","starred_url":"https://api.github.com/users/akroshg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akroshg/subscriptions","organizations_url":"https://api.github.com/users/akroshg/orgs","repos_url":"https://api.github.com/users/akroshg/repos","events_url":"https://api.github.com/users/akroshg/events{/privacy}","received_events_url":"https://api.github.com/users/akroshg/received_events","type":"User","site_admin":false},"body":"I couldn't find a scenario which involves the nested imports also dynamic->static->dynamic. sort of?\r\n\r\n---\r\nIn reply to: [115561112](https://github.com/Microsoft/ChakraCore/pull/2913#discussion_r115561112) [](ancestors = 115561112)","created_at":"2017-05-09T19:11:14Z","updated_at":"2017-05-09T19:11:14Z","html_url":"https://github.com/Microsoft/ChakraCore/pull/2913#discussion_r115577016","pull_request_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments/115577016"},"html":{"href":"https://github.com/Microsoft/ChakraCore/pull/2913#discussion_r115577016"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913","id":119021414,"html_url":"https://github.com/Microsoft/ChakraCore/pull/2913","diff_url":"https://github.com/Microsoft/ChakraCore/pull/2913.diff","patch_url":"https://github.com/Microsoft/ChakraCore/pull/2913.patch","issue_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/2913","number":2913,"state":"open","locked":false,"title":"Dynamic Module Import","user":{"login":"suwc","id":9597888,"avatar_url":"https://avatars0.githubusercontent.com/u/9597888?v=3","gravatar_id":"","url":"https://api.github.com/users/suwc","html_url":"https://github.com/suwc","followers_url":"https://api.github.com/users/suwc/followers","following_url":"https://api.github.com/users/suwc/following{/other_user}","gists_url":"https://api.github.com/users/suwc/gists{/gist_id}","starred_url":"https://api.github.com/users/suwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suwc/subscriptions","organizations_url":"https://api.github.com/users/suwc/orgs","repos_url":"https://api.github.com/users/suwc/repos","events_url":"https://api.github.com/users/suwc/events{/privacy}","received_events_url":"https://api.github.com/users/suwc/received_events","type":"User","site_admin":false},"body":"This PR adds support for `import()` dynamic module import sematic.\r\n\r\nPer https://github.com/tc39/proposal-dynamic-import:\r\n\r\n\"A call to `import(specifier)` returns a promise for the module namespace object of the requested module, which is created after fetching, instantiating, and evaluating all of the module's dependencies, as well as the module itself.\r\n\r\n\"Here specifier will be interpreted the same way as in an import declaration (i.e., the same strings will work in both places). However, while specifier is a string it is not necessarily a string literal; thus code like import(`./language-packs/${navigator.language}.js`) will work—something impossible to accomplish with the usual import declarations.\r\n\r\n\"`import()` is proposed to work in both scripts and modules. This gives script code an easy asynchronous entry point into the module world, allowing it to start running module code.\"\r\n\r\nThis PR includes following changes:\r\n\t- Update parser and bytecode generator to support `import()` sematic in module and in script\r\n\t- Add new bytecode `ImportCall`\r\n\t- Add runtime function for `import()` that:\r\n\t\t○ Uses caller from stack to look up module record or source context that are associated with the module or script from which `import()` is called\r\n\t\t○ Requests host to load target module source file (gets module record in return)\r\n\t\t○ Creates promise unless the module record has one\r\n\t\t○ Resolves/rejects promise if appropriates\r\n\t\t○ Returns promise\r\n\t- Add new host callback (`FetchImportedModuleFromScript`) for fetching imported module from script (accepts source context)\r\n\t- Add `promiseCapability` field to module record class\r\n\t- Update `SourceTextModuleRecord`'s methods to accept callback from host and to handle dynamically imported module and its promise capability\r\n\t- Update exception checks and assertions to cover new usage scenario of importing and evaluating module code with active script\r\nAdd unit tests for dynamic import functionality\r\n","created_at":"2017-05-04T17:04:17Z","updated_at":"2017-05-09T19:11:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"155d849f2ad7b204398a969e845bd925c946859d","assignee":{"login":"suwc","id":9597888,"avatar_url":"https://avatars0.githubusercontent.com/u/9597888?v=3","gravatar_id":"","url":"https://api.github.com/users/suwc","html_url":"https://github.com/suwc","followers_url":"https://api.github.com/users/suwc/followers","following_url":"https://api.github.com/users/suwc/following{/other_user}","gists_url":"https://api.github.com/users/suwc/gists{/gist_id}","starred_url":"https://api.github.com/users/suwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suwc/subscriptions","organizations_url":"https://api.github.com/users/suwc/orgs","repos_url":"https://api.github.com/users/suwc/repos","events_url":"https://api.github.com/users/suwc/events{/privacy}","received_events_url":"https://api.github.com/users/suwc/received_events","type":"User","site_admin":false},"assignees":[{"login":"suwc","id":9597888,"avatar_url":"https://avatars0.githubusercontent.com/u/9597888?v=3","gravatar_id":"","url":"https://api.github.com/users/suwc","html_url":"https://github.com/suwc","followers_url":"https://api.github.com/users/suwc/followers","following_url":"https://api.github.com/users/suwc/following{/other_user}","gists_url":"https://api.github.com/users/suwc/gists{/gist_id}","starred_url":"https://api.github.com/users/suwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suwc/subscriptions","organizations_url":"https://api.github.com/users/suwc/orgs","repos_url":"https://api.github.com/users/suwc/repos","events_url":"https://api.github.com/users/suwc/events{/privacy}","received_events_url":"https://api.github.com/users/suwc/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"pleath","id":15825988,"avatar_url":"https://avatars3.githubusercontent.com/u/15825988?v=3","gravatar_id":"","url":"https://api.github.com/users/pleath","html_url":"https://github.com/pleath","followers_url":"https://api.github.com/users/pleath/followers","following_url":"https://api.github.com/users/pleath/following{/other_user}","gists_url":"https://api.github.com/users/pleath/gists{/gist_id}","starred_url":"https://api.github.com/users/pleath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pleath/subscriptions","organizations_url":"https://api.github.com/users/pleath/orgs","repos_url":"https://api.github.com/users/pleath/repos","events_url":"https://api.github.com/users/pleath/events{/privacy}","received_events_url":"https://api.github.com/users/pleath/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913/commits","review_comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913/comments","review_comment_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/2913/comments","statuses_url":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/bae3e300043a65026096811a931402c3714fe61e","head":{"label":"suwc:build/suwc/buddy","ref":"build/suwc/buddy","sha":"bae3e300043a65026096811a931402c3714fe61e","user":{"login":"suwc","id":9597888,"avatar_url":"https://avatars0.githubusercontent.com/u/9597888?v=3","gravatar_id":"","url":"https://api.github.com/users/suwc","html_url":"https://github.com/suwc","followers_url":"https://api.github.com/users/suwc/followers","following_url":"https://api.github.com/users/suwc/following{/other_user}","gists_url":"https://api.github.com/users/suwc/gists{/gist_id}","starred_url":"https://api.github.com/users/suwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suwc/subscriptions","organizations_url":"https://api.github.com/users/suwc/orgs","repos_url":"https://api.github.com/users/suwc/repos","events_url":"https://api.github.com/users/suwc/events{/privacy}","received_events_url":"https://api.github.com/users/suwc/received_events","type":"User","site_admin":false},"repo":{"id":61909858,"name":"ChakraCore","full_name":"suwc/ChakraCore","owner":{"login":"suwc","id":9597888,"avatar_url":"https://avatars0.githubusercontent.com/u/9597888?v=3","gravatar_id":"","url":"https://api.github.com/users/suwc","html_url":"https://github.com/suwc","followers_url":"https://api.github.com/users/suwc/followers","following_url":"https://api.github.com/users/suwc/following{/other_user}","gists_url":"https://api.github.com/users/suwc/gists{/gist_id}","starred_url":"https://api.github.com/users/suwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suwc/subscriptions","organizations_url":"https://api.github.com/users/suwc/orgs","repos_url":"https://api.github.com/users/suwc/repos","events_url":"https://api.github.com/users/suwc/events{/privacy}","received_events_url":"https://api.github.com/users/suwc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/suwc/ChakraCore","description":"ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge","fork":true,"url":"https://api.github.com/repos/suwc/ChakraCore","forks_url":"https://api.github.com/repos/suwc/ChakraCore/forks","keys_url":"https://api.github.com/repos/suwc/ChakraCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/suwc/ChakraCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/suwc/ChakraCore/teams","hooks_url":"https://api.github.com/repos/suwc/ChakraCore/hooks","issue_events_url":"https://api.github.com/repos/suwc/ChakraCore/issues/events{/number}","events_url":"https://api.github.com/repos/suwc/ChakraCore/events","assignees_url":"https://api.github.com/repos/suwc/ChakraCore/assignees{/user}","branches_url":"https://api.github.com/repos/suwc/ChakraCore/branches{/branch}","tags_url":"https://api.github.com/repos/suwc/ChakraCore/tags","blobs_url":"https://api.github.com/repos/suwc/ChakraCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/suwc/ChakraCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/suwc/ChakraCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/suwc/ChakraCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/suwc/ChakraCore/statuses/{sha}","languages_url":"https://api.github.com/repos/suwc/ChakraCore/languages","stargazers_url":"https://api.github.com/repos/suwc/ChakraCore/stargazers","contributors_url":"https://api.github.com/repos/suwc/ChakraCore/contributors","subscribers_url":"https://api.github.com/repos/suwc/ChakraCore/subscribers","subscription_url":"https://api.github.com/repos/suwc/ChakraCore/subscription","commits_url":"https://api.github.com/repos/suwc/ChakraCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/suwc/ChakraCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/suwc/ChakraCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/suwc/ChakraCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/suwc/ChakraCore/contents/{+path}","compare_url":"https://api.github.com/repos/suwc/ChakraCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/suwc/ChakraCore/merges","archive_url":"https://api.github.com/repos/suwc/ChakraCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/suwc/ChakraCore/downloads","issues_url":"https://api.github.com/repos/suwc/ChakraCore/issues{/number}","pulls_url":"https://api.github.com/repos/suwc/ChakraCore/pulls{/number}","milestones_url":"https://api.github.com/repos/suwc/ChakraCore/milestones{/number}","notifications_url":"https://api.github.com/repos/suwc/ChakraCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/suwc/ChakraCore/labels{/name}","releases_url":"https://api.github.com/repos/suwc/ChakraCore/releases{/id}","deployments_url":"https://api.github.com/repos/suwc/ChakraCore/deployments","created_at":"2016-06-24T20:11:50Z","updated_at":"2016-06-24T20:12:09Z","pushed_at":"2017-05-09T17:51:56Z","git_url":"git://github.com/suwc/ChakraCore.git","ssh_url":"git@github.com:suwc/ChakraCore.git","clone_url":"https://github.com/suwc/ChakraCore.git","svn_url":"https://github.com/suwc/ChakraCore","homepage":null,"size":64085,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"12912e6f20b26a5c805ee412f53597c29305d4f4","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":49086513,"name":"ChakraCore","full_name":"Microsoft/ChakraCore","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/ChakraCore","description":"ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge","fork":false,"url":"https://api.github.com/repos/Microsoft/ChakraCore","forks_url":"https://api.github.com/repos/Microsoft/ChakraCore/forks","keys_url":"https://api.github.com/repos/Microsoft/ChakraCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/ChakraCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/ChakraCore/teams","hooks_url":"https://api.github.com/repos/Microsoft/ChakraCore/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/ChakraCore/events","assignees_url":"https://api.github.com/repos/Microsoft/ChakraCore/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/ChakraCore/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/ChakraCore/tags","blobs_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/ChakraCore/languages","stargazers_url":"https://api.github.com/repos/Microsoft/ChakraCore/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/ChakraCore/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/ChakraCore/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/ChakraCore/subscription","commits_url":"https://api.github.com/repos/Microsoft/ChakraCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/ChakraCore/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/ChakraCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/ChakraCore/merges","archive_url":"https://api.github.com/repos/Microsoft/ChakraCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/ChakraCore/downloads","issues_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/ChakraCore/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/ChakraCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/ChakraCore/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/ChakraCore/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/ChakraCore/deployments","created_at":"2016-01-05T19:05:31Z","updated_at":"2017-05-09T03:09:43Z","pushed_at":"2017-05-09T18:16:11Z","git_url":"git://github.com/Microsoft/ChakraCore.git","ssh_url":"git@github.com:Microsoft/ChakraCore.git","clone_url":"https://github.com/Microsoft/ChakraCore.git","svn_url":"https://github.com/Microsoft/ChakraCore","homepage":"","size":65113,"stargazers_count":6174,"watchers_count":6174,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":734,"mirror_url":null,"open_issues_count":290,"forks":734,"open_issues":290,"watchers":6174,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913"},"html":{"href":"https://github.com/Microsoft/ChakraCore/pull/2913"},"issue":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/issues/2913"},"comments":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/issues/2913/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/2913/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/bae3e300043a65026096811a931402c3714fe61e"}}}}
{"actor":{"display_login":"akroshg"}}