code() { return code_; } void set_code(Handle code) { DCHECK(code_.is_null()); code_ = code; } // RawMachineAssembler generally produces graphs which cannot be verified. bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } Zone* graph_zone() const { return graph_zone_; } Graph* graph() const { return graph_; } SourcePositionTable* source_positions() const { return source_positions_; } MachineOperatorBuilder* machine() const { return machine_; } CommonOperatorBuilder* common() const { return common_; } JSOperatorBuilder* javascript() const { return javascript_; } JSGraph* jsgraph() const { return jsgraph_; } MaybeHandle native_context() const { if (info()->is_native_context_specializing()) { return handle(info()->native_context(), isolate()); } return MaybeHandle(); } LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; } void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) { DCHECK(!loop_assignment_); loop_assignment_ = loop_assignment; } TypeHintAnalysis* type_hint_analysis() const { return type_hint_analysis_; } void set_type_hint_analysis(TypeHintAnalysis* type_hint_analysis) { DCHECK_NULL(type_hint_analysis_); type_hint_analysis_ = type_hint_analysis; } Schedule* schedule() const { return schedule_; } void set_schedule(Schedule* schedule) { DCHECK(!schedule_); schedule_ = schedule; } void reset_schedule() { schedule_ = nullptr; } Zone* instruction_zone() const { return instruction_zone_; } InstructionSequence* sequence() const { return sequence_; } Frame* frame() const { return frame_; } Zone* register_allocation_zone() const { return register_allocation_zone_; } RegisterAllocationData* register_allocation_data() const { return register_allocation_data_; } BasicBlockProfiler::Data* profiler_data() const { return profiler_data_; } void set_profiler_data(BasicBlockProfiler::Data* profiler_data) { profiler_data_ = profiler_data; } std::string const& source_position_output() const { return source_position_output_; } void set_source_position_output(std::string const& source_position_output) { source_position_output_ = source_position_output; } void DeleteGraphZone() { if (graph_zone_ == nullptr) return; graph_zone_scope_.Destroy(); graph_zone_ = nullptr; graph_ = nullptr; source_positions_ = nullptr; loop_assignment_ = nullptr; type_hint_analysis_ = nullptr; simplified_ = nullptr; machine_ = nullptr; common_ = nullptr; javascript_ = nullptr; jsgraph_ = nullptr; schedule_ = nullptr; } void DeleteInstructionZone() { if (instruction_zone_ == nullptr) return; instruction_zone_scope_.Destroy(); instruction_zone_ = nullptr; sequence_ = nullptr; frame_ = nullptr; } void DeleteRegisterAllocationZone() { if (register_allocation_zone_ == nullptr) return; register_allocation_zone_scope_.Destroy(); register_allocation_zone_ = nullptr; register_allocation_data_ = nullptr; } void InitializeInstructionSequence(const CallDescriptor* descriptor) { DCHECK(sequence_ == nullptr); InstructionBlocks* instruction_blocks = InstructionSequence::InstructionBlocksFor(instruction_zone(), schedule()); sequence_ = new (instruction_zone()) InstructionSequence( info()->isolate(), instruction_zone(), instruction_blocks); if (descriptor && descriptor->RequiresFrameAsIncoming()) { sequence_->instruction_blocks()[0]->mark_needs_frame(); } else { DCHECK_EQ(0, descriptor->CalleeSavedFPRegisters()); DCHECK_EQ(0, descriptor->CalleeSavedRegisters()); } } void InitializeFrameData(CallDescriptor* descriptor) { DCHECK(frame_ == nullptr); int fixed_frame_size = 0; if (descriptor != nullptr) { fixed_frame_size = CalculateFixedFrameSize(descriptor); } frame_ = new (instruction_zone()) Frame(fixed_frame_size); } void InitializeRegisterAllocationData(const RegisterConfiguration* config, CallDescriptor* descriptor) { DCHECK(register_allocation_data_ == nullptr); register_allocation_data_ = new (register_allocation_zone()) RegisterAllocationData(config, register_allocation_zone(), frame(), sequence(), debug_name_.get()); } void BeginPhaseKind(const char* phase_kind_name) { if (pipeline_statistics() != nullptr) { pipeline_statistics()->BeginPhaseKind(phase_kind_name); } } void EndPhaseKind() { if (pipeline_statistics() != nullptr) { pipeline_statistics()->EndPhaseKind(); } } private: Isolate* const isolate_; CompilationInfo* const info_; base::SmartArrayPointer debug_name_; Zone* outer_zone_ = nullptr; ZonePool* const zone_pool_; PipelineStatistics* pipeline_statistics_ = nullptr; bool compilation_failed_ = false; Handle code_ = Handle::null(); // All objects in the following group of fields are allocated in graph_zone_. // They are all set to nullptr when the graph_zone_ is destroyed. ZonePool::Scope graph_zone_scope_; Zone* graph_zone_ = nullptr; Graph* graph_ = nullptr; SourcePositionTable* source_positions_ = nullptr; LoopAssignmentAnalysis* loop_assignment_ = nullptr; TypeHintAnalysis* type_hint_analysis_ = nullptr; SimplifiedOperatorBuilder* simplified_ = nullptr; MachineOperatorBuilder* machine_ = nullptr; CommonOperatorBuilder* common_ = nullptr; JSOperatorBuilder* javascript_ = nullptr; JSGraph* jsgraph_ = nullptr; Schedule* schedule_ = nullptr; // All objects in the following group of fields are allocated in // instruction_zone_. They are all set to nullptr when the instruction_zone_ // is // destroyed. ZonePool::Scope instruction_zone_scope_; Zone* instruction_zone_; InstructionSequence* sequence_ = nullptr; Frame* frame_ = nullptr; // All objects in the following group of fields are allocated in // register_allocation_zone_. They are all set to nullptr when the zone is // destroyed. ZonePool::Scope register_allocation_zone_scope_; Zone* register_allocation_zone_; RegisterAllocationData* register_allocation_data_ = nullptr; // Basic block profiling support. BasicBlockProfiler::Data* profiler_data_ = nullptr; // Source position output for --trace-turbo. std::string source_position_output_; int CalculateFixedFrameSize(CallDescriptor* descriptor) { if (descriptor->IsJSFunctionCall()) { return StandardFrameConstants::kFixedSlotCount; } return descriptor->IsCFunctionCall() ? (CommonFrameConstants::kFixedSlotCountAboveFp + CommonFrameConstants::kCPSlotCount) : TypedFrameConstants::kFixedSlotCount; } DISALLOW_COPY_AND_ASSIGN(PipelineData); }; class PipelineImpl final { public: explicit PipelineImpl(PipelineData* data) : data_(data) {} // Helpers for executing pipeline phases. template void Run(); template void Run(Arg0 arg_0); template void Run(Arg0 arg_0, Arg1 arg_1); // Run the graph creation and initial optimization passes. bool CreateGraph(); // Run the concurrent optimization passes. bool OptimizeGraph(Linkage* linkage); // Perform the actual code generation and return handle to a code object. Handle GenerateCode(Linkage* linkage); bool ScheduleAndSelectInstructions(Linkage* linkage); void RunPrintAndVerify(const char* phase, bool untyped = false); Handle ScheduleAndGenerateCode(CallDescriptor* call_descriptor); void AllocateRegisters(const RegisterConfiguration* config, CallDescriptor* descriptor, bool run_verifier); CompilationInfo* info() const; Isolate* isolate() const; PipelineData* const data_; }; namespace { struct TurboCfgFile : public std::ofstream { explicit TurboCfgFile(Isolate* isolate) : std::ofstream(isolate->GetTurboCfgFileName().c_str(), std::ios_base::app) {} }; struct TurboJsonFile : public std::ofstream { TurboJsonFile(CompilationInfo* info, std::ios_base::openmode mode) : std::ofstream(GetVisualizerLogFileName(info, nullptr, "json").get(), mode) {} }; void TraceSchedule(CompilationInfo* info, Schedule* schedule) { if (FLAG_trace_turbo) { AllowHandleDereference allow_deref; TurboJsonFile json_of(info, std::ios_base::app); json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; std::stringstream schedule_stream; schedule_stream << *schedule; std::string schedule_string(schedule_stream.str()); for (const auto& c : schedule_string) { json_of << AsEscapedUC16ForJSON(c); } json_of << "\"},\n"; } if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { AllowHandleDereference allow_deref; OFStream os(stdout); os << "-- Schedule --------------------------------------\n" << *schedule; } } class AstGraphBuilderWithPositions final : public AstGraphBuilder { public: AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, LoopAssignmentAnalysis* loop_assignment, TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions) : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, type_hint_analysis), source_positions_(source_positions), start_position_(info->shared_info()->start_position()) {} bool CreateGraph(bool stack_check) { SourcePositionTable::Scope pos_scope(source_positions_, start_position_); return AstGraphBuilder::CreateGraph(stack_check); } #define DEF_VISIT(type) \ void Visit##type(type* node) override { \ SourcePositionTable::Scope pos(source_positions_, \ SourcePosition(node->position())); \ AstGraphBuilder::Visit##type(node); \ } AST_NODE_LIST(DEF_VISIT) #undef DEF_VISIT private: SourcePositionTable* const source_positions_; SourcePosition const start_position_; }; class SourcePositionWrapper final : public Reducer { public: SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) : reducer_(reducer), table_(table) {} ~SourcePositionWrapper() final {} Reduction Reduce(Node* node) final { SourcePosition const pos = table_->GetSourcePosition(node); SourcePositionTable::Scope position(table_, pos); return reducer_->Reduce(node); } void Finalize() final { reducer_->Finalize(); } private: Reducer* const reducer_; SourcePositionTable* const table_; DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); }; class JSGraphReducer final : public GraphReducer { public: JSGraphReducer(JSGraph* jsgraph, Zone* zone) : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} ~JSGraphReducer() final {} }; void AddReducer(PipelineData* data, GraphReducer* graph_reducer, Reducer* reducer) { if (data->info()->is_source_positions_enabled()) { void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); SourcePositionWrapper* const wrapper = new (buffer) SourcePositionWrapper(reducer, data->source_positions()); graph_reducer->AddReducer(wrapper); } else { graph_reducer->AddReducer(reducer); } } class PipelineRunScope { public: PipelineRunScope(PipelineData* data, const char* phase_name) : phase_scope_( phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name), zone_scope_(data->zone_pool()) {} Zone* zone() { return zone_scope_.zone(); } private: PhaseScope phase_scope_; ZonePool::Scope zone_scope_; }; PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, ZonePool* zone_pool) { PipelineStatistics* pipeline_statistics = nullptr; if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { pipeline_statistics = new PipelineStatistics(info, zone_pool); pipeline_statistics->BeginPhaseKind("initializing"); } if (FLAG_trace_turbo) { TurboJsonFile json_of(info, std::ios_base::trunc); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
code) { DCHECK(code_.is_null()); code_ = code; } // RawMachineAssembler generally produces graphs which cannot be verified. bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } Zone* graph_zone() const { return graph_zone_; } Graph* graph() const { return graph_; } SourcePositionTable* source_positions() const { return source_positions_; } MachineOperatorBuilder* machine() const { return machine_; } CommonOperatorBuilder* common() const { return common_; } JSOperatorBuilder* javascript() const { return javascript_; } JSGraph* jsgraph() const { return jsgraph_; } MaybeHandle native_context() const { if (info()->is_native_context_specializing()) { return handle(info()->native_context(), isolate()); } return MaybeHandle(); } LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; } void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) { DCHECK(!loop_assignment_); loop_assignment_ = loop_assignment; } TypeHintAnalysis* type_hint_analysis() const { return type_hint_analysis_; } void set_type_hint_analysis(TypeHintAnalysis* type_hint_analysis) { DCHECK_NULL(type_hint_analysis_); type_hint_analysis_ = type_hint_analysis; } Schedule* schedule() const { return schedule_; } void set_schedule(Schedule* schedule) { DCHECK(!schedule_); schedule_ = schedule; } void reset_schedule() { schedule_ = nullptr; } Zone* instruction_zone() const { return instruction_zone_; } InstructionSequence* sequence() const { return sequence_; } Frame* frame() const { return frame_; } Zone* register_allocation_zone() const { return register_allocation_zone_; } RegisterAllocationData* register_allocation_data() const { return register_allocation_data_; } BasicBlockProfiler::Data* profiler_data() const { return profiler_data_; } void set_profiler_data(BasicBlockProfiler::Data* profiler_data) { profiler_data_ = profiler_data; } std::string const& source_position_output() const { return source_position_output_; } void set_source_position_output(std::string const& source_position_output) { source_position_output_ = source_position_output; } void DeleteGraphZone() { if (graph_zone_ == nullptr) return; graph_zone_scope_.Destroy(); graph_zone_ = nullptr; graph_ = nullptr; source_positions_ = nullptr; loop_assignment_ = nullptr; type_hint_analysis_ = nullptr; simplified_ = nullptr; machine_ = nullptr; common_ = nullptr; javascript_ = nullptr; jsgraph_ = nullptr; schedule_ = nullptr; } void DeleteInstructionZone() { if (instruction_zone_ == nullptr) return; instruction_zone_scope_.Destroy(); instruction_zone_ = nullptr; sequence_ = nullptr; frame_ = nullptr; } void DeleteRegisterAllocationZone() { if (register_allocation_zone_ == nullptr) return; register_allocation_zone_scope_.Destroy(); register_allocation_zone_ = nullptr; register_allocation_data_ = nullptr; } void InitializeInstructionSequence(const CallDescriptor* descriptor) { DCHECK(sequence_ == nullptr); InstructionBlocks* instruction_blocks = InstructionSequence::InstructionBlocksFor(instruction_zone(), schedule()); sequence_ = new (instruction_zone()) InstructionSequence( info()->isolate(), instruction_zone(), instruction_blocks); if (descriptor && descriptor->RequiresFrameAsIncoming()) { sequence_->instruction_blocks()[0]->mark_needs_frame(); } else { DCHECK_EQ(0, descriptor->CalleeSavedFPRegisters()); DCHECK_EQ(0, descriptor->CalleeSavedRegisters()); } } void InitializeFrameData(CallDescriptor* descriptor) { DCHECK(frame_ == nullptr); int fixed_frame_size = 0; if (descriptor != nullptr) { fixed_frame_size = CalculateFixedFrameSize(descriptor); } frame_ = new (instruction_zone()) Frame(fixed_frame_size); } void InitializeRegisterAllocationData(const RegisterConfiguration* config, CallDescriptor* descriptor) { DCHECK(register_allocation_data_ == nullptr); register_allocation_data_ = new (register_allocation_zone()) RegisterAllocationData(config, register_allocation_zone(), frame(), sequence(), debug_name_.get()); } void BeginPhaseKind(const char* phase_kind_name) { if (pipeline_statistics() != nullptr) { pipeline_statistics()->BeginPhaseKind(phase_kind_name); } } void EndPhaseKind() { if (pipeline_statistics() != nullptr) { pipeline_statistics()->EndPhaseKind(); } } private: Isolate* const isolate_; CompilationInfo* const info_; base::SmartArrayPointer debug_name_; Zone* outer_zone_ = nullptr; ZonePool* const zone_pool_; PipelineStatistics* pipeline_statistics_ = nullptr; bool compilation_failed_ = false; Handle code_ = Handle::null(); // All objects in the following group of fields are allocated in graph_zone_. // They are all set to nullptr when the graph_zone_ is destroyed. ZonePool::Scope graph_zone_scope_; Zone* graph_zone_ = nullptr; Graph* graph_ = nullptr; SourcePositionTable* source_positions_ = nullptr; LoopAssignmentAnalysis* loop_assignment_ = nullptr; TypeHintAnalysis* type_hint_analysis_ = nullptr; SimplifiedOperatorBuilder* simplified_ = nullptr; MachineOperatorBuilder* machine_ = nullptr; CommonOperatorBuilder* common_ = nullptr; JSOperatorBuilder* javascript_ = nullptr; JSGraph* jsgraph_ = nullptr; Schedule* schedule_ = nullptr; // All objects in the following group of fields are allocated in // instruction_zone_. They are all set to nullptr when the instruction_zone_ // is // destroyed. ZonePool::Scope instruction_zone_scope_; Zone* instruction_zone_; InstructionSequence* sequence_ = nullptr; Frame* frame_ = nullptr; // All objects in the following group of fields are allocated in // register_allocation_zone_. They are all set to nullptr when the zone is // destroyed. ZonePool::Scope register_allocation_zone_scope_; Zone* register_allocation_zone_; RegisterAllocationData* register_allocation_data_ = nullptr; // Basic block profiling support. BasicBlockProfiler::Data* profiler_data_ = nullptr; // Source position output for --trace-turbo. std::string source_position_output_; int CalculateFixedFrameSize(CallDescriptor* descriptor) { if (descriptor->IsJSFunctionCall()) { return StandardFrameConstants::kFixedSlotCount; } return descriptor->IsCFunctionCall() ? (CommonFrameConstants::kFixedSlotCountAboveFp + CommonFrameConstants::kCPSlotCount) : TypedFrameConstants::kFixedSlotCount; } DISALLOW_COPY_AND_ASSIGN(PipelineData); }; class PipelineImpl final { public: explicit PipelineImpl(PipelineData* data) : data_(data) {} // Helpers for executing pipeline phases. template void Run(); template void Run(Arg0 arg_0); template void Run(Arg0 arg_0, Arg1 arg_1); // Run the graph creation and initial optimization passes. bool CreateGraph(); // Run the concurrent optimization passes. bool OptimizeGraph(Linkage* linkage); // Perform the actual code generation and return handle to a code object. Handle GenerateCode(Linkage* linkage); bool ScheduleAndSelectInstructions(Linkage* linkage); void RunPrintAndVerify(const char* phase, bool untyped = false); Handle ScheduleAndGenerateCode(CallDescriptor* call_descriptor); void AllocateRegisters(const RegisterConfiguration* config, CallDescriptor* descriptor, bool run_verifier); CompilationInfo* info() const; Isolate* isolate() const; PipelineData* const data_; }; namespace { struct TurboCfgFile : public std::ofstream { explicit TurboCfgFile(Isolate* isolate) : std::ofstream(isolate->GetTurboCfgFileName().c_str(), std::ios_base::app) {} }; struct TurboJsonFile : public std::ofstream { TurboJsonFile(CompilationInfo* info, std::ios_base::openmode mode) : std::ofstream(GetVisualizerLogFileName(info, nullptr, "json").get(), mode) {} }; void TraceSchedule(CompilationInfo* info, Schedule* schedule) { if (FLAG_trace_turbo) { AllowHandleDereference allow_deref; TurboJsonFile json_of(info, std::ios_base::app); json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; std::stringstream schedule_stream; schedule_stream << *schedule; std::string schedule_string(schedule_stream.str()); for (const auto& c : schedule_string) { json_of << AsEscapedUC16ForJSON(c); } json_of << "\"},\n"; } if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { AllowHandleDereference allow_deref; OFStream os(stdout); os << "-- Schedule --------------------------------------\n" << *schedule; } } class AstGraphBuilderWithPositions final : public AstGraphBuilder { public: AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, LoopAssignmentAnalysis* loop_assignment, TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions) : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, type_hint_analysis), source_positions_(source_positions), start_position_(info->shared_info()->start_position()) {} bool CreateGraph(bool stack_check) { SourcePositionTable::Scope pos_scope(source_positions_, start_position_); return AstGraphBuilder::CreateGraph(stack_check); } #define DEF_VISIT(type) \ void Visit##type(type* node) override { \ SourcePositionTable::Scope pos(source_positions_, \ SourcePosition(node->position())); \ AstGraphBuilder::Visit##type(node); \ } AST_NODE_LIST(DEF_VISIT) #undef DEF_VISIT private: SourcePositionTable* const source_positions_; SourcePosition const start_position_; }; class SourcePositionWrapper final : public Reducer { public: SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) : reducer_(reducer), table_(table) {} ~SourcePositionWrapper() final {} Reduction Reduce(Node* node) final { SourcePosition const pos = table_->GetSourcePosition(node); SourcePositionTable::Scope position(table_, pos); return reducer_->Reduce(node); } void Finalize() final { reducer_->Finalize(); } private: Reducer* const reducer_; SourcePositionTable* const table_; DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); }; class JSGraphReducer final : public GraphReducer { public: JSGraphReducer(JSGraph* jsgraph, Zone* zone) : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} ~JSGraphReducer() final {} }; void AddReducer(PipelineData* data, GraphReducer* graph_reducer, Reducer* reducer) { if (data->info()->is_source_positions_enabled()) { void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); SourcePositionWrapper* const wrapper = new (buffer) SourcePositionWrapper(reducer, data->source_positions()); graph_reducer->AddReducer(wrapper); } else { graph_reducer->AddReducer(reducer); } } class PipelineRunScope { public: PipelineRunScope(PipelineData* data, const char* phase_name) : phase_scope_( phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name), zone_scope_(data->zone_pool()) {} Zone* zone() { return zone_scope_.zone(); } private: PhaseScope phase_scope_; ZonePool::Scope zone_scope_; }; PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, ZonePool* zone_pool) { PipelineStatistics* pipeline_statistics = nullptr; if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { pipeline_statistics = new PipelineStatistics(info, zone_pool); pipeline_statistics->BeginPhaseKind("initializing"); } if (FLAG_trace_turbo) { TurboJsonFile json_of(info, std::ios_base::trunc); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
code_ = Handle::null(); // All objects in the following group of fields are allocated in graph_zone_. // They are all set to nullptr when the graph_zone_ is destroyed. ZonePool::Scope graph_zone_scope_; Zone* graph_zone_ = nullptr; Graph* graph_ = nullptr; SourcePositionTable* source_positions_ = nullptr; LoopAssignmentAnalysis* loop_assignment_ = nullptr; TypeHintAnalysis* type_hint_analysis_ = nullptr; SimplifiedOperatorBuilder* simplified_ = nullptr; MachineOperatorBuilder* machine_ = nullptr; CommonOperatorBuilder* common_ = nullptr; JSOperatorBuilder* javascript_ = nullptr; JSGraph* jsgraph_ = nullptr; Schedule* schedule_ = nullptr; // All objects in the following group of fields are allocated in // instruction_zone_. They are all set to nullptr when the instruction_zone_ // is // destroyed. ZonePool::Scope instruction_zone_scope_; Zone* instruction_zone_; InstructionSequence* sequence_ = nullptr; Frame* frame_ = nullptr; // All objects in the following group of fields are allocated in // register_allocation_zone_. They are all set to nullptr when the zone is // destroyed. ZonePool::Scope register_allocation_zone_scope_; Zone* register_allocation_zone_; RegisterAllocationData* register_allocation_data_ = nullptr; // Basic block profiling support. BasicBlockProfiler::Data* profiler_data_ = nullptr; // Source position output for --trace-turbo. std::string source_position_output_; int CalculateFixedFrameSize(CallDescriptor* descriptor) { if (descriptor->IsJSFunctionCall()) { return StandardFrameConstants::kFixedSlotCount; } return descriptor->IsCFunctionCall() ? (CommonFrameConstants::kFixedSlotCountAboveFp + CommonFrameConstants::kCPSlotCount) : TypedFrameConstants::kFixedSlotCount; } DISALLOW_COPY_AND_ASSIGN(PipelineData); }; class PipelineImpl final { public: explicit PipelineImpl(PipelineData* data) : data_(data) {} // Helpers for executing pipeline phases. template void Run(); template void Run(Arg0 arg_0); template void Run(Arg0 arg_0, Arg1 arg_1); // Run the graph creation and initial optimization passes. bool CreateGraph(); // Run the concurrent optimization passes. bool OptimizeGraph(Linkage* linkage); // Perform the actual code generation and return handle to a code object. Handle GenerateCode(Linkage* linkage); bool ScheduleAndSelectInstructions(Linkage* linkage); void RunPrintAndVerify(const char* phase, bool untyped = false); Handle ScheduleAndGenerateCode(CallDescriptor* call_descriptor); void AllocateRegisters(const RegisterConfiguration* config, CallDescriptor* descriptor, bool run_verifier); CompilationInfo* info() const; Isolate* isolate() const; PipelineData* const data_; }; namespace { struct TurboCfgFile : public std::ofstream { explicit TurboCfgFile(Isolate* isolate) : std::ofstream(isolate->GetTurboCfgFileName().c_str(), std::ios_base::app) {} }; struct TurboJsonFile : public std::ofstream { TurboJsonFile(CompilationInfo* info, std::ios_base::openmode mode) : std::ofstream(GetVisualizerLogFileName(info, nullptr, "json").get(), mode) {} }; void TraceSchedule(CompilationInfo* info, Schedule* schedule) { if (FLAG_trace_turbo) { AllowHandleDereference allow_deref; TurboJsonFile json_of(info, std::ios_base::app); json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; std::stringstream schedule_stream; schedule_stream << *schedule; std::string schedule_string(schedule_stream.str()); for (const auto& c : schedule_string) { json_of << AsEscapedUC16ForJSON(c); } json_of << "\"},\n"; } if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { AllowHandleDereference allow_deref; OFStream os(stdout); os << "-- Schedule --------------------------------------\n" << *schedule; } } class AstGraphBuilderWithPositions final : public AstGraphBuilder { public: AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, LoopAssignmentAnalysis* loop_assignment, TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions) : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, type_hint_analysis), source_positions_(source_positions), start_position_(info->shared_info()->start_position()) {} bool CreateGraph(bool stack_check) { SourcePositionTable::Scope pos_scope(source_positions_, start_position_); return AstGraphBuilder::CreateGraph(stack_check); } #define DEF_VISIT(type) \ void Visit##type(type* node) override { \ SourcePositionTable::Scope pos(source_positions_, \ SourcePosition(node->position())); \ AstGraphBuilder::Visit##type(node); \ } AST_NODE_LIST(DEF_VISIT) #undef DEF_VISIT private: SourcePositionTable* const source_positions_; SourcePosition const start_position_; }; class SourcePositionWrapper final : public Reducer { public: SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) : reducer_(reducer), table_(table) {} ~SourcePositionWrapper() final {} Reduction Reduce(Node* node) final { SourcePosition const pos = table_->GetSourcePosition(node); SourcePositionTable::Scope position(table_, pos); return reducer_->Reduce(node); } void Finalize() final { reducer_->Finalize(); } private: Reducer* const reducer_; SourcePositionTable* const table_; DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); }; class JSGraphReducer final : public GraphReducer { public: JSGraphReducer(JSGraph* jsgraph, Zone* zone) : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} ~JSGraphReducer() final {} }; void AddReducer(PipelineData* data, GraphReducer* graph_reducer, Reducer* reducer) { if (data->info()->is_source_positions_enabled()) { void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); SourcePositionWrapper* const wrapper = new (buffer) SourcePositionWrapper(reducer, data->source_positions()); graph_reducer->AddReducer(wrapper); } else { graph_reducer->AddReducer(reducer); } } class PipelineRunScope { public: PipelineRunScope(PipelineData* data, const char* phase_name) : phase_scope_( phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name), zone_scope_(data->zone_pool()) {} Zone* zone() { return zone_scope_.zone(); } private: PhaseScope phase_scope_; ZonePool::Scope zone_scope_; }; PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, ZonePool* zone_pool) { PipelineStatistics* pipeline_statistics = nullptr; if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { pipeline_statistics = new PipelineStatistics(info, zone_pool); pipeline_statistics->BeginPhaseKind("initializing"); } if (FLAG_trace_turbo) { TurboJsonFile json_of(info, std::ios_base::trunc); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
::null(); // All objects in the following group of fields are allocated in graph_zone_. // They are all set to nullptr when the graph_zone_ is destroyed. ZonePool::Scope graph_zone_scope_; Zone* graph_zone_ = nullptr; Graph* graph_ = nullptr; SourcePositionTable* source_positions_ = nullptr; LoopAssignmentAnalysis* loop_assignment_ = nullptr; TypeHintAnalysis* type_hint_analysis_ = nullptr; SimplifiedOperatorBuilder* simplified_ = nullptr; MachineOperatorBuilder* machine_ = nullptr; CommonOperatorBuilder* common_ = nullptr; JSOperatorBuilder* javascript_ = nullptr; JSGraph* jsgraph_ = nullptr; Schedule* schedule_ = nullptr; // All objects in the following group of fields are allocated in // instruction_zone_. They are all set to nullptr when the instruction_zone_ // is // destroyed. ZonePool::Scope instruction_zone_scope_; Zone* instruction_zone_; InstructionSequence* sequence_ = nullptr; Frame* frame_ = nullptr; // All objects in the following group of fields are allocated in // register_allocation_zone_. They are all set to nullptr when the zone is // destroyed. ZonePool::Scope register_allocation_zone_scope_; Zone* register_allocation_zone_; RegisterAllocationData* register_allocation_data_ = nullptr; // Basic block profiling support. BasicBlockProfiler::Data* profiler_data_ = nullptr; // Source position output for --trace-turbo. std::string source_position_output_; int CalculateFixedFrameSize(CallDescriptor* descriptor) { if (descriptor->IsJSFunctionCall()) { return StandardFrameConstants::kFixedSlotCount; } return descriptor->IsCFunctionCall() ? (CommonFrameConstants::kFixedSlotCountAboveFp + CommonFrameConstants::kCPSlotCount) : TypedFrameConstants::kFixedSlotCount; } DISALLOW_COPY_AND_ASSIGN(PipelineData); }; class PipelineImpl final { public: explicit PipelineImpl(PipelineData* data) : data_(data) {} // Helpers for executing pipeline phases. template void Run(); template void Run(Arg0 arg_0); template void Run(Arg0 arg_0, Arg1 arg_1); // Run the graph creation and initial optimization passes. bool CreateGraph(); // Run the concurrent optimization passes. bool OptimizeGraph(Linkage* linkage); // Perform the actual code generation and return handle to a code object. Handle GenerateCode(Linkage* linkage); bool ScheduleAndSelectInstructions(Linkage* linkage); void RunPrintAndVerify(const char* phase, bool untyped = false); Handle ScheduleAndGenerateCode(CallDescriptor* call_descriptor); void AllocateRegisters(const RegisterConfiguration* config, CallDescriptor* descriptor, bool run_verifier); CompilationInfo* info() const; Isolate* isolate() const; PipelineData* const data_; }; namespace { struct TurboCfgFile : public std::ofstream { explicit TurboCfgFile(Isolate* isolate) : std::ofstream(isolate->GetTurboCfgFileName().c_str(), std::ios_base::app) {} }; struct TurboJsonFile : public std::ofstream { TurboJsonFile(CompilationInfo* info, std::ios_base::openmode mode) : std::ofstream(GetVisualizerLogFileName(info, nullptr, "json").get(), mode) {} }; void TraceSchedule(CompilationInfo* info, Schedule* schedule) { if (FLAG_trace_turbo) { AllowHandleDereference allow_deref; TurboJsonFile json_of(info, std::ios_base::app); json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; std::stringstream schedule_stream; schedule_stream << *schedule; std::string schedule_string(schedule_stream.str()); for (const auto& c : schedule_string) { json_of << AsEscapedUC16ForJSON(c); } json_of << "\"},\n"; } if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { AllowHandleDereference allow_deref; OFStream os(stdout); os << "-- Schedule --------------------------------------\n" << *schedule; } } class AstGraphBuilderWithPositions final : public AstGraphBuilder { public: AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, LoopAssignmentAnalysis* loop_assignment, TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions) : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, type_hint_analysis), source_positions_(source_positions), start_position_(info->shared_info()->start_position()) {} bool CreateGraph(bool stack_check) { SourcePositionTable::Scope pos_scope(source_positions_, start_position_); return AstGraphBuilder::CreateGraph(stack_check); } #define DEF_VISIT(type) \ void Visit##type(type* node) override { \ SourcePositionTable::Scope pos(source_positions_, \ SourcePosition(node->position())); \ AstGraphBuilder::Visit##type(node); \ } AST_NODE_LIST(DEF_VISIT) #undef DEF_VISIT private: SourcePositionTable* const source_positions_; SourcePosition const start_position_; }; class SourcePositionWrapper final : public Reducer { public: SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) : reducer_(reducer), table_(table) {} ~SourcePositionWrapper() final {} Reduction Reduce(Node* node) final { SourcePosition const pos = table_->GetSourcePosition(node); SourcePositionTable::Scope position(table_, pos); return reducer_->Reduce(node); } void Finalize() final { reducer_->Finalize(); } private: Reducer* const reducer_; SourcePositionTable* const table_; DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); }; class JSGraphReducer final : public GraphReducer { public: JSGraphReducer(JSGraph* jsgraph, Zone* zone) : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} ~JSGraphReducer() final {} }; void AddReducer(PipelineData* data, GraphReducer* graph_reducer, Reducer* reducer) { if (data->info()->is_source_positions_enabled()) { void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); SourcePositionWrapper* const wrapper = new (buffer) SourcePositionWrapper(reducer, data->source_positions()); graph_reducer->AddReducer(wrapper); } else { graph_reducer->AddReducer(reducer); } } class PipelineRunScope { public: PipelineRunScope(PipelineData* data, const char* phase_name) : phase_scope_( phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name), zone_scope_(data->zone_pool()) {} Zone* zone() { return zone_scope_.zone(); } private: PhaseScope phase_scope_; ZonePool::Scope zone_scope_; }; PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, ZonePool* zone_pool) { PipelineStatistics* pipeline_statistics = nullptr; if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { pipeline_statistics = new PipelineStatistics(info, zone_pool); pipeline_statistics->BeginPhaseKind("initializing"); } if (FLAG_trace_turbo) { TurboJsonFile json_of(info, std::ios_base::trunc); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
GenerateCode(Linkage* linkage); bool ScheduleAndSelectInstructions(Linkage* linkage); void RunPrintAndVerify(const char* phase, bool untyped = false); Handle ScheduleAndGenerateCode(CallDescriptor* call_descriptor); void AllocateRegisters(const RegisterConfiguration* config, CallDescriptor* descriptor, bool run_verifier); CompilationInfo* info() const; Isolate* isolate() const; PipelineData* const data_; }; namespace { struct TurboCfgFile : public std::ofstream { explicit TurboCfgFile(Isolate* isolate) : std::ofstream(isolate->GetTurboCfgFileName().c_str(), std::ios_base::app) {} }; struct TurboJsonFile : public std::ofstream { TurboJsonFile(CompilationInfo* info, std::ios_base::openmode mode) : std::ofstream(GetVisualizerLogFileName(info, nullptr, "json").get(), mode) {} }; void TraceSchedule(CompilationInfo* info, Schedule* schedule) { if (FLAG_trace_turbo) { AllowHandleDereference allow_deref; TurboJsonFile json_of(info, std::ios_base::app); json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; std::stringstream schedule_stream; schedule_stream << *schedule; std::string schedule_string(schedule_stream.str()); for (const auto& c : schedule_string) { json_of << AsEscapedUC16ForJSON(c); } json_of << "\"},\n"; } if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { AllowHandleDereference allow_deref; OFStream os(stdout); os << "-- Schedule --------------------------------------\n" << *schedule; } } class AstGraphBuilderWithPositions final : public AstGraphBuilder { public: AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, LoopAssignmentAnalysis* loop_assignment, TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions) : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, type_hint_analysis), source_positions_(source_positions), start_position_(info->shared_info()->start_position()) {} bool CreateGraph(bool stack_check) { SourcePositionTable::Scope pos_scope(source_positions_, start_position_); return AstGraphBuilder::CreateGraph(stack_check); } #define DEF_VISIT(type) \ void Visit##type(type* node) override { \ SourcePositionTable::Scope pos(source_positions_, \ SourcePosition(node->position())); \ AstGraphBuilder::Visit##type(node); \ } AST_NODE_LIST(DEF_VISIT) #undef DEF_VISIT private: SourcePositionTable* const source_positions_; SourcePosition const start_position_; }; class SourcePositionWrapper final : public Reducer { public: SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) : reducer_(reducer), table_(table) {} ~SourcePositionWrapper() final {} Reduction Reduce(Node* node) final { SourcePosition const pos = table_->GetSourcePosition(node); SourcePositionTable::Scope position(table_, pos); return reducer_->Reduce(node); } void Finalize() final { reducer_->Finalize(); } private: Reducer* const reducer_; SourcePositionTable* const table_; DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); }; class JSGraphReducer final : public GraphReducer { public: JSGraphReducer(JSGraph* jsgraph, Zone* zone) : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} ~JSGraphReducer() final {} }; void AddReducer(PipelineData* data, GraphReducer* graph_reducer, Reducer* reducer) { if (data->info()->is_source_positions_enabled()) { void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); SourcePositionWrapper* const wrapper = new (buffer) SourcePositionWrapper(reducer, data->source_positions()); graph_reducer->AddReducer(wrapper); } else { graph_reducer->AddReducer(reducer); } } class PipelineRunScope { public: PipelineRunScope(PipelineData* data, const char* phase_name) : phase_scope_( phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name), zone_scope_(data->zone_pool()) {} Zone* zone() { return zone_scope_.zone(); } private: PhaseScope phase_scope_; ZonePool::Scope zone_scope_; }; PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, ZonePool* zone_pool) { PipelineStatistics* pipeline_statistics = nullptr; if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { pipeline_statistics = new PipelineStatistics(info, zone_pool); pipeline_statistics->BeginPhaseKind("initializing"); } if (FLAG_trace_turbo) { TurboJsonFile json_of(info, std::ios_base::trunc); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
ScheduleAndGenerateCode(CallDescriptor* call_descriptor); void AllocateRegisters(const RegisterConfiguration* config, CallDescriptor* descriptor, bool run_verifier); CompilationInfo* info() const; Isolate* isolate() const; PipelineData* const data_; }; namespace { struct TurboCfgFile : public std::ofstream { explicit TurboCfgFile(Isolate* isolate) : std::ofstream(isolate->GetTurboCfgFileName().c_str(), std::ios_base::app) {} }; struct TurboJsonFile : public std::ofstream { TurboJsonFile(CompilationInfo* info, std::ios_base::openmode mode) : std::ofstream(GetVisualizerLogFileName(info, nullptr, "json").get(), mode) {} }; void TraceSchedule(CompilationInfo* info, Schedule* schedule) { if (FLAG_trace_turbo) { AllowHandleDereference allow_deref; TurboJsonFile json_of(info, std::ios_base::app); json_of << "{\"name\":\"Schedule\",\"type\":\"schedule\",\"data\":\""; std::stringstream schedule_stream; schedule_stream << *schedule; std::string schedule_string(schedule_stream.str()); for (const auto& c : schedule_string) { json_of << AsEscapedUC16ForJSON(c); } json_of << "\"},\n"; } if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { AllowHandleDereference allow_deref; OFStream os(stdout); os << "-- Schedule --------------------------------------\n" << *schedule; } } class AstGraphBuilderWithPositions final : public AstGraphBuilder { public: AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, LoopAssignmentAnalysis* loop_assignment, TypeHintAnalysis* type_hint_analysis, SourcePositionTable* source_positions) : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, type_hint_analysis), source_positions_(source_positions), start_position_(info->shared_info()->start_position()) {} bool CreateGraph(bool stack_check) { SourcePositionTable::Scope pos_scope(source_positions_, start_position_); return AstGraphBuilder::CreateGraph(stack_check); } #define DEF_VISIT(type) \ void Visit##type(type* node) override { \ SourcePositionTable::Scope pos(source_positions_, \ SourcePosition(node->position())); \ AstGraphBuilder::Visit##type(node); \ } AST_NODE_LIST(DEF_VISIT) #undef DEF_VISIT private: SourcePositionTable* const source_positions_; SourcePosition const start_position_; }; class SourcePositionWrapper final : public Reducer { public: SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) : reducer_(reducer), table_(table) {} ~SourcePositionWrapper() final {} Reduction Reduce(Node* node) final { SourcePosition const pos = table_->GetSourcePosition(node); SourcePositionTable::Scope position(table_, pos); return reducer_->Reduce(node); } void Finalize() final { reducer_->Finalize(); } private: Reducer* const reducer_; SourcePositionTable* const table_; DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); }; class JSGraphReducer final : public GraphReducer { public: JSGraphReducer(JSGraph* jsgraph, Zone* zone) : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} ~JSGraphReducer() final {} }; void AddReducer(PipelineData* data, GraphReducer* graph_reducer, Reducer* reducer) { if (data->info()->is_source_positions_enabled()) { void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); SourcePositionWrapper* const wrapper = new (buffer) SourcePositionWrapper(reducer, data->source_positions()); graph_reducer->AddReducer(wrapper); } else { graph_reducer->AddReducer(reducer); } } class PipelineRunScope { public: PipelineRunScope(PipelineData* data, const char* phase_name) : phase_scope_( phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name), zone_scope_(data->zone_pool()) {} Zone* zone() { return zone_scope_.zone(); } private: PhaseScope phase_scope_; ZonePool::Scope zone_scope_; }; PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, ZonePool* zone_pool) { PipelineStatistics* pipeline_statistics = nullptr; if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { pipeline_statistics = new PipelineStatistics(info, zone_pool); pipeline_statistics->BeginPhaseKind("initializing"); } if (FLAG_trace_turbo) { TurboJsonFile json_of(info, std::ios_base::trunc); Handle 登录后可以享受更多权益 您还没有登录,登录后您可以: 收藏Android系统代码 收藏喜欢的文章 多个平台共享账号 去登录 首次使用?从这里 注册
您还没有登录,登录后您可以:
首次使用?从这里 注册