| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/precompiler.h" | 5 #include "vm/precompiler.h" |
| 6 | 6 |
| 7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 Zone* zone_; | 147 Zone* zone_; |
| 148 CompileType result_type_; | 148 CompileType result_type_; |
| 149 FieldTypeMap* field_map_; | 149 FieldTypeMap* field_map_; |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 | 152 |
| 153 class PrecompileParsedFunctionHelper : public ValueObject { | 153 class PrecompileParsedFunctionHelper : public ValueObject { |
| 154 public: | 154 public: |
| 155 PrecompileParsedFunctionHelper(ParsedFunction* parsed_function, | 155 PrecompileParsedFunctionHelper(Precompiler* precompiler, |
| 156 ParsedFunction* parsed_function, |
| 156 bool optimized) | 157 bool optimized) |
| 157 : parsed_function_(parsed_function), | 158 : precompiler_(precompiler), |
| 159 parsed_function_(parsed_function), |
| 158 optimized_(optimized), | 160 optimized_(optimized), |
| 159 thread_(Thread::Current()) { | 161 thread_(Thread::Current()) { |
| 160 } | 162 } |
| 161 | 163 |
| 162 bool Compile(CompilationPipeline* pipeline); | 164 bool Compile(CompilationPipeline* pipeline); |
| 163 | 165 |
| 164 private: | 166 private: |
| 165 ParsedFunction* parsed_function() const { return parsed_function_; } | 167 ParsedFunction* parsed_function() const { return parsed_function_; } |
| 166 bool optimized() const { return optimized_; } | 168 bool optimized() const { return optimized_; } |
| 167 Thread* thread() const { return thread_; } | 169 Thread* thread() const { return thread_; } |
| 168 Isolate* isolate() const { return thread_->isolate(); } | 170 Isolate* isolate() const { return thread_->isolate(); } |
| 169 | 171 |
| 170 void FinalizeCompilation(Assembler* assembler, | 172 void FinalizeCompilation(Assembler* assembler, |
| 171 FlowGraphCompiler* graph_compiler, | 173 FlowGraphCompiler* graph_compiler, |
| 172 FlowGraph* flow_graph); | 174 FlowGraph* flow_graph); |
| 173 | 175 |
| 176 Precompiler* precompiler_; |
| 174 ParsedFunction* parsed_function_; | 177 ParsedFunction* parsed_function_; |
| 175 const bool optimized_; | 178 const bool optimized_; |
| 176 Thread* const thread_; | 179 Thread* const thread_; |
| 177 | 180 |
| 178 DISALLOW_COPY_AND_ASSIGN(PrecompileParsedFunctionHelper); | 181 DISALLOW_COPY_AND_ASSIGN(PrecompileParsedFunctionHelper); |
| 179 }; | 182 }; |
| 180 | 183 |
| 181 | 184 |
| 182 static void Jump(const Error& error) { | 185 static void Jump(const Error& error) { |
| 183 Thread::Current()->long_jump_base()->Jump(1, error); | 186 Thread::Current()->long_jump_base()->Jump(1, error); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 GrowableObjectArray::Handle(GrowableObjectArray::New())), | 310 GrowableObjectArray::Handle(GrowableObjectArray::New())), |
| 308 sent_selectors_(), | 311 sent_selectors_(), |
| 309 enqueued_functions_(), | 312 enqueued_functions_(), |
| 310 fields_to_retain_(), | 313 fields_to_retain_(), |
| 311 functions_to_retain_(), | 314 functions_to_retain_(), |
| 312 classes_to_retain_(), | 315 classes_to_retain_(), |
| 313 typeargs_to_retain_(), | 316 typeargs_to_retain_(), |
| 314 types_to_retain_(), | 317 types_to_retain_(), |
| 315 consts_to_retain_(), | 318 consts_to_retain_(), |
| 316 field_type_map_(), | 319 field_type_map_(), |
| 317 error_(Error::Handle()) { | 320 error_(Error::Handle()), |
| 321 get_runtime_type_is_unique_(false) { |
| 318 } | 322 } |
| 319 | 323 |
| 320 | 324 |
| 321 void Precompiler::DoCompileAll( | 325 void Precompiler::DoCompileAll( |
| 322 Dart_QualifiedFunctionName embedder_entry_points[]) { | 326 Dart_QualifiedFunctionName embedder_entry_points[]) { |
| 323 ASSERT(I->compilation_allowed()); | 327 ASSERT(I->compilation_allowed()); |
| 324 | 328 |
| 325 { | 329 { |
| 326 StackZone stack_zone(T); | 330 StackZone stack_zone(T); |
| 327 zone_ = stack_zone.GetZone(); | 331 zone_ = stack_zone.GetZone(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 480 |
| 477 HANDLESCOPE(T); | 481 HANDLESCOPE(T); |
| 478 StaticInitializerVisitor visitor(Z); | 482 StaticInitializerVisitor visitor(Z); |
| 479 VisitClasses(&visitor); | 483 VisitClasses(&visitor); |
| 480 } | 484 } |
| 481 | 485 |
| 482 | 486 |
| 483 void Precompiler::PrecompileConstructors() { | 487 void Precompiler::PrecompileConstructors() { |
| 484 class ConstructorVisitor : public FunctionVisitor { | 488 class ConstructorVisitor : public FunctionVisitor { |
| 485 public: | 489 public: |
| 486 explicit ConstructorVisitor(Zone* zone, FieldTypeMap* map) | 490 explicit ConstructorVisitor(Precompiler* precompiler, Zone* zone) |
| 487 : zone_(zone), field_type_map_(map) { | 491 : precompiler_(precompiler), zone_(zone) { |
| 488 ASSERT(map != NULL); | |
| 489 } | 492 } |
| 490 void Visit(const Function& function) { | 493 void Visit(const Function& function) { |
| 491 if (!function.IsGenerativeConstructor()) return; | 494 if (!function.IsGenerativeConstructor()) return; |
| 492 if (function.HasCode()) { | 495 if (function.HasCode()) { |
| 493 // Const constructors may have been visited before. Recompile them here | 496 // Const constructors may have been visited before. Recompile them here |
| 494 // to collect type information for final fields for them as well. | 497 // to collect type information for final fields for them as well. |
| 495 function.ClearCode(); | 498 function.ClearCode(); |
| 496 } | 499 } |
| 497 if (FLAG_trace_precompiler) { | 500 if (FLAG_trace_precompiler) { |
| 498 THR_Print("Precompiling constructor %s\n", function.ToCString()); | 501 THR_Print("Precompiling constructor %s\n", function.ToCString()); |
| 499 } | 502 } |
| 500 CompileFunction(Thread::Current(), | 503 CompileFunction(precompiler_, |
| 504 Thread::Current(), |
| 501 zone_, | 505 zone_, |
| 502 function, | 506 function, |
| 503 field_type_map_); | 507 precompiler_->field_type_map()); |
| 504 } | 508 } |
| 509 |
| 505 private: | 510 private: |
| 511 Precompiler* precompiler_; |
| 506 Zone* zone_; | 512 Zone* zone_; |
| 507 FieldTypeMap* field_type_map_; | |
| 508 }; | 513 }; |
| 509 | 514 |
| 510 HANDLESCOPE(T); | 515 HANDLESCOPE(T); |
| 511 ConstructorVisitor visitor(zone_, &field_type_map_); | 516 ConstructorVisitor visitor(this, zone_); |
| 512 VisitFunctions(&visitor); | 517 VisitFunctions(&visitor); |
| 513 | 518 |
| 514 FieldTypeMap::Iterator it(field_type_map_.GetIterator()); | 519 FieldTypeMap::Iterator it(field_type_map_.GetIterator()); |
| 515 for (FieldTypePair* current = it.Next(); | 520 for (FieldTypePair* current = it.Next(); |
| 516 current != NULL; | 521 current != NULL; |
| 517 current = it.Next()) { | 522 current = it.Next()) { |
| 518 const intptr_t cid = current->cid_; | 523 const intptr_t cid = current->cid_; |
| 519 current->field_->set_guarded_cid(cid); | 524 current->field_->set_guarded_cid(cid); |
| 520 current->field_->set_is_nullable(cid == kNullCid || cid == kDynamicCid); | 525 current->field_->set_is_nullable(cid == kNullCid || cid == kDynamicCid); |
| 521 if (FLAG_trace_precompiler) { | 526 if (FLAG_trace_precompiler) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 THR_Print("Precompiling %" Pd " %s (%s, %s)\n", | 794 THR_Print("Precompiling %" Pd " %s (%s, %s)\n", |
| 790 function_count_, | 795 function_count_, |
| 791 function.ToLibNamePrefixedQualifiedCString(), | 796 function.ToLibNamePrefixedQualifiedCString(), |
| 792 function.token_pos().ToCString(), | 797 function.token_pos().ToCString(), |
| 793 Function::KindToCString(function.kind())); | 798 Function::KindToCString(function.kind())); |
| 794 } | 799 } |
| 795 | 800 |
| 796 ASSERT(!function.is_abstract()); | 801 ASSERT(!function.is_abstract()); |
| 797 ASSERT(!function.IsRedirectingFactory()); | 802 ASSERT(!function.IsRedirectingFactory()); |
| 798 | 803 |
| 799 error_ = CompileFunction(thread_, zone_, function); | 804 error_ = CompileFunction(this, thread_, zone_, function); |
| 800 if (!error_.IsNull()) { | 805 if (!error_.IsNull()) { |
| 801 Jump(error_); | 806 Jump(error_); |
| 802 } | 807 } |
| 803 // Used in the JIT to save type-feedback across compilations. | 808 // Used in the JIT to save type-feedback across compilations. |
| 804 function.ClearICDataArray(); | 809 function.ClearICDataArray(); |
| 805 } else { | 810 } else { |
| 806 if (FLAG_trace_precompiler) { | 811 if (FLAG_trace_precompiler) { |
| 807 // This function was compiled from somewhere other than Precompiler, | 812 // This function was compiled from somewhere other than Precompiler, |
| 808 // such as const constructors compiled by the parser. | 813 // such as const constructors compiled by the parser. |
| 809 THR_Print("Already has code: %s (%s, %s)\n", | 814 THR_Print("Already has code: %s (%s, %s)\n", |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 RawFunction* Precompiler::CompileStaticInitializer(const Field& field, | 1132 RawFunction* Precompiler::CompileStaticInitializer(const Field& field, |
| 1128 bool compute_type) { | 1133 bool compute_type) { |
| 1129 ASSERT(field.is_static()); | 1134 ASSERT(field.is_static()); |
| 1130 Thread* thread = Thread::Current(); | 1135 Thread* thread = Thread::Current(); |
| 1131 StackZone zone(thread); | 1136 StackZone zone(thread); |
| 1132 | 1137 |
| 1133 ParsedFunction* parsed_function = Parser::ParseStaticFieldInitializer(field); | 1138 ParsedFunction* parsed_function = Parser::ParseStaticFieldInitializer(field); |
| 1134 | 1139 |
| 1135 parsed_function->AllocateVariables(); | 1140 parsed_function->AllocateVariables(); |
| 1136 DartPrecompilationPipeline pipeline(zone.GetZone()); | 1141 DartPrecompilationPipeline pipeline(zone.GetZone()); |
| 1137 PrecompileParsedFunctionHelper helper(parsed_function, | 1142 PrecompileParsedFunctionHelper helper(/* precompiler = */ NULL, |
| 1143 parsed_function, |
| 1138 /* optimized = */ true); | 1144 /* optimized = */ true); |
| 1139 bool success = helper.Compile(&pipeline); | 1145 bool success = helper.Compile(&pipeline); |
| 1140 ASSERT(success); | 1146 ASSERT(success); |
| 1141 | 1147 |
| 1142 if (compute_type && field.is_final()) { | 1148 if (compute_type && field.is_final()) { |
| 1143 intptr_t result_cid = pipeline.result_type().ToCid(); | 1149 intptr_t result_cid = pipeline.result_type().ToCid(); |
| 1144 if (result_cid != kDynamicCid) { | 1150 if (result_cid != kDynamicCid) { |
| 1145 if (FLAG_trace_precompiler && FLAG_support_il_printer) { | 1151 if (FLAG_trace_precompiler && FLAG_support_il_printer) { |
| 1146 THR_Print("Setting guarded_cid of %s to %s\n", field.ToCString(), | 1152 THR_Print("Setting guarded_cid of %s to %s\n", field.ToCString(), |
| 1147 pipeline.result_type().ToCString()); | 1153 pipeline.result_type().ToCString()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 // here. | 1234 // here. |
| 1229 ParsedFunction* parsed_function = new ParsedFunction(thread, func); | 1235 ParsedFunction* parsed_function = new ParsedFunction(thread, func); |
| 1230 parsed_function->SetNodeSequence(fragment); | 1236 parsed_function->SetNodeSequence(fragment); |
| 1231 fragment->scope()->AddVariable(parsed_function->EnsureExpressionTemp()); | 1237 fragment->scope()->AddVariable(parsed_function->EnsureExpressionTemp()); |
| 1232 fragment->scope()->AddVariable( | 1238 fragment->scope()->AddVariable( |
| 1233 parsed_function->current_context_var()); | 1239 parsed_function->current_context_var()); |
| 1234 parsed_function->AllocateVariables(); | 1240 parsed_function->AllocateVariables(); |
| 1235 | 1241 |
| 1236 // Non-optimized code generator. | 1242 // Non-optimized code generator. |
| 1237 DartPrecompilationPipeline pipeline(Thread::Current()->zone()); | 1243 DartPrecompilationPipeline pipeline(Thread::Current()->zone()); |
| 1238 PrecompileParsedFunctionHelper helper(parsed_function, | 1244 PrecompileParsedFunctionHelper helper(/* precompiler = */ NULL, |
| 1245 parsed_function, |
| 1239 /* optimized = */ false); | 1246 /* optimized = */ false); |
| 1240 helper.Compile(&pipeline); | 1247 helper.Compile(&pipeline); |
| 1241 Code::Handle(func.unoptimized_code()).set_var_descriptors( | 1248 Code::Handle(func.unoptimized_code()).set_var_descriptors( |
| 1242 Object::empty_var_descriptors()); | 1249 Object::empty_var_descriptors()); |
| 1243 | 1250 |
| 1244 const Object& result = PassiveObject::Handle( | 1251 const Object& result = PassiveObject::Handle( |
| 1245 DartEntry::InvokeFunction(func, Object::empty_array())); | 1252 DartEntry::InvokeFunction(func, Object::empty_array())); |
| 1246 return result.raw(); | 1253 return result.raw(); |
| 1247 } else { | 1254 } else { |
| 1248 Thread* const thread = Thread::Current(); | 1255 Thread* const thread = Thread::Current(); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 key ^= table.GetKey(curr_key); | 1511 key ^= table.GetKey(curr_key); |
| 1505 farray ^= table.GetOrNull(key); | 1512 farray ^= table.GetOrNull(key); |
| 1506 ASSERT(!farray.IsNull()); | 1513 ASSERT(!farray.IsNull()); |
| 1507 if (farray.Length() == 1) { | 1514 if (farray.Length() == 1) { |
| 1508 function ^= farray.At(0); | 1515 function ^= farray.At(0); |
| 1509 cls = function.Owner(); | 1516 cls = function.Owner(); |
| 1510 functions_set.Insert(function); | 1517 functions_set.Insert(function); |
| 1511 } | 1518 } |
| 1512 } | 1519 } |
| 1513 | 1520 |
| 1521 farray ^= table.GetOrNull(Symbols::GetRuntimeType()); |
| 1522 |
| 1523 get_runtime_type_is_unique_ = !farray.IsNull() && (farray.Length() == 1); |
| 1524 |
| 1514 if (FLAG_print_unique_targets) { | 1525 if (FLAG_print_unique_targets) { |
| 1515 UniqueFunctionsSet::Iterator unique_iter(&functions_set); | 1526 UniqueFunctionsSet::Iterator unique_iter(&functions_set); |
| 1516 while (unique_iter.MoveNext()) { | 1527 while (unique_iter.MoveNext()) { |
| 1517 intptr_t curr_key = unique_iter.Current(); | 1528 intptr_t curr_key = unique_iter.Current(); |
| 1518 function ^= functions_set.GetKey(curr_key); | 1529 function ^= functions_set.GetKey(curr_key); |
| 1519 THR_Print("* %s\n", function.ToQualifiedCString()); | 1530 THR_Print("* %s\n", function.ToQualifiedCString()); |
| 1520 } | 1531 } |
| 1521 THR_Print("%" Pd " of %" Pd " dynamic selectors are unique\n", | 1532 THR_Print("%" Pd " of %" Pd " dynamic selectors are unique\n", |
| 1522 functions_set.NumOccupied(), table.NumOccupied()); | 1533 functions_set.NumOccupied(), table.NumOccupied()); |
| 1523 } | 1534 } |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2812 // We do not add the token position now because we don't know the | 2823 // We do not add the token position now because we don't know the |
| 2813 // position of the inlined call until later. A side effect of this | 2824 // position of the inlined call until later. A side effect of this |
| 2814 // is that the length of |inline_id_to_function| is always larger | 2825 // is that the length of |inline_id_to_function| is always larger |
| 2815 // than the length of |inline_id_to_token_pos| by one. | 2826 // than the length of |inline_id_to_token_pos| by one. |
| 2816 // Top scope function has no caller (-1). We do this because we expect | 2827 // Top scope function has no caller (-1). We do this because we expect |
| 2817 // all token positions to be at an inlined call. | 2828 // all token positions to be at an inlined call. |
| 2818 // Top scope function has no caller (-1). | 2829 // Top scope function has no caller (-1). |
| 2819 caller_inline_id.Add(-1); | 2830 caller_inline_id.Add(-1); |
| 2820 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); | 2831 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); |
| 2821 | 2832 |
| 2822 AotOptimizer optimizer(flow_graph, | 2833 AotOptimizer optimizer(precompiler_, |
| 2834 flow_graph, |
| 2823 use_speculative_inlining, | 2835 use_speculative_inlining, |
| 2824 &inlining_black_list); | 2836 &inlining_black_list); |
| 2825 optimizer.PopulateWithICData(); | 2837 optimizer.PopulateWithICData(); |
| 2826 | 2838 |
| 2827 optimizer.ApplyClassIds(); | 2839 optimizer.ApplyClassIds(); |
| 2828 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2840 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2829 | 2841 |
| 2830 FlowGraphTypePropagator::Propagate(flow_graph); | 2842 FlowGraphTypePropagator::Propagate(flow_graph); |
| 2831 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2843 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2832 | 2844 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2854 | 2866 |
| 2855 // Use propagated class-ids to create more inlining opportunities. | 2867 // Use propagated class-ids to create more inlining opportunities. |
| 2856 optimizer.ApplyClassIds(); | 2868 optimizer.ApplyClassIds(); |
| 2857 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2869 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2858 | 2870 |
| 2859 FlowGraphInliner inliner(flow_graph, | 2871 FlowGraphInliner inliner(flow_graph, |
| 2860 &inline_id_to_function, | 2872 &inline_id_to_function, |
| 2861 &inline_id_to_token_pos, | 2873 &inline_id_to_token_pos, |
| 2862 &caller_inline_id, | 2874 &caller_inline_id, |
| 2863 use_speculative_inlining, | 2875 use_speculative_inlining, |
| 2864 &inlining_black_list); | 2876 &inlining_black_list, |
| 2877 precompiler_); |
| 2865 inliner.Inline(); | 2878 inliner.Inline(); |
| 2866 // Use lists are maintained and validated by the inliner. | 2879 // Use lists are maintained and validated by the inliner. |
| 2867 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2880 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2868 } | 2881 } |
| 2869 | 2882 |
| 2870 // Propagate types and eliminate more type tests. | 2883 // Propagate types and eliminate more type tests. |
| 2871 FlowGraphTypePropagator::Propagate(flow_graph); | 2884 FlowGraphTypePropagator::Propagate(flow_graph); |
| 2872 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2885 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2873 | 2886 |
| 2874 { | 2887 { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3233 } | 3246 } |
| 3234 is_compiled = false; | 3247 is_compiled = false; |
| 3235 } | 3248 } |
| 3236 // Reset global isolate state. | 3249 // Reset global isolate state. |
| 3237 thread()->set_deopt_id(prev_deopt_id); | 3250 thread()->set_deopt_id(prev_deopt_id); |
| 3238 } | 3251 } |
| 3239 return is_compiled; | 3252 return is_compiled; |
| 3240 } | 3253 } |
| 3241 | 3254 |
| 3242 | 3255 |
| 3243 static RawError* PrecompileFunctionHelper(CompilationPipeline* pipeline, | 3256 static RawError* PrecompileFunctionHelper(Precompiler* precompiler, |
| 3257 CompilationPipeline* pipeline, |
| 3244 const Function& function, | 3258 const Function& function, |
| 3245 bool optimized) { | 3259 bool optimized) { |
| 3246 // Check that we optimize, except if the function is not optimizable. | 3260 // Check that we optimize, except if the function is not optimizable. |
| 3247 ASSERT(FLAG_precompiled_mode); | 3261 ASSERT(FLAG_precompiled_mode); |
| 3248 ASSERT(!function.IsOptimizable() || optimized); | 3262 ASSERT(!function.IsOptimizable() || optimized); |
| 3249 ASSERT(!function.HasCode()); | 3263 ASSERT(!function.HasCode()); |
| 3250 LongJumpScope jump; | 3264 LongJumpScope jump; |
| 3251 if (setjmp(*jump.Set()) == 0) { | 3265 if (setjmp(*jump.Set()) == 0) { |
| 3252 Thread* const thread = Thread::Current(); | 3266 Thread* const thread = Thread::Current(); |
| 3253 StackZone stack_zone(thread); | 3267 StackZone stack_zone(thread); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3275 { | 3289 { |
| 3276 HANDLESCOPE(thread); | 3290 HANDLESCOPE(thread); |
| 3277 const int64_t num_tokens_before = STAT_VALUE(thread, num_tokens_consumed); | 3291 const int64_t num_tokens_before = STAT_VALUE(thread, num_tokens_consumed); |
| 3278 pipeline->ParseFunction(parsed_function); | 3292 pipeline->ParseFunction(parsed_function); |
| 3279 const int64_t num_tokens_after = STAT_VALUE(thread, num_tokens_consumed); | 3293 const int64_t num_tokens_after = STAT_VALUE(thread, num_tokens_consumed); |
| 3280 INC_STAT(thread, | 3294 INC_STAT(thread, |
| 3281 num_func_tokens_compiled, | 3295 num_func_tokens_compiled, |
| 3282 num_tokens_after - num_tokens_before); | 3296 num_tokens_after - num_tokens_before); |
| 3283 } | 3297 } |
| 3284 | 3298 |
| 3285 PrecompileParsedFunctionHelper helper(parsed_function, optimized); | 3299 PrecompileParsedFunctionHelper helper( |
| 3300 precompiler, parsed_function, optimized); |
| 3286 const bool success = helper.Compile(pipeline); | 3301 const bool success = helper.Compile(pipeline); |
| 3287 if (!success) { | 3302 if (!success) { |
| 3288 // Encountered error. | 3303 // Encountered error. |
| 3289 Error& error = Error::Handle(); | 3304 Error& error = Error::Handle(); |
| 3290 // We got an error during compilation. | 3305 // We got an error during compilation. |
| 3291 error = thread->sticky_error(); | 3306 error = thread->sticky_error(); |
| 3292 thread->clear_sticky_error(); | 3307 thread->clear_sticky_error(); |
| 3293 ASSERT(error.IsLanguageError() && | 3308 ASSERT(error.IsLanguageError() && |
| 3294 LanguageError::Cast(error).kind() != Report::kBailout); | 3309 LanguageError::Cast(error).kind() != Report::kBailout); |
| 3295 return error.raw(); | 3310 return error.raw(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3323 // Precompilation may encounter compile-time errors. | 3338 // Precompilation may encounter compile-time errors. |
| 3324 // Do not attempt to optimize functions that can cause errors. | 3339 // Do not attempt to optimize functions that can cause errors. |
| 3325 function.set_is_optimizable(false); | 3340 function.set_is_optimizable(false); |
| 3326 return error.raw(); | 3341 return error.raw(); |
| 3327 } | 3342 } |
| 3328 UNREACHABLE(); | 3343 UNREACHABLE(); |
| 3329 return Error::null(); | 3344 return Error::null(); |
| 3330 } | 3345 } |
| 3331 | 3346 |
| 3332 | 3347 |
| 3333 RawError* Precompiler::CompileFunction(Thread* thread, | 3348 RawError* Precompiler::CompileFunction(Precompiler* precompiler, |
| 3349 Thread* thread, |
| 3334 Zone* zone, | 3350 Zone* zone, |
| 3335 const Function& function, | 3351 const Function& function, |
| 3336 FieldTypeMap* field_type_map) { | 3352 FieldTypeMap* field_type_map) { |
| 3337 VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId); | 3353 VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId); |
| 3338 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, "CompileFunction", function); | 3354 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, "CompileFunction", function); |
| 3339 | 3355 |
| 3340 ASSERT(FLAG_precompiled_mode); | 3356 ASSERT(FLAG_precompiled_mode); |
| 3341 const bool optimized = function.IsOptimizable(); // False for natives. | 3357 const bool optimized = function.IsOptimizable(); // False for natives. |
| 3342 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3358 DartPrecompilationPipeline pipeline(zone, field_type_map); |
| 3343 return PrecompileFunctionHelper(&pipeline, function, optimized); | 3359 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
| 3344 } | 3360 } |
| 3345 | 3361 |
| 3346 #endif // DART_PRECOMPILER | 3362 #endif // DART_PRECOMPILER |
| 3347 | 3363 |
| 3348 } // namespace dart | 3364 } // namespace dart |
| OLD | NEW |