Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: runtime/vm/parser.cc

Issue 1211273011: Added full deferred loading semantic to precompiled/--noopt/eager-loading code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: m Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index a966b40a639cb4b29aff9cba5fcb7ee7b033ca80..2a3ae02a498eed76a78c2b32e125f6387fef5894 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -38,15 +38,17 @@
namespace dart {
DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\".");
+DEFINE_FLAG(bool, enable_mirrors, true,
+ "Disable to make importing dart:mirrors an error.");
DEFINE_FLAG(bool, load_deferred_eagerly, false,
"Load deferred libraries eagerly.");
DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef.");
+
+DECLARE_FLAG(bool, lazy_dispatchers);
+DECLARE_FLAG(bool, load_deferred_eagerly);
DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
DECLARE_FLAG(bool, warn_on_javascript_compatibility);
-DEFINE_FLAG(bool, enable_mirrors, true,
- "Disable to make importing dart:mirrors an error.");
-DECLARE_FLAG(bool, lazy_dispatchers);
// Quick access to the current isolate and zone.
#define I (isolate())
@@ -10060,14 +10062,25 @@ AstNode* Parser::ThrowTypeError(intptr_t type_pos, const AbstractType& type) {
}
+// If 'prefix' is not NULL, then it will be passed to _throwNewIfNotLoaded.
AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos,
const Class& cls,
const String& function_name,
ArgumentListNode* function_arguments,
InvocationMirror::Call im_call,
InvocationMirror::Type im_type,
- const Function* func) {
+ const Function* func,
+ const LibraryPrefix* prefix) {
ArgumentListNode* arguments = new(Z) ArgumentListNode(call_pos);
+
+ String& method_name = String::Handle();
+ if (prefix == NULL) {
+ method_name = Library::PrivateCoreLibName(Symbols::ThrowNew()).raw();
+ } else {
+ arguments->Add(new(Z) LiteralNode(call_pos, *prefix));
+ method_name = Library::PrivateCoreLibName(
+ Symbols::ThrowNewIfNotLoaded()).raw();
+ }
// Object receiver.
// If the function is external and dynamic, pass the actual receiver,
// otherwise, pass a class literal of the unresolved method's owner.
@@ -10140,9 +10153,7 @@ AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos,
}
arguments->Add(new(Z) LiteralNode(call_pos, array));
- return MakeStaticCall(Symbols::NoSuchMethodError(),
- Library::PrivateCoreLibName(Symbols::ThrowNew()),
- arguments);
+ return MakeStaticCall(Symbols::NoSuchMethodError(), method_name, arguments);
}
@@ -11825,6 +11836,9 @@ AstNode* Parser::ResolveIdentInPrefixScope(intptr_t ident_pos,
if (parsed_function() != NULL) {
parsed_function()->AddDeferredPrefix(prefix);
hausner 2015/07/08 18:19:58 It's not necessary (or even wrong) to make code de
srdjan 2015/07/09 16:41:44 By adding '|| FLAG_load_deferred_eagerly' above as
}
+ if (FLAG_load_deferred_eagerly) {
+ obj = prefix.LookupObject(ident);
+ }
}
const bool is_deferred = prefix.is_deferred_load();
if (obj.IsNull()) {
@@ -13083,6 +13097,24 @@ AstNode* Parser::ParsePrimary() {
call_type,
NULL); // No existing function.
}
+ } else if (FLAG_load_deferred_eagerly && prefix.is_deferred_load()) {
+ // primary != NULL.
+ String& qualified_name = String::ZoneHandle(Z, prefix.name());
+ qualified_name = String::Concat(qualified_name, Symbols::Dot());
+ qualified_name = String::Concat(qualified_name, ident);
+ qualified_name = Symbols::New(qualified_name);
+ InvocationMirror::Type call_type =
+ CurrentToken() == Token::kLPAREN ?
+ InvocationMirror::kMethod : InvocationMirror::kGetter;
+ current_block_->statements->Add(ThrowNoSuchMethodError(
hausner 2015/07/08 18:19:58 Can you add a comment here that reminds that addin
srdjan 2015/07/09 16:41:44 Done.
+ qual_ident_pos,
+ current_class(),
+ qualified_name,
+ NULL, // No arguments.
+ InvocationMirror::kTopLevel,
+ call_type,
+ NULL, // No existing function.
+ &prefix));
}
}
ASSERT(primary != NULL);
« runtime/vm/object.cc ('K') | « runtime/vm/parser.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698