OLD | NEW |
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" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 kDisableFutureOptimization = 1 << 12, | 128 kDisableFutureOptimization = 1 << 12, |
129 kSplittingEnabled = 1 << 13, | 129 kSplittingEnabled = 1 << 13, |
130 kTypeFeedbackEnabled = 1 << 14, | 130 kTypeFeedbackEnabled = 1 << 14, |
131 kDeoptimizationEnabled = 1 << 15, | 131 kDeoptimizationEnabled = 1 << 15, |
132 kSourcePositionsEnabled = 1 << 16, | 132 kSourcePositionsEnabled = 1 << 16, |
133 kFirstCompile = 1 << 17, | 133 kFirstCompile = 1 << 17, |
134 }; | 134 }; |
135 | 135 |
136 explicit CompilationInfo(ParseInfo* parse_info); | 136 explicit CompilationInfo(ParseInfo* parse_info); |
137 CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone); | 137 CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone); |
| 138 CompilationInfo(const char* code_stub_debug_name, Isolate* isolate, |
| 139 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 osr_ast_id_ = osr_ast_id; | 301 osr_ast_id_ = osr_ast_id; |
300 unoptimized_code_ = unoptimized; | 302 unoptimized_code_ = unoptimized; |
301 optimization_id_ = isolate()->NextOptimizationId(); | 303 optimization_id_ = isolate()->NextOptimizationId(); |
302 } | 304 } |
303 | 305 |
304 void SetFunctionType(Type::FunctionType* function_type) { | 306 void SetFunctionType(Type::FunctionType* function_type) { |
305 function_type_ = function_type; | 307 function_type_ = function_type; |
306 } | 308 } |
307 Type::FunctionType* function_type() const { return function_type_; } | 309 Type::FunctionType* function_type() const { return function_type_; } |
308 | 310 |
309 void SetStub(CodeStub* code_stub) { | 311 void SetStub(CodeStub* code_stub); |
310 SetMode(STUB); | |
311 code_stub_ = code_stub; | |
312 } | |
313 | 312 |
314 // Deoptimization support. | 313 // Deoptimization support. |
315 bool HasDeoptimizationSupport() const { | 314 bool HasDeoptimizationSupport() const { |
316 return GetFlag(kDeoptimizationSupport); | 315 return GetFlag(kDeoptimizationSupport); |
317 } | 316 } |
318 void EnableDeoptimizationSupport() { | 317 void EnableDeoptimizationSupport() { |
319 DCHECK_EQ(BASE, mode_); | 318 DCHECK_EQ(BASE, mode_); |
320 SetFlag(kDeoptimizationSupport); | 319 SetFlag(kDeoptimizationSupport); |
321 } | 320 } |
| 321 bool ShouldEnsureSpaceForLazyDeopt() { return !IsStub(); } |
322 | 322 |
323 // Determines whether or not to insert a self-optimization header. | 323 // Determines whether or not to insert a self-optimization header. |
324 bool ShouldSelfOptimize(); | 324 bool ShouldSelfOptimize(); |
325 | 325 |
326 void set_deferred_handles(DeferredHandles* deferred_handles) { | 326 void set_deferred_handles(DeferredHandles* deferred_handles) { |
327 DCHECK(deferred_handles_ == NULL); | 327 DCHECK(deferred_handles_ == NULL); |
328 deferred_handles_ = deferred_handles; | 328 deferred_handles_ = deferred_handles; |
329 } | 329 } |
330 | 330 |
331 void ReopenHandlesInNewHandleScope() { | 331 void ReopenHandlesInNewHandleScope() { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 Handle<Code> GenerateCodeStub(); | 405 Handle<Code> GenerateCodeStub(); |
406 | 406 |
407 typedef std::vector<Handle<SharedFunctionInfo>> InlinedFunctionList; | 407 typedef std::vector<Handle<SharedFunctionInfo>> InlinedFunctionList; |
408 InlinedFunctionList const& inlined_functions() const { | 408 InlinedFunctionList const& inlined_functions() const { |
409 return inlined_functions_; | 409 return inlined_functions_; |
410 } | 410 } |
411 void AddInlinedFunction(Handle<SharedFunctionInfo> inlined_function) { | 411 void AddInlinedFunction(Handle<SharedFunctionInfo> inlined_function) { |
412 inlined_functions_.push_back(inlined_function); | 412 inlined_functions_.push_back(inlined_function); |
413 } | 413 } |
414 | 414 |
| 415 base::SmartArrayPointer<char> GetDebugName() const; |
| 416 |
415 protected: | 417 protected: |
416 ParseInfo* parse_info_; | 418 ParseInfo* parse_info_; |
417 | 419 |
418 void DisableFutureOptimization() { | 420 void DisableFutureOptimization() { |
419 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) { | 421 if (GetFlag(kDisableFutureOptimization) && has_shared_info()) { |
420 shared_info()->DisableOptimization(bailout_reason()); | 422 shared_info()->DisableOptimization(bailout_reason()); |
421 } | 423 } |
422 } | 424 } |
423 | 425 |
424 private: | 426 private: |
425 // Compilation mode. | 427 // Compilation mode. |
426 // BASE is generated by the full codegen, optionally prepared for bailouts. | 428 // BASE is generated by the full codegen, optionally prepared for bailouts. |
427 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. | 429 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. |
428 enum Mode { | 430 enum Mode { |
429 BASE, | 431 BASE, |
430 OPTIMIZE, | 432 OPTIMIZE, |
431 STUB | 433 STUB |
432 }; | 434 }; |
433 | 435 |
434 CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, Mode mode, | 436 CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub, |
435 Isolate* isolate, Zone* zone); | 437 const char* code_stub_debug_name, Mode mode, Isolate* isolate, |
| 438 Zone* zone); |
436 | 439 |
437 Isolate* isolate_; | 440 Isolate* isolate_; |
438 | 441 |
439 void SetMode(Mode mode) { | 442 void SetMode(Mode mode) { |
440 mode_ = mode; | 443 mode_ = mode; |
441 } | 444 } |
442 | 445 |
443 void SetFlag(Flag flag) { flags_ |= flag; } | 446 void SetFlag(Flag flag) { flags_ |= flag; } |
444 | 447 |
445 void SetFlag(Flag flag, bool value) { | 448 void SetFlag(Flag flag, bool value) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 497 |
495 int optimization_id_; | 498 int optimization_id_; |
496 | 499 |
497 int osr_expr_stack_height_; | 500 int osr_expr_stack_height_; |
498 | 501 |
499 // The current OSR frame for specialization or {nullptr}. | 502 // The current OSR frame for specialization or {nullptr}. |
500 JavaScriptFrame* osr_frame_ = nullptr; | 503 JavaScriptFrame* osr_frame_ = nullptr; |
501 | 504 |
502 Type::FunctionType* function_type_; | 505 Type::FunctionType* function_type_; |
503 | 506 |
| 507 const char* code_stub_debug_name_; |
| 508 |
504 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 509 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
505 }; | 510 }; |
506 | 511 |
507 | 512 |
508 // A wrapper around a CompilationInfo that detaches the Handles from | 513 // A wrapper around a CompilationInfo that detaches the Handles from |
509 // the underlying DeferredHandleScope and stores them in info_ on | 514 // the underlying DeferredHandleScope and stores them in info_ on |
510 // destruction. | 515 // destruction. |
511 class CompilationHandleScope BASE_EMBEDDED { | 516 class CompilationHandleScope BASE_EMBEDDED { |
512 public: | 517 public: |
513 explicit CompilationHandleScope(CompilationInfo* info) | 518 explicit CompilationHandleScope(CompilationInfo* info) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 Zone zone_; | 704 Zone zone_; |
700 size_t info_zone_start_allocation_size_; | 705 size_t info_zone_start_allocation_size_; |
701 base::ElapsedTimer timer_; | 706 base::ElapsedTimer timer_; |
702 | 707 |
703 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 708 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
704 }; | 709 }; |
705 | 710 |
706 } } // namespace v8::internal | 711 } } // namespace v8::internal |
707 | 712 |
708 #endif // V8_COMPILER_H_ | 713 #endif // V8_COMPILER_H_ |
OLD | NEW |