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

Side by Side Diff: src/compiler.cc

Issue 1911313002: Pass debug name as Vector instead of const char* (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-1
Patch Set: rebase Created 4 years, 7 months 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 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/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/ast/ast-numbering.h" 9 #include "src/ast/ast-numbering.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 // ---------------------------------------------------------------------------- 115 // ----------------------------------------------------------------------------
116 // Implementation of CompilationInfo 116 // Implementation of CompilationInfo
117 117
118 bool CompilationInfo::has_shared_info() const { 118 bool CompilationInfo::has_shared_info() const {
119 return parse_info_ && !parse_info_->shared_info().is_null(); 119 return parse_info_ && !parse_info_->shared_info().is_null();
120 } 120 }
121 121
122 CompilationInfo::CompilationInfo(ParseInfo* parse_info, 122 CompilationInfo::CompilationInfo(ParseInfo* parse_info,
123 Handle<JSFunction> closure) 123 Handle<JSFunction> closure)
124 : CompilationInfo(parse_info, nullptr, Code::ComputeFlags(Code::FUNCTION), 124 : CompilationInfo(parse_info, {}, Code::ComputeFlags(Code::FUNCTION), BASE,
125 BASE, parse_info->isolate(), parse_info->zone()) { 125 parse_info->isolate(), parse_info->zone()) {
126 closure_ = closure; 126 closure_ = closure;
127 127
128 // Compiling for the snapshot typically results in different code than 128 // Compiling for the snapshot typically results in different code than
129 // compiling later on. This means that code recompiled with deoptimization 129 // compiling later on. This means that code recompiled with deoptimization
130 // support won't be "equivalent" (as defined by SharedFunctionInfo:: 130 // support won't be "equivalent" (as defined by SharedFunctionInfo::
131 // EnableDeoptimizationSupport), so it will replace the old code and all 131 // EnableDeoptimizationSupport), so it will replace the old code and all
132 // its type feedback. To avoid this, always compile functions in the snapshot 132 // its type feedback. To avoid this, always compile functions in the snapshot
133 // with deoptimization support. 133 // with deoptimization support.
134 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); 134 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport();
135 135
136 if (FLAG_function_context_specialization) MarkAsFunctionContextSpecializing(); 136 if (FLAG_function_context_specialization) MarkAsFunctionContextSpecializing();
137 if (FLAG_turbo_inlining) MarkAsInliningEnabled(); 137 if (FLAG_turbo_inlining) MarkAsInliningEnabled();
138 if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled(); 138 if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled();
139 if (FLAG_turbo_splitting) MarkAsSplittingEnabled(); 139 if (FLAG_turbo_splitting) MarkAsSplittingEnabled();
140 } 140 }
141 141
142 142 CompilationInfo::CompilationInfo(Vector<const char> debug_name,
143 CompilationInfo::CompilationInfo(const char* debug_name, Isolate* isolate, 143 Isolate* isolate, Zone* zone,
144 Zone* zone, Code::Flags code_flags) 144 Code::Flags code_flags)
145 : CompilationInfo(nullptr, debug_name, code_flags, STUB, isolate, zone) {} 145 : CompilationInfo(nullptr, debug_name, code_flags, STUB, isolate, zone) {}
146 146
147 CompilationInfo::CompilationInfo(ParseInfo* parse_info, const char* debug_name, 147 CompilationInfo::CompilationInfo(ParseInfo* parse_info,
148 Vector<const char> debug_name,
148 Code::Flags code_flags, Mode mode, 149 Code::Flags code_flags, Mode mode,
149 Isolate* isolate, Zone* zone) 150 Isolate* isolate, Zone* zone)
150 : parse_info_(parse_info), 151 : parse_info_(parse_info),
151 isolate_(isolate), 152 isolate_(isolate),
152 flags_(0), 153 flags_(0),
153 code_flags_(code_flags), 154 code_flags_(code_flags),
154 mode_(mode), 155 mode_(mode),
155 osr_ast_id_(BailoutId::None()), 156 osr_ast_id_(BailoutId::None()),
156 zone_(zone), 157 zone_(zone),
157 deferred_handles_(nullptr), 158 deferred_handles_(nullptr),
158 dependencies_(isolate, zone), 159 dependencies_(isolate, zone),
159 bailout_reason_(kNoReason), 160 bailout_reason_(kNoReason),
160 prologue_offset_(Code::kPrologueOffsetNotSet), 161 prologue_offset_(Code::kPrologueOffsetNotSet),
161 track_positions_(FLAG_hydrogen_track_positions || 162 track_positions_(FLAG_hydrogen_track_positions ||
162 isolate->cpu_profiler()->is_profiling()), 163 isolate->cpu_profiler()->is_profiling()),
163 parameter_count_(0), 164 parameter_count_(0),
164 optimization_id_(-1), 165 optimization_id_(-1),
165 osr_expr_stack_height_(0), 166 osr_expr_stack_height_(0),
166 debug_name_(debug_name) {} 167 debug_name_(debug_name) {}
167 168
168
169 CompilationInfo::~CompilationInfo() { 169 CompilationInfo::~CompilationInfo() {
170 DisableFutureOptimization(); 170 DisableFutureOptimization();
171 delete deferred_handles_; 171 delete deferred_handles_;
172 #ifdef DEBUG 172 #ifdef DEBUG
173 // Check that no dependent maps have been added or added dependent maps have 173 // Check that no dependent maps have been added or added dependent maps have
174 // been rolled back or committed. 174 // been rolled back or committed.
175 DCHECK(dependencies()->IsEmpty()); 175 DCHECK(dependencies()->IsEmpty());
176 #endif // DEBUG 176 #endif // DEBUG
177 } 177 }
178 178
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 262
263 base::SmartArrayPointer<char> CompilationInfo::GetDebugName() const { 263 base::SmartArrayPointer<char> CompilationInfo::GetDebugName() const {
264 if (parse_info() && parse_info()->literal()) { 264 if (parse_info() && parse_info()->literal()) {
265 AllowHandleDereference allow_deref; 265 AllowHandleDereference allow_deref;
266 return parse_info()->literal()->debug_name()->ToCString(); 266 return parse_info()->literal()->debug_name()->ToCString();
267 } 267 }
268 if (parse_info() && !parse_info()->shared_info().is_null()) { 268 if (parse_info() && !parse_info()->shared_info().is_null()) {
269 return parse_info()->shared_info()->DebugName()->ToCString(); 269 return parse_info()->shared_info()->DebugName()->ToCString();
270 } 270 }
271 const char* str = debug_name_ ? debug_name_ : "unknown"; 271 Vector<const char> name_vec = debug_name_;
272 size_t len = strlen(str) + 1; 272 if (name_vec.is_empty()) name_vec = ArrayVector("unknown");
273 base::SmartArrayPointer<char> name(new char[len]); 273 base::SmartArrayPointer<char> name(new char[name_vec.length() + 1]);
274 memcpy(name.get(), str, len); 274 memcpy(name.get(), name_vec.start(), name_vec.length());
275 name[name_vec.length()] = '\0';
275 return name; 276 return name;
276 } 277 }
277 278
278 StackFrame::Type CompilationInfo::GetOutputStackFrameType() const { 279 StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
279 switch (output_code_kind()) { 280 switch (output_code_kind()) {
280 case Code::STUB: 281 case Code::STUB:
281 case Code::BYTECODE_HANDLER: 282 case Code::BYTECODE_HANDLER:
282 case Code::HANDLER: 283 case Code::HANDLER:
283 case Code::BUILTIN: 284 case Code::BUILTIN:
284 return StackFrame::STUB; 285 return StackFrame::STUB;
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 MaybeHandle<Code> code; 1805 MaybeHandle<Code> code;
1805 if (cached.code != nullptr) code = handle(cached.code); 1806 if (cached.code != nullptr) code = handle(cached.code);
1806 Handle<Context> native_context(function->context()->native_context()); 1807 Handle<Context> native_context(function->context()->native_context());
1807 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 1808 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
1808 literals, BailoutId::None()); 1809 literals, BailoutId::None());
1809 } 1810 }
1810 } 1811 }
1811 1812
1812 } // namespace internal 1813 } // namespace internal
1813 } // namespace v8 1814 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/compiler/pipeline.cc » ('j') | src/wasm/wasm-opcodes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698