| Index: runtime/vm/precompiler.cc
|
| diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
|
| index de1f3536e391dbdd84ff30d999390597e95790ae..70e00a2e209d7cd745712f912c3635b80213835d 100644
|
| --- a/runtime/vm/precompiler.cc
|
| +++ b/runtime/vm/precompiler.cc
|
| @@ -152,9 +152,11 @@ class DartPrecompilationPipeline : public DartCompilationPipeline {
|
|
|
| class PrecompileParsedFunctionHelper : public ValueObject {
|
| public:
|
| - PrecompileParsedFunctionHelper(ParsedFunction* parsed_function,
|
| + PrecompileParsedFunctionHelper(Precompiler* precompiler,
|
| + ParsedFunction* parsed_function,
|
| bool optimized)
|
| - : parsed_function_(parsed_function),
|
| + : precompiler_(precompiler),
|
| + parsed_function_(parsed_function),
|
| optimized_(optimized),
|
| thread_(Thread::Current()) {
|
| }
|
| @@ -171,6 +173,7 @@ class PrecompileParsedFunctionHelper : public ValueObject {
|
| FlowGraphCompiler* graph_compiler,
|
| FlowGraph* flow_graph);
|
|
|
| + Precompiler* precompiler_;
|
| ParsedFunction* parsed_function_;
|
| const bool optimized_;
|
| Thread* const thread_;
|
| @@ -314,7 +317,8 @@ Precompiler::Precompiler(Thread* thread, bool reset_fields) :
|
| types_to_retain_(),
|
| consts_to_retain_(),
|
| field_type_map_(),
|
| - error_(Error::Handle()) {
|
| + error_(Error::Handle()),
|
| + get_runtime_type_is_unique_(false) {
|
| }
|
|
|
|
|
| @@ -483,9 +487,8 @@ void Precompiler::PrecompileStaticInitializers() {
|
| void Precompiler::PrecompileConstructors() {
|
| class ConstructorVisitor : public FunctionVisitor {
|
| public:
|
| - explicit ConstructorVisitor(Zone* zone, FieldTypeMap* map)
|
| - : zone_(zone), field_type_map_(map) {
|
| - ASSERT(map != NULL);
|
| + explicit ConstructorVisitor(Precompiler* precompiler, Zone* zone)
|
| + : precompiler_(precompiler), zone_(zone) {
|
| }
|
| void Visit(const Function& function) {
|
| if (!function.IsGenerativeConstructor()) return;
|
| @@ -497,18 +500,19 @@ void Precompiler::PrecompileConstructors() {
|
| if (FLAG_trace_precompiler) {
|
| THR_Print("Precompiling constructor %s\n", function.ToCString());
|
| }
|
| - CompileFunction(Thread::Current(),
|
| + CompileFunction(precompiler_,
|
| + Thread::Current(),
|
| zone_,
|
| - function,
|
| - field_type_map_);
|
| + function);
|
| }
|
| +
|
| private:
|
| + Precompiler* precompiler_;
|
| Zone* zone_;
|
| - FieldTypeMap* field_type_map_;
|
| };
|
|
|
| HANDLESCOPE(T);
|
| - ConstructorVisitor visitor(zone_, &field_type_map_);
|
| + ConstructorVisitor visitor(this, zone_);
|
| VisitFunctions(&visitor);
|
|
|
| FieldTypeMap::Iterator it(field_type_map_.GetIterator());
|
| @@ -796,7 +800,7 @@ void Precompiler::ProcessFunction(const Function& function) {
|
| ASSERT(!function.is_abstract());
|
| ASSERT(!function.IsRedirectingFactory());
|
|
|
| - error_ = CompileFunction(thread_, zone_, function);
|
| + error_ = CompileFunction(this, thread_, zone_, function);
|
| if (!error_.IsNull()) {
|
| Jump(error_);
|
| }
|
| @@ -1134,7 +1138,8 @@ RawFunction* Precompiler::CompileStaticInitializer(const Field& field,
|
|
|
| parsed_function->AllocateVariables();
|
| DartPrecompilationPipeline pipeline(zone.GetZone());
|
| - PrecompileParsedFunctionHelper helper(parsed_function,
|
| + PrecompileParsedFunctionHelper helper(/* precompiler = */ NULL,
|
| + parsed_function,
|
| /* optimized = */ true);
|
| bool success = helper.Compile(&pipeline);
|
| ASSERT(success);
|
| @@ -1235,7 +1240,8 @@ RawObject* Precompiler::ExecuteOnce(SequenceNode* fragment) {
|
|
|
| // Non-optimized code generator.
|
| DartPrecompilationPipeline pipeline(Thread::Current()->zone());
|
| - PrecompileParsedFunctionHelper helper(parsed_function,
|
| + PrecompileParsedFunctionHelper helper(/* precompiler = */ NULL,
|
| + parsed_function,
|
| /* optimized = */ false);
|
| helper.Compile(&pipeline);
|
| Code::Handle(func.unoptimized_code()).set_var_descriptors(
|
| @@ -1511,6 +1517,10 @@ void Precompiler::CollectDynamicFunctionNames() {
|
| }
|
| }
|
|
|
| + farray ^= table.GetOrNull(Symbols::GetRuntimeType());
|
| +
|
| + get_runtime_type_is_unique_ = !farray.IsNull() && (farray.Length() == 1);
|
| +
|
| if (FLAG_print_unique_targets) {
|
| UniqueFunctionsSet::Iterator unique_iter(&functions_set);
|
| while (unique_iter.MoveNext()) {
|
| @@ -2819,7 +2829,8 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
| caller_inline_id.Add(-1);
|
| CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer);
|
|
|
| - AotOptimizer optimizer(flow_graph,
|
| + AotOptimizer optimizer(precompiler_,
|
| + flow_graph,
|
| use_speculative_inlining,
|
| &inlining_black_list);
|
| optimizer.PopulateWithICData();
|
| @@ -2861,7 +2872,8 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
| &inline_id_to_token_pos,
|
| &caller_inline_id,
|
| use_speculative_inlining,
|
| - &inlining_black_list);
|
| + &inlining_black_list,
|
| + precompiler_);
|
| inliner.Inline();
|
| // Use lists are maintained and validated by the inliner.
|
| DEBUG_ASSERT(flow_graph->VerifyUseLists());
|
| @@ -3240,7 +3252,8 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
| }
|
|
|
|
|
| -static RawError* PrecompileFunctionHelper(CompilationPipeline* pipeline,
|
| +static RawError* PrecompileFunctionHelper(Precompiler* precompiler,
|
| + CompilationPipeline* pipeline,
|
| const Function& function,
|
| bool optimized) {
|
| // Check that we optimize, except if the function is not optimizable.
|
| @@ -3282,7 +3295,8 @@ static RawError* PrecompileFunctionHelper(CompilationPipeline* pipeline,
|
| num_tokens_after - num_tokens_before);
|
| }
|
|
|
| - PrecompileParsedFunctionHelper helper(parsed_function, optimized);
|
| + PrecompileParsedFunctionHelper helper(
|
| + precompiler, parsed_function, optimized);
|
| const bool success = helper.Compile(pipeline);
|
| if (!success) {
|
| // Encountered error.
|
| @@ -3330,17 +3344,18 @@ static RawError* PrecompileFunctionHelper(CompilationPipeline* pipeline,
|
| }
|
|
|
|
|
| -RawError* Precompiler::CompileFunction(Thread* thread,
|
| +RawError* Precompiler::CompileFunction(Precompiler* precompiler,
|
| + Thread* thread,
|
| Zone* zone,
|
| - const Function& function,
|
| - FieldTypeMap* field_type_map) {
|
| + const Function& function) {
|
| VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId);
|
| TIMELINE_FUNCTION_COMPILATION_DURATION(thread, "CompileFunction", function);
|
|
|
| ASSERT(FLAG_precompiled_mode);
|
| const bool optimized = function.IsOptimizable(); // False for natives.
|
| - DartPrecompilationPipeline pipeline(zone, field_type_map);
|
| - return PrecompileFunctionHelper(&pipeline, function, optimized);
|
| + DartPrecompilationPipeline pipeline(zone,
|
| + (precompiler != NULL) ? precompiler->field_type_map() : NULL);
|
| + return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized);
|
| }
|
|
|
| #endif // DART_PRECOMPILER
|
|
|