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

Unified Diff: runtime/vm/compiler.cc

Issue 471283002: Runtime support for evaluation of static field initializer expressions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler.cc
===================================================================
--- runtime/vm/compiler.cc (revision 39381)
+++ runtime/vm/compiler.cc (working copy)
@@ -929,6 +929,39 @@
}
+RawObject* Compiler::EvaluateStaticInitializer(const Field& field) {
+ ASSERT(field.is_static());
+ // The VM sets the field's value to transiton_sentinel prior to
+ // evaluating the initializer value.
+ ASSERT(field.value() == Object::transition_sentinel().raw());
+ Isolate* isolate = Isolate::Current();
+ StackZone zone(isolate);
+ LongJumpScope jump;
+ if (setjmp(*jump.Set()) == 0) {
+ ParsedFunction* parsed_function =
+ Parser::ParseStaticFieldInitializer(field);
+
+ parsed_function->AllocateVariables();
+ // Non-optimized code generator.
+ CompileParsedFunctionHelper(parsed_function, false, Isolate::kNoDeoptId);
+
+ // Invoke the function to evaluate the expression.
+ const Function& initializer = parsed_function->function();
+ const Object& result = Object::Handle(
+ DartEntry::InvokeFunction(initializer, Object::empty_array()));
+ return result.raw();
+ } else {
+ const Error& error =
+ Error::Handle(isolate, isolate->object_store()->sticky_error());
+ isolate->object_store()->clear_sticky_error();
+ return error.raw();
+ }
+ UNREACHABLE();
+ return Object::null();
+}
+
+
+
RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) {
Isolate* isolate = Isolate::Current();
LongJumpScope jump;
@@ -959,7 +992,7 @@
// Manually generated AST, do not recompile.
func.SetIsOptimizable(false);
- // We compile the function here, even though InvokeStatic() below
+ // We compile the function here, even though InvokeFunction() below
// would compile func automatically. We are checking fewer invariants
// here.
ParsedFunction* parsed_function = new ParsedFunction(isolate, func);
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698