488 {
489 ASSERT(!FLAG_precompiled_mode);
491 if (optimized() && !
function.IsOptimizable()) {
493 }
494 Zone*
const zone = thread()->
zone();
496 EnterCompilerScope cs(thread());
497
498
499
500
501
502
503 volatile bool done =
false;
504
505 volatile intptr_t far_branch_level = 0;
506
507
508
509 SpeculativeInliningPolicy speculative_policy(false);
510
514 LongJumpScope jump;
515 if (setjmp(*jump.Set()) == 0) {
516 FlowGraph* flow_graph = nullptr;
517 ZoneGrowableArray<const ICData*>* ic_data_array = nullptr;
518
519 CompilerState compiler_state(thread(), false, optimized(),
521 compiler_state.set_function(
function);
522
523 {
524
525
526 ic_data_array = new (zone) ZoneGrowableArray<const ICData*>();
527
528
529
531 function.RestoreICDataMap(ic_data_array, clone_ic_data);
532
533 if (optimized()) {
536 }
537
538 if (FLAG_print_ic_data_map) {
539 for (intptr_t i = 0; i < ic_data_array->length(); i++) {
540 if ((*ic_data_array)[i] != nullptr) {
543 }
544 }
545 }
546
548 flow_graph = pipeline->BuildFlowGraph(
549 zone, parsed_function(), ic_data_array, osr_id(), optimized());
550 }
551
552 const bool print_flow_graph =
553 (FLAG_print_flow_graph ||
554 (optimized() && FLAG_print_flow_graph_optimized)) &&
556
557 if (print_flow_graph && !optimized()) {
559 }
560
561 if (flow_graph->should_reorder_blocks()) {
563 "BlockScheduler::AssignEdgeWeights");
565 }
566
567 CompilerPassState pass_state(thread(), flow_graph, &speculative_policy);
568
569 if (optimized()) {
571
572 JitCallSpecializer call_specializer(flow_graph, &speculative_policy);
573 pass_state.call_specializer = &call_specializer;
574
576 }
577
578 ASSERT(pass_state.inline_id_to_function.length() ==
579 pass_state.caller_inline_id.length());
580 compiler::ObjectPoolBuilder object_pool_builder;
581 compiler::Assembler assembler(&object_pool_builder, far_branch_level);
582 FlowGraphCompiler graph_compiler(
583 &assembler, flow_graph, *parsed_function(), optimized(),
584 &speculative_policy, pass_state.inline_id_to_function,
585 pass_state.inline_id_to_token_pos, pass_state.caller_inline_id,
586 ic_data_array);
587 pass_state.graph_compiler = &graph_compiler;
589
590 {
592
593 auto install_code_fun = [&]() {
595 FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
596#if !defined(PRODUCT)
597
598
599
600
601
602
607 }
608 }
609#endif
610 };
611
612
613
614
615
616
617 SafepointWriteRwLocker ml(thread(),
618 thread()->isolate_group()->program_lock());
619
620
621
622
623
624
625
626
627
628
629
630
631
633 install_code_fun, true);
634 }
636
638
641 } else if (FLAG_disassemble_optimized && optimized() &&
644 }
645 }
646
648 } else {
649
651
652 if (
error.ptr() == Object::branch_offset_error().ptr()) {
653
654
657 far_branch_level++;
658 }
else if (
error.ptr() == Object::speculative_inlining_error().ptr()) {
659
661 } else {
662
663
664 if (FLAG_trace_bailout) {
666 }
669
670
671
672 } else {
673
675 }
677 }
678 }
679 }
681}
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
#define RELEASE_ASSERT(cond)
static void AssignEdgeWeights(FlowGraph *flow_graph)
static void NotifyCodeObservers(const Code &code, bool optimized)
static DART_WARN_UNUSED_RESULT FlowGraph * RunPipeline(PipelineMode mode, CompilerPassState *state)
static void GenerateCode(CompilerPassState *state)
static bool ShouldTrace()
static bool IsBackgroundCompilation()
static void DisassembleCode(const Function &function, const Code &code, bool optimized)
static void PrintGraph(const char *phase, FlowGraph *flow_graph)
static bool ShouldPrint(const Function &function, uint8_t **compiler_pass_filter=nullptr)
static void PrintICData(const ICData &ic_data, intptr_t num_checks_to_print=kPrintAll)
void NotifyCompilation(const Function &func)
GroupDebugger * debugger() const
void RunWithStoppedMutators(T single_current_mutator, S otherwise, bool use_force_growth_in_otherwise=false)
static Object & ZoneHandle()
const Function & function() const
void set_sticky_error(const Error &value)
IsolateGroup * isolate_group() const
#define THR_Print(format,...)
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
#define HANDLESCOPE(thread)
#define TIMELINE_DURATION(thread, stream, name)