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

Side by Side Diff: src/compiler.h

Issue 1604543002: [compiler] Remove CodeStub from CompilationInfo (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 4 years, 11 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
« no previous file with comments | « src/codegen.cc ('k') | src/compiler.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 #ifndef V8_COMPILER_H_ 5 #ifndef V8_COMPILER_H_
6 #define V8_COMPILER_H_ 6 #define V8_COMPILER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 kInliningEnabled = 1 << 11, 60 kInliningEnabled = 1 << 11,
61 kTypingEnabled = 1 << 12, 61 kTypingEnabled = 1 << 12,
62 kDisableFutureOptimization = 1 << 13, 62 kDisableFutureOptimization = 1 << 13,
63 kSplittingEnabled = 1 << 14, 63 kSplittingEnabled = 1 << 14,
64 kDeoptimizationEnabled = 1 << 16, 64 kDeoptimizationEnabled = 1 << 16,
65 kSourcePositionsEnabled = 1 << 17, 65 kSourcePositionsEnabled = 1 << 17,
66 kFirstCompile = 1 << 18, 66 kFirstCompile = 1 << 18,
67 }; 67 };
68 68
69 explicit CompilationInfo(ParseInfo* parse_info); 69 explicit CompilationInfo(ParseInfo* parse_info);
70 CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone); 70 CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone,
71 CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone); 71 Code::Flags code_flags = Code::ComputeFlags(Code::STUB));
72 virtual ~CompilationInfo(); 72 virtual ~CompilationInfo();
73 73
74 ParseInfo* parse_info() const { return parse_info_; } 74 ParseInfo* parse_info() const { return parse_info_; }
75 75
76 // ----------------------------------------------------------- 76 // -----------------------------------------------------------
77 // TODO(titzer): inline and delete accessors of ParseInfo 77 // TODO(titzer): inline and delete accessors of ParseInfo
78 // ----------------------------------------------------------- 78 // -----------------------------------------------------------
79 Handle<Script> script() const; 79 Handle<Script> script() const;
80 bool is_eval() const; 80 bool is_eval() const;
81 bool is_native() const; 81 bool is_native() const;
82 bool is_module() const; 82 bool is_module() const;
83 LanguageMode language_mode() const; 83 LanguageMode language_mode() const;
84 Handle<JSFunction> closure() const; 84 Handle<JSFunction> closure() const;
85 FunctionLiteral* literal() const; 85 FunctionLiteral* literal() const;
86 Scope* scope() const; 86 Scope* scope() const;
87 Handle<Context> context() const; 87 Handle<Context> context() const;
88 Handle<SharedFunctionInfo> shared_info() const; 88 Handle<SharedFunctionInfo> shared_info() const;
89 bool has_shared_info() const; 89 bool has_shared_info() const;
90 bool has_context() const; 90 bool has_context() const;
91 bool has_literal() const; 91 bool has_literal() const;
92 bool has_scope() const; 92 bool has_scope() const;
93 // ----------------------------------------------------------- 93 // -----------------------------------------------------------
94 94
95 Isolate* isolate() const { 95 Isolate* isolate() const {
96 return isolate_; 96 return isolate_;
97 } 97 }
98 Zone* zone() { return zone_; } 98 Zone* zone() { return zone_; }
99 bool is_osr() const { return !osr_ast_id_.IsNone(); } 99 bool is_osr() const { return !osr_ast_id_.IsNone(); }
100 Handle<Code> code() const { return code_; } 100 Handle<Code> code() const { return code_; }
101 CodeStub* code_stub() const { return code_stub_; } 101 Code::Flags code_flags() const { return code_flags_; }
102 BailoutId osr_ast_id() const { return osr_ast_id_; } 102 BailoutId osr_ast_id() const { return osr_ast_id_; }
103 Handle<Code> unoptimized_code() const { return unoptimized_code_; } 103 Handle<Code> unoptimized_code() const { return unoptimized_code_; }
104 int opt_count() const { return opt_count_; } 104 int opt_count() const { return opt_count_; }
105 int num_parameters() const; 105 int num_parameters() const;
106 int num_parameters_including_this() const; 106 int num_parameters_including_this() const;
107 bool is_this_defined() const; 107 bool is_this_defined() const;
108 int num_heap_slots() const; 108 int num_heap_slots() const;
109 109
110 void set_parameter_count(int parameter_count) { 110 void set_parameter_count(int parameter_count) {
111 DCHECK(IsStub()); 111 DCHECK(IsStub());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 void MarkAsCompiled() { SetFlag(kFirstCompile, false); } 206 void MarkAsCompiled() { SetFlag(kFirstCompile, false); }
207 207
208 bool is_first_compile() const { return GetFlag(kFirstCompile); } 208 bool is_first_compile() const { return GetFlag(kFirstCompile); }
209 209
210 bool GeneratePreagedPrologue() const { 210 bool GeneratePreagedPrologue() const {
211 // Generate a pre-aged prologue if we are optimizing for size, which 211 // Generate a pre-aged prologue if we are optimizing for size, which
212 // will make code flushing more aggressive. Only apply to Code::FUNCTION, 212 // will make code flushing more aggressive. Only apply to Code::FUNCTION,
213 // since StaticMarkingVisitor::IsFlushable only flushes proper functions. 213 // since StaticMarkingVisitor::IsFlushable only flushes proper functions.
214 return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() && 214 return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
215 !is_debug() && output_code_kind_ == Code::FUNCTION; 215 !is_debug() && output_code_kind() == Code::FUNCTION;
216 } 216 }
217 217
218 void EnsureFeedbackVector(); 218 void EnsureFeedbackVector();
219 Handle<TypeFeedbackVector> feedback_vector() const { 219 Handle<TypeFeedbackVector> feedback_vector() const {
220 return feedback_vector_; 220 return feedback_vector_;
221 } 221 }
222 void SetCode(Handle<Code> code) { code_ = code; } 222 void SetCode(Handle<Code> code) { code_ = code; }
223 223
224 void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) { 224 void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) {
225 bytecode_array_ = bytecode_array; 225 bytecode_array_ = bytecode_array;
(...skipping 20 matching lines...) Expand all
246 246
247 // Accessors for the different compilation modes. 247 // Accessors for the different compilation modes.
248 bool IsOptimizing() const { return mode_ == OPTIMIZE; } 248 bool IsOptimizing() const { return mode_ == OPTIMIZE; }
249 bool IsStub() const { return mode_ == STUB; } 249 bool IsStub() const { return mode_ == STUB; }
250 void SetOptimizing(BailoutId osr_ast_id, Handle<Code> unoptimized) { 250 void SetOptimizing(BailoutId osr_ast_id, Handle<Code> unoptimized) {
251 DCHECK(has_shared_info()); 251 DCHECK(has_shared_info());
252 SetMode(OPTIMIZE); 252 SetMode(OPTIMIZE);
253 osr_ast_id_ = osr_ast_id; 253 osr_ast_id_ = osr_ast_id;
254 unoptimized_code_ = unoptimized; 254 unoptimized_code_ = unoptimized;
255 optimization_id_ = isolate()->NextOptimizationId(); 255 optimization_id_ = isolate()->NextOptimizationId();
256 set_output_code_kind(Code::OPTIMIZED_FUNCTION); 256 code_flags_ =
257 Code::KindField::update(code_flags_, Code::OPTIMIZED_FUNCTION);
257 } 258 }
258 259
259 // Deoptimization support. 260 // Deoptimization support.
260 bool HasDeoptimizationSupport() const { 261 bool HasDeoptimizationSupport() const {
261 return GetFlag(kDeoptimizationSupport); 262 return GetFlag(kDeoptimizationSupport);
262 } 263 }
263 void EnableDeoptimizationSupport() { 264 void EnableDeoptimizationSupport() {
264 DCHECK_EQ(BASE, mode_); 265 DCHECK_EQ(BASE, mode_);
265 SetFlag(kDeoptimizationSupport); 266 SetFlag(kDeoptimizationSupport);
266 } 267 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 InlinedFunctionList const& inlined_functions() const { 356 InlinedFunctionList const& inlined_functions() const {
356 return inlined_functions_; 357 return inlined_functions_;
357 } 358 }
358 359
359 void AddInlinedFunction(Handle<SharedFunctionInfo> inlined_function) { 360 void AddInlinedFunction(Handle<SharedFunctionInfo> inlined_function) {
360 inlined_functions_.push_back(InlinedFunctionHolder(inlined_function)); 361 inlined_functions_.push_back(InlinedFunctionHolder(inlined_function));
361 } 362 }
362 363
363 base::SmartArrayPointer<char> GetDebugName() const; 364 base::SmartArrayPointer<char> GetDebugName() const;
364 365
365 Code::Kind output_code_kind() const { return output_code_kind_; } 366 Code::Kind output_code_kind() const {
366 367 return Code::ExtractKindFromFlags(code_flags_);
367 void set_output_code_kind(Code::Kind kind) { output_code_kind_ = kind; } 368 }
368 369
369 protected: 370 protected:
370 ParseInfo* parse_info_; 371 ParseInfo* parse_info_;
371 372
372 void DisableFutureOptimization() { 373 void DisableFutureOptimization() {
373 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) { 374 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) {
374 shared_info()->DisableOptimization(bailout_reason()); 375 shared_info()->DisableOptimization(bailout_reason());
375 } 376 }
376 } 377 }
377 378
378 private: 379 private:
379 // Compilation mode. 380 // Compilation mode.
380 // BASE is generated by the full codegen, optionally prepared for bailouts. 381 // BASE is generated by the full codegen, optionally prepared for bailouts.
381 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 382 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
382 enum Mode { 383 enum Mode {
383 BASE, 384 BASE,
384 OPTIMIZE, 385 OPTIMIZE,
385 STUB 386 STUB
386 }; 387 };
387 388
388 CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, 389 CompilationInfo(ParseInfo* parse_info, const char* debug_name,
389 const char* debug_name, Mode mode, Isolate* isolate, 390 Code::Flags code_flags, Mode mode, Isolate* isolate,
390 Zone* zone); 391 Zone* zone);
391 392
392 Isolate* isolate_; 393 Isolate* isolate_;
393 394
394 void SetMode(Mode mode) { 395 void SetMode(Mode mode) {
395 mode_ = mode; 396 mode_ = mode;
396 } 397 }
397 398
398 void SetFlag(Flag flag) { flags_ |= flag; } 399 void SetFlag(Flag flag) { flags_ |= flag; }
399 400
400 void SetFlag(Flag flag, bool value) { 401 void SetFlag(Flag flag, bool value) {
401 flags_ = value ? flags_ | flag : flags_ & ~flag; 402 flags_ = value ? flags_ | flag : flags_ & ~flag;
402 } 403 }
403 404
404 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } 405 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; }
405 406
406 unsigned flags_; 407 unsigned flags_;
407 408
408 Code::Kind output_code_kind_; 409 Code::Flags code_flags_;
409 410
410 // For compiled stubs, the stub object
411 CodeStub* code_stub_;
412 // The compiled code. 411 // The compiled code.
413 Handle<Code> code_; 412 Handle<Code> code_;
414 413
415 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo. 414 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo.
416 Handle<TypeFeedbackVector> feedback_vector_; 415 Handle<TypeFeedbackVector> feedback_vector_;
417 416
418 // Compilation mode flag and whether deoptimization is allowed. 417 // Compilation mode flag and whether deoptimization is allowed.
419 Mode mode_; 418 Mode mode_;
420 BailoutId osr_ast_id_; 419 BailoutId osr_ast_id_;
421 // The unoptimized code we patched for OSR may not be the shared code 420 // The unoptimized code we patched for OSR may not be the shared code
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 size_t info_zone_start_allocation_size_; 657 size_t info_zone_start_allocation_size_;
659 base::ElapsedTimer timer_; 658 base::ElapsedTimer timer_;
660 659
661 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); 660 DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
662 }; 661 };
663 662
664 } // namespace internal 663 } // namespace internal
665 } // namespace v8 664 } // namespace v8
666 665
667 #endif // V8_COMPILER_H_ 666 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « src/codegen.cc ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698