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

Side by Side Diff: src/compiler.cc

Issue 1520373002: Deprecate ability to generate stubs via Compiler class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « src/compiler.h ('k') | src/compiler/pipeline.cc » ('j') | 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/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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 deferred_handles_(nullptr), 171 deferred_handles_(nullptr),
172 dependencies_(isolate, zone), 172 dependencies_(isolate, zone),
173 bailout_reason_(kNoReason), 173 bailout_reason_(kNoReason),
174 prologue_offset_(Code::kPrologueOffsetNotSet), 174 prologue_offset_(Code::kPrologueOffsetNotSet),
175 track_positions_(FLAG_hydrogen_track_positions || 175 track_positions_(FLAG_hydrogen_track_positions ||
176 isolate->cpu_profiler()->is_profiling()), 176 isolate->cpu_profiler()->is_profiling()),
177 opt_count_(has_shared_info() ? shared_info()->opt_count() : 0), 177 opt_count_(has_shared_info() ? shared_info()->opt_count() : 0),
178 parameter_count_(0), 178 parameter_count_(0),
179 optimization_id_(-1), 179 optimization_id_(-1),
180 osr_expr_stack_height_(0), 180 osr_expr_stack_height_(0),
181 function_type_(nullptr),
182 debug_name_(debug_name) { 181 debug_name_(debug_name) {
183 // Parameter count is number of stack parameters. 182 // Parameter count is number of stack parameters.
184 if (code_stub_ != NULL) { 183 if (code_stub_ != NULL) {
185 CodeStubDescriptor descriptor(code_stub_); 184 CodeStubDescriptor descriptor(code_stub_);
186 parameter_count_ = descriptor.GetStackParameterCount(); 185 parameter_count_ = descriptor.GetStackParameterCount();
187 if (descriptor.function_mode() == NOT_JS_FUNCTION_STUB_MODE) { 186 if (descriptor.function_mode() == NOT_JS_FUNCTION_STUB_MODE) {
188 parameter_count_--; 187 parameter_count_--;
189 } 188 }
190 set_output_code_kind(code_stub->GetCodeKind()); 189 set_output_code_kind(code_stub->GetCodeKind());
191 } else { 190 } else {
192 set_output_code_kind(Code::FUNCTION); 191 set_output_code_kind(Code::FUNCTION);
193 } 192 }
194 } 193 }
195 194
196 195
197 CompilationInfo::~CompilationInfo() { 196 CompilationInfo::~CompilationInfo() {
198 DisableFutureOptimization(); 197 DisableFutureOptimization();
199 delete deferred_handles_; 198 delete deferred_handles_;
200 #ifdef DEBUG 199 #ifdef DEBUG
201 // Check that no dependent maps have been added or added dependent maps have 200 // Check that no dependent maps have been added or added dependent maps have
202 // been rolled back or committed. 201 // been rolled back or committed.
203 DCHECK(dependencies()->IsEmpty()); 202 DCHECK(dependencies()->IsEmpty());
204 #endif // DEBUG 203 #endif // DEBUG
205 } 204 }
206 205
207 206
208 void CompilationInfo::SetStub(CodeStub* code_stub) {
209 SetMode(STUB);
210 code_stub_ = code_stub;
211 debug_name_ = CodeStub::MajorName(code_stub->MajorKey());
212 set_output_code_kind(code_stub->GetCodeKind());
213 }
214
215
216 int CompilationInfo::num_parameters() const { 207 int CompilationInfo::num_parameters() const {
217 return has_scope() ? scope()->num_parameters() : parameter_count_; 208 return has_scope() ? scope()->num_parameters() : parameter_count_;
218 } 209 }
219 210
220 211
221 int CompilationInfo::num_parameters_including_this() const { 212 int CompilationInfo::num_parameters_including_this() const {
222 return num_parameters() + (is_this_defined() ? 1 : 0); 213 return num_parameters() + (is_this_defined() ? 1 : 0);
223 } 214 }
224 215
225 216
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 function, result, 982 function, result,
992 Compiler::NOT_CONCURRENT).ToHandle(&opt_code)) { 983 Compiler::NOT_CONCURRENT).ToHandle(&opt_code)) {
993 result = opt_code; 984 result = opt_code;
994 } 985 }
995 } 986 }
996 987
997 return result; 988 return result;
998 } 989 }
999 990
1000 991
1001 MaybeHandle<Code> Compiler::GetStubCode(Handle<JSFunction> function,
1002 CodeStub* stub) {
1003 // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
1004 Zone zone;
1005 ParseInfo parse_info(&zone, function);
1006 CompilationInfo info(&parse_info);
1007 info.SetFunctionType(stub->GetCallInterfaceDescriptor().GetFunctionType());
1008 info.MarkAsFunctionContextSpecializing();
1009 info.MarkAsDeoptimizationEnabled();
1010 info.SetStub(stub);
1011
1012 // Run a "mini pipeline", extracted from compiler.cc.
1013 if (!ParseAndAnalyze(&parse_info)) return MaybeHandle<Code>();
1014 return compiler::Pipeline(&info).GenerateCode();
1015 }
1016
1017
1018 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { 992 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) {
1019 if (function->is_compiled()) return true; 993 if (function->is_compiled()) return true;
1020 MaybeHandle<Code> maybe_code = Compiler::GetLazyCode(function); 994 MaybeHandle<Code> maybe_code = Compiler::GetLazyCode(function);
1021 Handle<Code> code; 995 Handle<Code> code;
1022 if (!maybe_code.ToHandle(&code)) { 996 if (!maybe_code.ToHandle(&code)) {
1023 if (flag == CLEAR_EXCEPTION) { 997 if (flag == CLEAR_EXCEPTION) {
1024 function->GetIsolate()->clear_pending_exception(); 998 function->GetIsolate()->clear_pending_exception();
1025 } 999 }
1026 return false; 1000 return false;
1027 } 1001 }
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 } 1777 }
1804 1778
1805 #if DEBUG 1779 #if DEBUG
1806 void CompilationInfo::PrintAstForTesting() { 1780 void CompilationInfo::PrintAstForTesting() {
1807 PrintF("--- Source from AST ---\n%s\n", 1781 PrintF("--- Source from AST ---\n%s\n",
1808 PrettyPrinter(isolate()).PrintProgram(literal())); 1782 PrettyPrinter(isolate()).PrintProgram(literal()));
1809 } 1783 }
1810 #endif 1784 #endif
1811 } // namespace internal 1785 } // namespace internal
1812 } // namespace v8 1786 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698