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

Unified Diff: runtime/vm/compiler.cc

Issue 2411823003: VM support for running Kernel binaries. (Closed)
Patch Set: Address initial review comments Created 4 years, 2 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/compiler.cc
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index 3972b3300fb0c256f9441fb07169b424d855b186..eb03452d03e847ee94545d878b52c8842a336099 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -16,6 +16,8 @@
#include "vm/dart_entry.h"
#include "vm/debugger.h"
#include "vm/deopt_instructions.h"
+#include "vm/dil.h"
+#include "vm/dil_to_il.h"
#include "vm/disassembler.h"
#include "vm/exceptions.h"
#include "vm/flags.h"
@@ -84,9 +86,20 @@ DECLARE_FLAG(bool, trace_irregexp);
#ifndef DART_PRECOMPILED_RUNTIME
+
+bool UseDilFrontEndFor(ParsedFunction* parsed_function) {
+ const Function& function = parsed_function->function();
+ return (function.dil_function() != kNoDilNode) ||
+ (function.kind() == RawFunction::kNoSuchMethodDispatcher) ||
+ (function.kind() == RawFunction::kInvokeFieldDispatcher);
+}
+
+
void DartCompilationPipeline::ParseFunction(ParsedFunction* parsed_function) {
- Parser::ParseFunction(parsed_function);
- parsed_function->AllocateVariables();
+ if (!UseDilFrontEndFor(parsed_function)) {
+ Parser::ParseFunction(parsed_function);
+ parsed_function->AllocateVariables();
+ }
}
@@ -95,7 +108,15 @@ FlowGraph* DartCompilationPipeline::BuildFlowGraph(
ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
intptr_t osr_id) {
- // Build the flow graph.
+ if (UseDilFrontEndFor(parsed_function)) {
+ dil::TreeNode* node = reinterpret_cast<dil::TreeNode*>(
+ parsed_function->function().dil_function());
+ dil::FlowGraphBuilder builder(
+ node, parsed_function, ic_data_array, NULL, osr_id);
+ FlowGraph* graph = builder.BuildGraph();
+ ASSERT(graph != NULL);
+ return graph;
+ }
FlowGraphBuilder builder(*parsed_function,
ic_data_array,
NULL, // NULL = not inlining.
@@ -1028,7 +1049,7 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
// the deoptimization path.
AllocationSinking* sinking = NULL;
if (FLAG_allocation_sinking &&
- (flow_graph->graph_entry()->SuccessorCount() == 1)) {
+ (flow_graph->graph_entry()->SuccessorCount() == 1)) {
NOT_IN_PRODUCT(TimelineDurationScope tds2(
thread(), compiler_timeline, "AllocationSinking::Optimize"));
// TODO(fschneider): Support allocation sinking with try-catch.
@@ -1704,11 +1725,43 @@ RawObject* Compiler::EvaluateStaticInitializer(const Field& field) {
}
)
- StackZone zone(thread);
- ParsedFunction* parsed_function =
- Parser::ParseStaticFieldInitializer(field);
+ StackZone _(thread);
rmacnak 2016/10/13 00:56:39 StackZone stack_zone(thread); Zone* zone = stack_z
Vyacheslav Egorov (Google) 2016/10/13 14:37:57 Done.
+ Zone* zone = thread->zone();
+ ParsedFunction* parsed_function;
+
+ // Create a one-time-use function to evaluate the initializer and invoke
+ // it immediately.
+ if (field.dil_field() != kNoDilNode) {
+ // kImplicitStaticFinalGetter is used for both implicit static getters
+ // and static initializers. The Kernel graph builder will tell the
+ // difference by pattern matching on the name.
+ const String& name = String::Handle(zone,
+ Symbols::FromConcat(thread,
+ Symbols::InitPrefix(), String::Handle(zone, field.name())));
+ const Script& script = Script::Handle(zone, field.Script());
+ Object& owner = Object::Handle(zone, field.Owner());
+ owner = PatchClass::New(Class::Cast(owner), script);
+ const Function& function = Function::ZoneHandle(zone,
+ Function::New(name,
+ RawFunction::kImplicitStaticFinalGetter,
+ true, // is_static
+ false, // is_const
+ false, // is_abstract
+ false, // is_external
+ false, // is_native
+ owner,
+ TokenPosition::kNoSource));
+ function.set_dil_function(field.dil_field());
+ function.set_result_type(AbstractType::Handle(zone, field.type()));
+ function.set_is_reflectable(false);
+ function.set_is_debuggable(false);
+ function.set_is_inlinable(false);
+ parsed_function = new(zone) ParsedFunction(thread, function);
+ } else {
+ parsed_function = Parser::ParseStaticFieldInitializer(field);
+ parsed_function->AllocateVariables();
+ }
- parsed_function->AllocateVariables();
// Non-optimized code generator.
DartCompilationPipeline pipeline;
CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId);
@@ -2165,6 +2218,12 @@ void BackgroundCompiler::EnsureInit(Thread* thread) {
#else // DART_PRECOMPILED_RUNTIME
+bool UseDilFrontEndFor(ParsedFunction* parsed_function) {
+ UNREACHABLE();
+ return false;
+}
+
+
CompilationPipeline* CompilationPipeline::New(Zone* zone,
const Function& function) {
UNREACHABLE();

Powered by Google App Engine
This is Rietveld 408576698