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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 796363002: Fixed an ordering issue found by UBSan_vptr. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/bailout-reason.h" 7 #include "src/bailout-reason.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/field-index.h" 9 #include "src/field-index.h"
10 #include "src/hydrogen.h" 10 #include "src/hydrogen.h"
(...skipping 16 matching lines...) Expand all
27 LChunk* chunk = LChunk::NewChunk(graph); 27 LChunk* chunk = LChunk::NewChunk(graph);
28 if (chunk == NULL) { 28 if (chunk == NULL) {
29 FATAL(GetBailoutReason(graph->info()->bailout_reason())); 29 FATAL(GetBailoutReason(graph->info()->bailout_reason()));
30 } 30 }
31 return chunk; 31 return chunk;
32 } 32 }
33 33
34 34
35 class CodeStubGraphBuilderBase : public HGraphBuilder { 35 class CodeStubGraphBuilderBase : public HGraphBuilder {
36 public: 36 public:
37 CodeStubGraphBuilderBase(Isolate* isolate, HydrogenCodeStub* stub) 37 explicit CodeStubGraphBuilderBase(CompilationInfoWithZone* info)
38 : HGraphBuilder(&info_), 38 : HGraphBuilder(info),
39 arguments_length_(NULL), 39 arguments_length_(NULL),
40 info_(stub, isolate), 40 info_(info),
41 descriptor_(stub), 41 descriptor_(info->code_stub()),
42 context_(NULL) { 42 context_(NULL) {
43 int parameter_count = descriptor_.GetEnvironmentParameterCount(); 43 int parameter_count = descriptor_.GetEnvironmentParameterCount();
44 parameters_.Reset(new HParameter*[parameter_count]); 44 parameters_.Reset(new HParameter*[parameter_count]);
45 } 45 }
46 virtual bool BuildGraph(); 46 virtual bool BuildGraph();
47 47
48 protected: 48 protected:
49 virtual HValue* BuildCodeStub() = 0; 49 virtual HValue* BuildCodeStub() = 0;
50 HParameter* GetParameter(int parameter) { 50 HParameter* GetParameter(int parameter) {
51 DCHECK(parameter < descriptor_.GetEnvironmentParameterCount()); 51 DCHECK(parameter < descriptor_.GetEnvironmentParameterCount());
52 return parameters_[parameter]; 52 return parameters_[parameter];
53 } 53 }
54 HValue* GetArgumentsLength() { 54 HValue* GetArgumentsLength() {
55 // This is initialized in BuildGraph() 55 // This is initialized in BuildGraph()
56 DCHECK(arguments_length_ != NULL); 56 DCHECK(arguments_length_ != NULL);
57 return arguments_length_; 57 return arguments_length_;
58 } 58 }
59 CompilationInfo* info() { return &info_; } 59 CompilationInfo* info() { return info_; }
60 HydrogenCodeStub* stub() { return info_.code_stub(); } 60 HydrogenCodeStub* stub() { return info_->code_stub(); }
61 HContext* context() { return context_; } 61 HContext* context() { return context_; }
62 Isolate* isolate() { return info_.isolate(); } 62 Isolate* isolate() { return info_->isolate(); }
63 63
64 HLoadNamedField* BuildLoadNamedField(HValue* object, 64 HLoadNamedField* BuildLoadNamedField(HValue* object,
65 FieldIndex index); 65 FieldIndex index);
66 void BuildStoreNamedField(HValue* object, HValue* value, FieldIndex index, 66 void BuildStoreNamedField(HValue* object, HValue* value, FieldIndex index,
67 Representation representation, 67 Representation representation,
68 bool transition_to_field); 68 bool transition_to_field);
69 69
70 enum ArgumentClass { 70 enum ArgumentClass {
71 NONE, 71 NONE,
72 SINGLE, 72 SINGLE,
(...skipping 26 matching lines...) Expand all
99 HValue* shared_info, 99 HValue* shared_info,
100 HValue* native_context); 100 HValue* native_context);
101 101
102 private: 102 private:
103 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); 103 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder);
104 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, 104 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder,
105 ElementsKind kind); 105 ElementsKind kind);
106 106
107 SmartArrayPointer<HParameter*> parameters_; 107 SmartArrayPointer<HParameter*> parameters_;
108 HValue* arguments_length_; 108 HValue* arguments_length_;
109 CompilationInfoWithZone info_; 109 CompilationInfoWithZone* info_;
110 CodeStubDescriptor descriptor_; 110 CodeStubDescriptor descriptor_;
111 HContext* context_; 111 HContext* context_;
112 }; 112 };
113 113
114 114
115 bool CodeStubGraphBuilderBase::BuildGraph() { 115 bool CodeStubGraphBuilderBase::BuildGraph() {
116 // Update the static counter each time a new code stub is generated. 116 // Update the static counter each time a new code stub is generated.
117 isolate()->counters()->code_stubs()->Increment(); 117 isolate()->counters()->code_stubs()->Increment();
118 118
119 if (FLAG_trace_hydrogen_stubs) { 119 if (FLAG_trace_hydrogen_stubs) {
120 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); 120 const char* name = CodeStub::MajorName(stub()->MajorKey(), false);
121 PrintF("-----------------------------------------------------------\n"); 121 PrintF("-----------------------------------------------------------\n");
122 PrintF("Compiling stub %s using hydrogen\n", name); 122 PrintF("Compiling stub %s using hydrogen\n", name);
123 isolate()->GetHTracer()->TraceCompilation(&info_); 123 isolate()->GetHTracer()->TraceCompilation(info());
124 } 124 }
125 125
126 int param_count = descriptor_.GetEnvironmentParameterCount(); 126 int param_count = descriptor_.GetEnvironmentParameterCount();
127 HEnvironment* start_environment = graph()->start_environment(); 127 HEnvironment* start_environment = graph()->start_environment();
128 HBasicBlock* next_block = CreateBasicBlock(start_environment); 128 HBasicBlock* next_block = CreateBasicBlock(start_environment);
129 Goto(next_block); 129 Goto(next_block);
130 next_block->SetJoinId(BailoutId::StubEntry()); 130 next_block->SetJoinId(BailoutId::StubEntry());
131 set_current_block(next_block); 131 set_current_block(next_block);
132 132
133 bool runtime_stack_params = descriptor_.stack_parameter_count().is_valid(); 133 bool runtime_stack_params = descriptor_.stack_parameter_count().is_valid();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 stack_pop_count); 182 stack_pop_count);
183 FinishCurrentBlock(hreturn_instruction); 183 FinishCurrentBlock(hreturn_instruction);
184 } 184 }
185 return true; 185 return true;
186 } 186 }
187 187
188 188
189 template <class Stub> 189 template <class Stub>
190 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { 190 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
191 public: 191 public:
192 CodeStubGraphBuilder(Isolate* isolate, Stub* stub) 192 explicit CodeStubGraphBuilder(CompilationInfoWithZone* info)
193 : CodeStubGraphBuilderBase(isolate, stub) {} 193 : CodeStubGraphBuilderBase(info) {}
194 194
195 protected: 195 protected:
196 virtual HValue* BuildCodeStub() { 196 virtual HValue* BuildCodeStub() {
197 if (casted_stub()->IsUninitialized()) { 197 if (casted_stub()->IsUninitialized()) {
198 return BuildCodeUninitializedStub(); 198 return BuildCodeUninitializedStub();
199 } else { 199 } else {
200 return BuildCodeInitializedStub(); 200 return BuildCodeInitializedStub();
201 } 201 }
202 } 202 }
203 203
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // the runtime that is significantly faster than using the standard 264 // the runtime that is significantly faster than using the standard
265 // stub-failure deopt mechanism. 265 // stub-failure deopt mechanism.
266 if (stub->IsUninitialized() && descriptor.has_miss_handler()) { 266 if (stub->IsUninitialized() && descriptor.has_miss_handler()) {
267 DCHECK(!descriptor.stack_parameter_count().is_valid()); 267 DCHECK(!descriptor.stack_parameter_count().is_valid());
268 return stub->GenerateLightweightMissCode(descriptor.miss_handler()); 268 return stub->GenerateLightweightMissCode(descriptor.miss_handler());
269 } 269 }
270 base::ElapsedTimer timer; 270 base::ElapsedTimer timer;
271 if (FLAG_profile_hydrogen_code_stub_compilation) { 271 if (FLAG_profile_hydrogen_code_stub_compilation) {
272 timer.Start(); 272 timer.Start();
273 } 273 }
274 CodeStubGraphBuilder<Stub> builder(isolate, stub); 274 CompilationInfoWithZone info(stub, isolate);
275 CodeStubGraphBuilder<Stub> builder(&info);
275 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 276 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
276 Handle<Code> code = chunk->Codegen(); 277 Handle<Code> code = chunk->Codegen();
277 if (FLAG_profile_hydrogen_code_stub_compilation) { 278 if (FLAG_profile_hydrogen_code_stub_compilation) {
278 OFStream os(stdout); 279 OFStream os(stdout);
279 os << "[Lazy compilation of " << stub << " took " 280 os << "[Lazy compilation of " << stub << " took "
280 << timer.Elapsed().InMillisecondsF() << " ms]" << std::endl; 281 << timer.Elapsed().InMillisecondsF() << " ms]" << std::endl;
281 } 282 }
282 return code; 283 return code;
283 } 284 }
284 285
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 1694
1694 Handle<Code> RegExpConstructResultStub::GenerateCode() { 1695 Handle<Code> RegExpConstructResultStub::GenerateCode() {
1695 return DoGenerateCode(this); 1696 return DoGenerateCode(this);
1696 } 1697 }
1697 1698
1698 1699
1699 template <> 1700 template <>
1700 class CodeStubGraphBuilder<KeyedLoadGenericStub> 1701 class CodeStubGraphBuilder<KeyedLoadGenericStub>
1701 : public CodeStubGraphBuilderBase { 1702 : public CodeStubGraphBuilderBase {
1702 public: 1703 public:
1703 CodeStubGraphBuilder(Isolate* isolate, KeyedLoadGenericStub* stub) 1704 explicit CodeStubGraphBuilder(CompilationInfoWithZone* info)
1704 : CodeStubGraphBuilderBase(isolate, stub) {} 1705 : CodeStubGraphBuilderBase(info) {}
1705 1706
1706 protected: 1707 protected:
1707 virtual HValue* BuildCodeStub(); 1708 virtual HValue* BuildCodeStub();
1708 1709
1709 void BuildElementsKindLimitCheck(HGraphBuilder::IfBuilder* if_builder, 1710 void BuildElementsKindLimitCheck(HGraphBuilder::IfBuilder* if_builder,
1710 HValue* bit_field2, 1711 HValue* bit_field2,
1711 ElementsKind kind); 1712 ElementsKind kind);
1712 1713
1713 void BuildFastElementLoad(HGraphBuilder::IfBuilder* if_builder, 1714 void BuildFastElementLoad(HGraphBuilder::IfBuilder* if_builder,
1714 HValue* receiver, 1715 HValue* receiver,
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 2041
2041 // Probe the stub cache. 2042 // Probe the stub cache.
2042 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( 2043 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
2043 Code::ComputeHandlerFlags(Code::LOAD_IC)); 2044 Code::ComputeHandlerFlags(Code::LOAD_IC));
2044 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); 2045 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags);
2045 2046
2046 // We never continue. 2047 // We never continue.
2047 return graph()->GetConstant0(); 2048 return graph()->GetConstant0();
2048 } 2049 }
2049 } } // namespace v8::internal 2050 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698