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

Side by Side Diff: src/compiler/pipeline.cc

Issue 2500443004: [wasm] OOB traps: build protected instruction list during codegen (Closed)
Patch Set: Fixing Windows better Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/pipeline.h" 5 #include "src/compiler/pipeline.h"
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <memory> 8 #include <memory>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "src/compiler/typer.h" 70 #include "src/compiler/typer.h"
71 #include "src/compiler/value-numbering-reducer.h" 71 #include "src/compiler/value-numbering-reducer.h"
72 #include "src/compiler/verifier.h" 72 #include "src/compiler/verifier.h"
73 #include "src/compiler/zone-stats.h" 73 #include "src/compiler/zone-stats.h"
74 #include "src/isolate-inl.h" 74 #include "src/isolate-inl.h"
75 #include "src/ostreams.h" 75 #include "src/ostreams.h"
76 #include "src/parsing/parse-info.h" 76 #include "src/parsing/parse-info.h"
77 #include "src/register-configuration.h" 77 #include "src/register-configuration.h"
78 #include "src/type-info.h" 78 #include "src/type-info.h"
79 #include "src/utils.h" 79 #include "src/utils.h"
80 #include "src/wasm/wasm-module.h"
80 81
81 namespace v8 { 82 namespace v8 {
82 namespace internal { 83 namespace internal {
83 namespace compiler { 84 namespace compiler {
84 85
85 class PipelineData { 86 class PipelineData {
86 public: 87 public:
87 // For main entry point. 88 // For main entry point.
88 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, 89 PipelineData(ZoneStats* zone_stats, CompilationInfo* info,
89 PipelineStatistics* pipeline_statistics) 90 PipelineStatistics* pipeline_statistics)
(...skipping 18 matching lines...) Expand all
108 InstructionSelector::SupportedMachineOperatorFlags(), 109 InstructionSelector::SupportedMachineOperatorFlags(),
109 InstructionSelector::AlignmentRequirements()); 110 InstructionSelector::AlignmentRequirements());
110 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); 111 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_);
111 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); 112 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_);
112 jsgraph_ = new (graph_zone_) 113 jsgraph_ = new (graph_zone_)
113 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); 114 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_);
114 } 115 }
115 116
116 // For WASM compile entry point. 117 // For WASM compile entry point.
117 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, 118 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph,
118 SourcePositionTable* source_positions) 119 SourcePositionTable* source_positions,
120 wasm::ProtectedInstructionList* protected_instructions)
119 : isolate_(info->isolate()), 121 : isolate_(info->isolate()),
120 info_(info), 122 info_(info),
121 debug_name_(info_->GetDebugName()), 123 debug_name_(info_->GetDebugName()),
122 zone_stats_(zone_stats), 124 zone_stats_(zone_stats),
123 graph_zone_scope_(zone_stats_, ZONE_NAME), 125 graph_zone_scope_(zone_stats_, ZONE_NAME),
124 graph_(graph), 126 graph_(graph),
125 source_positions_(source_positions), 127 source_positions_(source_positions),
126 instruction_zone_scope_(zone_stats_, ZONE_NAME), 128 instruction_zone_scope_(zone_stats_, ZONE_NAME),
127 instruction_zone_(instruction_zone_scope_.zone()), 129 instruction_zone_(instruction_zone_scope_.zone()),
128 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), 130 register_allocation_zone_scope_(zone_stats_, ZONE_NAME),
129 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} 131 register_allocation_zone_(register_allocation_zone_scope_.zone()),
132 protected_instructions_(protected_instructions) {}
130 133
131 // For machine graph testing entry point. 134 // For machine graph testing entry point.
132 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, 135 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph,
133 Schedule* schedule) 136 Schedule* schedule)
134 : isolate_(info->isolate()), 137 : isolate_(info->isolate()),
135 info_(info), 138 info_(info),
136 debug_name_(info_->GetDebugName()), 139 debug_name_(info_->GetDebugName()),
137 zone_stats_(zone_stats), 140 zone_stats_(zone_stats),
138 graph_zone_scope_(zone_stats_, ZONE_NAME), 141 graph_zone_scope_(zone_stats_, ZONE_NAME),
139 graph_(graph), 142 graph_(graph),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 profiler_data_ = profiler_data; 229 profiler_data_ = profiler_data;
227 } 230 }
228 231
229 std::string const& source_position_output() const { 232 std::string const& source_position_output() const {
230 return source_position_output_; 233 return source_position_output_;
231 } 234 }
232 void set_source_position_output(std::string const& source_position_output) { 235 void set_source_position_output(std::string const& source_position_output) {
233 source_position_output_ = source_position_output; 236 source_position_output_ = source_position_output;
234 } 237 }
235 238
239 wasm::ProtectedInstructionList* protected_instructions() const {
240 return protected_instructions_;
241 }
242
236 void DeleteGraphZone() { 243 void DeleteGraphZone() {
237 if (graph_zone_ == nullptr) return; 244 if (graph_zone_ == nullptr) return;
238 graph_zone_scope_.Destroy(); 245 graph_zone_scope_.Destroy();
239 graph_zone_ = nullptr; 246 graph_zone_ = nullptr;
240 graph_ = nullptr; 247 graph_ = nullptr;
241 source_positions_ = nullptr; 248 source_positions_ = nullptr;
242 loop_assignment_ = nullptr; 249 loop_assignment_ = nullptr;
243 type_hint_analysis_ = nullptr; 250 type_hint_analysis_ = nullptr;
244 simplified_ = nullptr; 251 simplified_ = nullptr;
245 machine_ = nullptr; 252 machine_ = nullptr;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 ZoneStats::Scope register_allocation_zone_scope_; 355 ZoneStats::Scope register_allocation_zone_scope_;
349 Zone* register_allocation_zone_; 356 Zone* register_allocation_zone_;
350 RegisterAllocationData* register_allocation_data_ = nullptr; 357 RegisterAllocationData* register_allocation_data_ = nullptr;
351 358
352 // Basic block profiling support. 359 // Basic block profiling support.
353 BasicBlockProfiler::Data* profiler_data_ = nullptr; 360 BasicBlockProfiler::Data* profiler_data_ = nullptr;
354 361
355 // Source position output for --trace-turbo. 362 // Source position output for --trace-turbo.
356 std::string source_position_output_; 363 std::string source_position_output_;
357 364
365 wasm::ProtectedInstructionList* protected_instructions_ = nullptr;
366
358 DISALLOW_COPY_AND_ASSIGN(PipelineData); 367 DISALLOW_COPY_AND_ASSIGN(PipelineData);
359 }; 368 };
360 369
361 class PipelineImpl final { 370 class PipelineImpl final {
362 public: 371 public:
363 explicit PipelineImpl(PipelineData* data) : data_(data) {} 372 explicit PipelineImpl(PipelineData* data) : data_(data) {}
364 373
365 // Helpers for executing pipeline phases. 374 // Helpers for executing pipeline phases.
366 template <typename Phase> 375 template <typename Phase>
367 void Run(); 376 void Run();
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 info()->SetCode(code); 646 info()->SetCode(code);
638 if (info()->is_deoptimization_enabled()) { 647 if (info()->is_deoptimization_enabled()) {
639 info()->context()->native_context()->AddOptimizedCode(*code); 648 info()->context()->native_context()->AddOptimizedCode(*code);
640 RegisterWeakObjectsInOptimizedCode(code); 649 RegisterWeakObjectsInOptimizedCode(code);
641 } 650 }
642 return SUCCEEDED; 651 return SUCCEEDED;
643 } 652 }
644 653
645 class PipelineWasmCompilationJob final : public CompilationJob { 654 class PipelineWasmCompilationJob final : public CompilationJob {
646 public: 655 public:
647 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, 656 explicit PipelineWasmCompilationJob(
648 CallDescriptor* descriptor, 657 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor,
649 SourcePositionTable* source_positions) 658 SourcePositionTable* source_positions,
659 wasm::ProtectedInstructionList* protected_insts)
650 : CompilationJob(info->isolate(), info, "TurboFan", 660 : CompilationJob(info->isolate(), info, "TurboFan",
651 State::kReadyToExecute), 661 State::kReadyToExecute),
652 zone_stats_(info->isolate()->allocator()), 662 zone_stats_(info->isolate()->allocator()),
653 data_(&zone_stats_, info, graph, source_positions), 663 data_(&zone_stats_, info, graph, source_positions, protected_insts),
654 pipeline_(&data_), 664 pipeline_(&data_),
655 linkage_(descriptor) {} 665 linkage_(descriptor) {}
656 666
657 protected: 667 protected:
658 Status PrepareJobImpl() final; 668 Status PrepareJobImpl() final;
659 Status ExecuteJobImpl() final; 669 Status ExecuteJobImpl() final;
660 Status FinalizeJobImpl() final; 670 Status FinalizeJobImpl() final;
661 671
662 private: 672 private:
663 ZoneStats zone_stats_; 673 ZoneStats zone_stats_;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } 1433 }
1424 } 1434 }
1425 }; 1435 };
1426 1436
1427 1437
1428 struct GenerateCodePhase { 1438 struct GenerateCodePhase {
1429 static const char* phase_name() { return "generate code"; } 1439 static const char* phase_name() { return "generate code"; }
1430 1440
1431 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { 1441 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) {
1432 CodeGenerator generator(data->frame(), linkage, data->sequence(), 1442 CodeGenerator generator(data->frame(), linkage, data->sequence(),
1433 data->info()); 1443 data->info(), data->protected_instructions());
1434 data->set_code(generator.GenerateCode()); 1444 data->set_code(generator.GenerateCode());
1435 } 1445 }
1436 }; 1446 };
1437 1447
1438 1448
1439 struct PrintGraphPhase { 1449 struct PrintGraphPhase {
1440 static const char* phase_name() { return nullptr; } 1450 static const char* phase_name() { return nullptr; }
1441 1451
1442 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { 1452 void Run(PipelineData* data, Zone* temp_zone, const char* phase) {
1443 CompilationInfo* info = data->info(); 1453 CompilationInfo* info = data->info();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 } 1754 }
1745 1755
1746 // static 1756 // static
1747 CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function) { 1757 CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function) {
1748 return new PipelineCompilationJob(function->GetIsolate(), function); 1758 return new PipelineCompilationJob(function->GetIsolate(), function);
1749 } 1759 }
1750 1760
1751 // static 1761 // static
1752 CompilationJob* Pipeline::NewWasmCompilationJob( 1762 CompilationJob* Pipeline::NewWasmCompilationJob(
1753 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor, 1763 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor,
1754 SourcePositionTable* source_positions) { 1764 SourcePositionTable* source_positions,
1755 return new PipelineWasmCompilationJob(info, graph, descriptor, 1765 wasm::ProtectedInstructionList* protected_instructions) {
1756 source_positions); 1766 return new PipelineWasmCompilationJob(
1767 info, graph, descriptor, source_positions, protected_instructions);
1757 } 1768 }
1758 1769
1759 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, 1770 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config,
1760 InstructionSequence* sequence, 1771 InstructionSequence* sequence,
1761 bool run_verifier) { 1772 bool run_verifier) {
1762 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), 1773 CompilationInfo info(ArrayVector("testing"), sequence->isolate(),
1763 sequence->zone(), Code::ComputeFlags(Code::STUB)); 1774 sequence->zone(), Code::ComputeFlags(Code::STUB));
1764 ZoneStats zone_stats(sequence->isolate()->allocator()); 1775 ZoneStats zone_stats(sequence->isolate()->allocator());
1765 PipelineData data(&zone_stats, &info, sequence); 1776 PipelineData data(&zone_stats, &info, sequence);
1766 PipelineImpl pipeline(&data); 1777 PipelineImpl pipeline(&data);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 data->DeleteRegisterAllocationZone(); 2006 data->DeleteRegisterAllocationZone();
1996 } 2007 }
1997 2008
1998 CompilationInfo* PipelineImpl::info() const { return data_->info(); } 2009 CompilationInfo* PipelineImpl::info() const { return data_->info(); }
1999 2010
2000 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } 2011 Isolate* PipelineImpl::isolate() const { return info()->isolate(); }
2001 2012
2002 } // namespace compiler 2013 } // namespace compiler
2003 } // namespace internal 2014 } // namespace internal
2004 } // namespace v8 2015 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/pipeline.h ('k') | src/compiler/wasm-compiler.h » ('j') | src/wasm/wasm-module.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698