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

Side by Side Diff: src/compiler.h

Issue 1297203002: Add CompileInfo::GetDebugName() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@interpreter_immed_bytecodes
Patch Set: Add CompilationInfo::ShouldEnsureSpaceForLazyDeopt() Created 5 years, 4 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 #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.h" 9 #include "src/ast.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
11 #include "src/compilation-dependencies.h" 11 #include "src/compilation-dependencies.h"
12 #include "src/interpreter/bytecodes.h"
12 #include "src/signature.h" 13 #include "src/signature.h"
13 #include "src/zone.h" 14 #include "src/zone.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
17 18
18 class AstValueFactory; 19 class AstValueFactory;
19 class HydrogenCodeStub; 20 class HydrogenCodeStub;
20 class JavaScriptFrame; 21 class JavaScriptFrame;
21 class ParseInfo; 22 class ParseInfo;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 kDisableFutureOptimization = 1 << 12, 129 kDisableFutureOptimization = 1 << 12,
129 kSplittingEnabled = 1 << 13, 130 kSplittingEnabled = 1 << 13,
130 kTypeFeedbackEnabled = 1 << 14, 131 kTypeFeedbackEnabled = 1 << 14,
131 kDeoptimizationEnabled = 1 << 15, 132 kDeoptimizationEnabled = 1 << 15,
132 kSourcePositionsEnabled = 1 << 16, 133 kSourcePositionsEnabled = 1 << 16,
133 kFirstCompile = 1 << 17, 134 kFirstCompile = 1 << 17,
134 }; 135 };
135 136
136 explicit CompilationInfo(ParseInfo* parse_info); 137 explicit CompilationInfo(ParseInfo* parse_info);
137 CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone); 138 CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone);
139 CompilationInfo(interpreter::Bytecode bytecode, Isolate* isolate, Zone* zone);
138 virtual ~CompilationInfo(); 140 virtual ~CompilationInfo();
139 141
140 ParseInfo* parse_info() const { return parse_info_; } 142 ParseInfo* parse_info() const { return parse_info_; }
141 143
142 // ----------------------------------------------------------- 144 // -----------------------------------------------------------
143 // TODO(titzer): inline and delete accessors of ParseInfo 145 // TODO(titzer): inline and delete accessors of ParseInfo
144 // ----------------------------------------------------------- 146 // -----------------------------------------------------------
145 Handle<Script> script() const; 147 Handle<Script> script() const;
146 bool is_eval() const; 148 bool is_eval() const;
147 bool is_native() const; 149 bool is_native() const;
(...skipping 11 matching lines...) Expand all
159 bool has_scope() const; 161 bool has_scope() const;
160 // ----------------------------------------------------------- 162 // -----------------------------------------------------------
161 163
162 Isolate* isolate() const { 164 Isolate* isolate() const {
163 return isolate_; 165 return isolate_;
164 } 166 }
165 Zone* zone() { return zone_; } 167 Zone* zone() { return zone_; }
166 bool is_osr() const { return !osr_ast_id_.IsNone(); } 168 bool is_osr() const { return !osr_ast_id_.IsNone(); }
167 Handle<Code> code() const { return code_; } 169 Handle<Code> code() const { return code_; }
168 CodeStub* code_stub() const { return code_stub_; } 170 CodeStub* code_stub() const { return code_stub_; }
171 interpreter::Bytecode bytecode() const { return bytecode_; }
169 BailoutId osr_ast_id() const { return osr_ast_id_; } 172 BailoutId osr_ast_id() const { return osr_ast_id_; }
170 Handle<Code> unoptimized_code() const { return unoptimized_code_; } 173 Handle<Code> unoptimized_code() const { return unoptimized_code_; }
171 int opt_count() const { return opt_count_; } 174 int opt_count() const { return opt_count_; }
172 int num_parameters() const; 175 int num_parameters() const;
173 int num_parameters_including_this() const; 176 int num_parameters_including_this() const;
174 bool is_this_defined() const; 177 bool is_this_defined() const;
175 int num_heap_slots() const; 178 int num_heap_slots() const;
176 Code::Flags flags() const; 179 Code::Flags flags() const;
177 180
178 void set_parameter_count(int parameter_count) { 181 void set_parameter_count(int parameter_count) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 291 }
289 292
290 GlobalObject* global_object() const { 293 GlobalObject* global_object() const {
291 return has_global_object() ? closure()->context()->global_object() : NULL; 294 return has_global_object() ? closure()->context()->global_object() : NULL;
292 } 295 }
293 296
294 // Accessors for the different compilation modes. 297 // Accessors for the different compilation modes.
295 bool IsOptimizing() const { return mode_ == OPTIMIZE; } 298 bool IsOptimizing() const { return mode_ == OPTIMIZE; }
296 bool IsOptimizable() const { return mode_ == BASE; } 299 bool IsOptimizable() const { return mode_ == BASE; }
297 bool IsStub() const { return mode_ == STUB; } 300 bool IsStub() const { return mode_ == STUB; }
301 bool IsBytecodeHandler() const { return mode_ == BYTECODE_HANDLER; }
298 void SetOptimizing(BailoutId osr_ast_id, Handle<Code> unoptimized) { 302 void SetOptimizing(BailoutId osr_ast_id, Handle<Code> unoptimized) {
299 DCHECK(!shared_info().is_null()); 303 DCHECK(!shared_info().is_null());
300 SetMode(OPTIMIZE); 304 SetMode(OPTIMIZE);
301 osr_ast_id_ = osr_ast_id; 305 osr_ast_id_ = osr_ast_id;
302 unoptimized_code_ = unoptimized; 306 unoptimized_code_ = unoptimized;
303 optimization_id_ = isolate()->NextOptimizationId(); 307 optimization_id_ = isolate()->NextOptimizationId();
304 } 308 }
305 309
306 void SetFunctionType(Type::FunctionType* function_type) { 310 void SetFunctionType(Type::FunctionType* function_type) {
307 function_type_ = function_type; 311 function_type_ = function_type;
308 } 312 }
309 Type::FunctionType* function_type() const { return function_type_; } 313 Type::FunctionType* function_type() const { return function_type_; }
310 314
311 void SetStub(CodeStub* code_stub) { 315 void SetStub(CodeStub* code_stub) {
312 SetMode(STUB); 316 SetMode(STUB);
313 code_stub_ = code_stub; 317 code_stub_ = code_stub;
314 } 318 }
315 319
316 // Deoptimization support. 320 // Deoptimization support.
317 bool HasDeoptimizationSupport() const { 321 bool HasDeoptimizationSupport() const {
318 return GetFlag(kDeoptimizationSupport); 322 return GetFlag(kDeoptimizationSupport);
319 } 323 }
320 void EnableDeoptimizationSupport() { 324 void EnableDeoptimizationSupport() {
321 DCHECK(IsOptimizable()); 325 DCHECK(IsOptimizable());
322 SetFlag(kDeoptimizationSupport); 326 SetFlag(kDeoptimizationSupport);
323 } 327 }
328 bool ShouldEnsureSpaceForLazyDeopt() {
329 return !IsStub() && !IsBytecodeHandler();
330 }
324 331
325 // Determines whether or not to insert a self-optimization header. 332 // Determines whether or not to insert a self-optimization header.
326 bool ShouldSelfOptimize(); 333 bool ShouldSelfOptimize();
327 334
328 void set_deferred_handles(DeferredHandles* deferred_handles) { 335 void set_deferred_handles(DeferredHandles* deferred_handles) {
329 DCHECK(deferred_handles_ == NULL); 336 DCHECK(deferred_handles_ == NULL);
330 deferred_handles_ = deferred_handles; 337 deferred_handles_ = deferred_handles;
331 } 338 }
332 339
333 void ReopenHandlesInNewHandleScope() { 340 void ReopenHandlesInNewHandleScope() {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 430 }
424 } 431 }
425 432
426 private: 433 private:
427 // Compilation mode. 434 // Compilation mode.
428 // BASE is generated by the full codegen, optionally prepared for bailouts. 435 // BASE is generated by the full codegen, optionally prepared for bailouts.
429 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 436 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
430 enum Mode { 437 enum Mode {
431 BASE, 438 BASE,
432 OPTIMIZE, 439 OPTIMIZE,
433 STUB 440 STUB,
441 BYTECODE_HANDLER
titzer 2015/08/21 13:37:21 Do we really need a new mode? What does it control
rmcilroy 2015/08/21 16:41:05 Removed this mode and replaced it's need with debu
434 }; 442 };
435 443
436 CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, Mode mode, 444 CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
437 Isolate* isolate, Zone* zone); 445 interpreter::Bytecode bytecode, Mode mode, Isolate* isolate,
446 Zone* zone);
438 447
439 Isolate* isolate_; 448 Isolate* isolate_;
440 449
441 void SetMode(Mode mode) { 450 void SetMode(Mode mode) {
442 mode_ = mode; 451 mode_ = mode;
443 } 452 }
444 453
445 void SetFlag(Flag flag) { flags_ |= flag; } 454 void SetFlag(Flag flag) { flags_ |= flag; }
446 455
447 void SetFlag(Flag flag, bool value) { 456 void SetFlag(Flag flag, bool value) {
448 flags_ = value ? flags_ | flag : flags_ & ~flag; 457 flags_ = value ? flags_ | flag : flags_ & ~flag;
449 } 458 }
450 459
451 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; } 460 bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; }
452 461
453 unsigned flags_; 462 unsigned flags_;
454 463
455 // For compiled stubs, the stub object 464 // For compiled stubs, the stub object
456 CodeStub* code_stub_; 465 CodeStub* code_stub_;
466 // For compiled bytecode handlers, the bytecode
467 interpreter::Bytecode bytecode_;
titzer 2015/08/21 13:37:21 AFAICT this is only used for debugging purposes in
rmcilroy 2015/08/21 16:41:05 Done with GetDebugName as discussed.
457 // The compiled code. 468 // The compiled code.
458 Handle<Code> code_; 469 Handle<Code> code_;
459 470
460 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo. 471 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo.
461 Handle<TypeFeedbackVector> feedback_vector_; 472 Handle<TypeFeedbackVector> feedback_vector_;
462 473
463 // Compilation mode flag and whether deoptimization is allowed. 474 // Compilation mode flag and whether deoptimization is allowed.
464 Mode mode_; 475 Mode mode_;
465 BailoutId osr_ast_id_; 476 BailoutId osr_ast_id_;
466 // The unoptimized code we patched for OSR may not be the shared code 477 // The unoptimized code we patched for OSR may not be the shared code
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 Zone zone_; 712 Zone zone_;
702 size_t info_zone_start_allocation_size_; 713 size_t info_zone_start_allocation_size_;
703 base::ElapsedTimer timer_; 714 base::ElapsedTimer timer_;
704 715
705 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); 716 DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
706 }; 717 };
707 718
708 } } // namespace v8::internal 719 } } // namespace v8::internal
709 720
710 #endif // V8_COMPILER_H_ 721 #endif // V8_COMPILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698