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

Unified Diff: runtime/vm/precompiler.cc

Issue 2453463006: Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."" (Closed)
Patch Set: 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
« no previous file with comments | « runtime/vm/precompiler.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/precompiler.cc
diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
index de1f3536e391dbdd84ff30d999390597e95790ae..6f57ab8ecd5bdc3f91f67b31c139a17ec9463de0 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,20 @@ 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_);
+ precompiler_->field_type_map());
}
+
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 +801,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 +1139,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 +1241,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 +1518,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 +2830,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 +2873,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 +3253,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 +3296,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,7 +3345,8 @@ 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) {
@@ -3340,7 +3356,7 @@ RawError* Precompiler::CompileFunction(Thread* thread,
ASSERT(FLAG_precompiled_mode);
const bool optimized = function.IsOptimizable(); // False for natives.
DartPrecompilationPipeline pipeline(zone, field_type_map);
- return PrecompileFunctionHelper(&pipeline, function, optimized);
+ return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized);
}
#endif // DART_PRECOMPILER
« no previous file with comments | « runtime/vm/precompiler.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698