| 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" |
| 11 #include "src/compilation-dependencies.h" | 11 #include "src/compilation-dependencies.h" |
| 12 #include "src/signature.h" | 12 #include "src/signature.h" |
| 13 #include "src/zone.h" | 13 #include "src/zone.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 class AstValueFactory; | 18 class AstValueFactory; |
| 19 class HydrogenCodeStub; | 19 class HydrogenCodeStub; |
| 20 class JavaScriptFrame; |
| 20 class ParseInfo; | 21 class ParseInfo; |
| 21 class ScriptData; | 22 class ScriptData; |
| 22 | 23 |
| 23 struct OffsetRange { | 24 struct OffsetRange { |
| 24 OffsetRange(int from, int to) : from(from), to(to) {} | 25 OffsetRange(int from, int to) : from(from), to(to) {} |
| 25 int from; | 26 int from; |
| 26 int to; | 27 int to; |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 | 30 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 kDeferredCalling = 1 << 0, | 116 kDeferredCalling = 1 << 0, |
| 116 kNonDeferredCalling = 1 << 1, | 117 kNonDeferredCalling = 1 << 1, |
| 117 kSavesCallerDoubles = 1 << 2, | 118 kSavesCallerDoubles = 1 << 2, |
| 118 kRequiresFrame = 1 << 3, | 119 kRequiresFrame = 1 << 3, |
| 119 kMustNotHaveEagerFrame = 1 << 4, | 120 kMustNotHaveEagerFrame = 1 << 4, |
| 120 kDeoptimizationSupport = 1 << 5, | 121 kDeoptimizationSupport = 1 << 5, |
| 121 kDebug = 1 << 6, | 122 kDebug = 1 << 6, |
| 122 kCompilingForDebugging = 1 << 7, | 123 kCompilingForDebugging = 1 << 7, |
| 123 kSerializing = 1 << 8, | 124 kSerializing = 1 << 8, |
| 124 kContextSpecializing = 1 << 9, | 125 kContextSpecializing = 1 << 9, |
| 125 kInliningEnabled = 1 << 10, | 126 kFrameSpecializing = 1 << 10, |
| 126 kTypingEnabled = 1 << 11, | 127 kInliningEnabled = 1 << 11, |
| 127 kDisableFutureOptimization = 1 << 12, | 128 kTypingEnabled = 1 << 12, |
| 128 kSplittingEnabled = 1 << 13, | 129 kDisableFutureOptimization = 1 << 13, |
| 129 kTypeFeedbackEnabled = 1 << 14, | 130 kSplittingEnabled = 1 << 14, |
| 130 kDeoptimizationEnabled = 1 << 15, | 131 kTypeFeedbackEnabled = 1 << 15, |
| 131 kSourcePositionsEnabled = 1 << 16, | 132 kDeoptimizationEnabled = 1 << 16, |
| 132 kFirstCompile = 1 << 17, | 133 kSourcePositionsEnabled = 1 << 17, |
| 134 kFirstCompile = 1 << 18, |
| 133 }; | 135 }; |
| 134 | 136 |
| 135 explicit CompilationInfo(ParseInfo* parse_info); | 137 explicit CompilationInfo(ParseInfo* parse_info); |
| 136 CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone); | 138 CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone); |
| 137 virtual ~CompilationInfo(); | 139 virtual ~CompilationInfo(); |
| 138 | 140 |
| 139 ParseInfo* parse_info() const { return parse_info_; } | 141 ParseInfo* parse_info() const { return parse_info_; } |
| 140 | 142 |
| 141 // ----------------------------------------------------------- | 143 // ----------------------------------------------------------- |
| 142 // TODO(titzer): inline and delete accessors of ParseInfo | 144 // TODO(titzer): inline and delete accessors of ParseInfo |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 bool is_debug() const { return GetFlag(kDebug); } | 212 bool is_debug() const { return GetFlag(kDebug); } |
| 211 | 213 |
| 212 void PrepareForSerializing() { SetFlag(kSerializing); } | 214 void PrepareForSerializing() { SetFlag(kSerializing); } |
| 213 | 215 |
| 214 bool will_serialize() const { return GetFlag(kSerializing); } | 216 bool will_serialize() const { return GetFlag(kSerializing); } |
| 215 | 217 |
| 216 void MarkAsContextSpecializing() { SetFlag(kContextSpecializing); } | 218 void MarkAsContextSpecializing() { SetFlag(kContextSpecializing); } |
| 217 | 219 |
| 218 bool is_context_specializing() const { return GetFlag(kContextSpecializing); } | 220 bool is_context_specializing() const { return GetFlag(kContextSpecializing); } |
| 219 | 221 |
| 222 void MarkAsFrameSpecializing() { SetFlag(kFrameSpecializing); } |
| 223 |
| 224 bool is_frame_specializing() const { return GetFlag(kFrameSpecializing); } |
| 225 |
| 220 void MarkAsTypeFeedbackEnabled() { SetFlag(kTypeFeedbackEnabled); } | 226 void MarkAsTypeFeedbackEnabled() { SetFlag(kTypeFeedbackEnabled); } |
| 221 | 227 |
| 222 bool is_type_feedback_enabled() const { | 228 bool is_type_feedback_enabled() const { |
| 223 return GetFlag(kTypeFeedbackEnabled); | 229 return GetFlag(kTypeFeedbackEnabled); |
| 224 } | 230 } |
| 225 | 231 |
| 226 void MarkAsDeoptimizationEnabled() { SetFlag(kDeoptimizationEnabled); } | 232 void MarkAsDeoptimizationEnabled() { SetFlag(kDeoptimizationEnabled); } |
| 227 | 233 |
| 228 bool is_deoptimization_enabled() const { | 234 bool is_deoptimization_enabled() const { |
| 229 return GetFlag(kDeoptimizationEnabled); | 235 return GetFlag(kDeoptimizationEnabled); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure()); | 387 return osr_ast_id_ == osr_ast_id && function.is_identical_to(closure()); |
| 382 } | 388 } |
| 383 | 389 |
| 384 int optimization_id() const { return optimization_id_; } | 390 int optimization_id() const { return optimization_id_; } |
| 385 | 391 |
| 386 int osr_expr_stack_height() { return osr_expr_stack_height_; } | 392 int osr_expr_stack_height() { return osr_expr_stack_height_; } |
| 387 void set_osr_expr_stack_height(int height) { | 393 void set_osr_expr_stack_height(int height) { |
| 388 DCHECK(height >= 0); | 394 DCHECK(height >= 0); |
| 389 osr_expr_stack_height_ = height; | 395 osr_expr_stack_height_ = height; |
| 390 } | 396 } |
| 397 JavaScriptFrame* osr_frame() const { return osr_frame_; } |
| 398 void set_osr_frame(JavaScriptFrame* osr_frame) { osr_frame_ = osr_frame; } |
| 391 | 399 |
| 392 #if DEBUG | 400 #if DEBUG |
| 393 void PrintAstForTesting(); | 401 void PrintAstForTesting(); |
| 394 #endif | 402 #endif |
| 395 | 403 |
| 396 bool is_simple_parameter_list(); | 404 bool is_simple_parameter_list(); |
| 397 | 405 |
| 398 Handle<Code> GenerateCodeStub(); | 406 Handle<Code> GenerateCodeStub(); |
| 399 | 407 |
| 400 typedef std::vector<Handle<SharedFunctionInfo>> InlinedFunctionList; | 408 typedef std::vector<Handle<SharedFunctionInfo>> InlinedFunctionList; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // during graph optimization. | 493 // during graph optimization. |
| 486 int opt_count_; | 494 int opt_count_; |
| 487 | 495 |
| 488 // Number of parameters used for compilation of stubs that require arguments. | 496 // Number of parameters used for compilation of stubs that require arguments. |
| 489 int parameter_count_; | 497 int parameter_count_; |
| 490 | 498 |
| 491 int optimization_id_; | 499 int optimization_id_; |
| 492 | 500 |
| 493 int osr_expr_stack_height_; | 501 int osr_expr_stack_height_; |
| 494 | 502 |
| 503 // The current OSR frame for specialization or {nullptr}. |
| 504 JavaScriptFrame* osr_frame_ = nullptr; |
| 505 |
| 495 Type::FunctionType* function_type_; | 506 Type::FunctionType* function_type_; |
| 496 | 507 |
| 497 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 508 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
| 498 }; | 509 }; |
| 499 | 510 |
| 500 | 511 |
| 501 // A wrapper around a CompilationInfo that detaches the Handles from | 512 // A wrapper around a CompilationInfo that detaches the Handles from |
| 502 // the underlying DeferredHandleScope and stores them in info_ on | 513 // the underlying DeferredHandleScope and stores them in info_ on |
| 503 // destruction. | 514 // destruction. |
| 504 class CompilationHandleScope BASE_EMBEDDED { | 515 class CompilationHandleScope BASE_EMBEDDED { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 // Create a shared function info object (the code may be lazily compiled). | 666 // Create a shared function info object (the code may be lazily compiled). |
| 656 static Handle<SharedFunctionInfo> GetSharedFunctionInfo( | 667 static Handle<SharedFunctionInfo> GetSharedFunctionInfo( |
| 657 FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer); | 668 FunctionLiteral* node, Handle<Script> script, CompilationInfo* outer); |
| 658 | 669 |
| 659 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; | 670 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; |
| 660 | 671 |
| 661 // Generate and return optimized code or start a concurrent optimization job. | 672 // Generate and return optimized code or start a concurrent optimization job. |
| 662 // In the latter case, return the InOptimizationQueue builtin. On failure, | 673 // In the latter case, return the InOptimizationQueue builtin. On failure, |
| 663 // return the empty handle. | 674 // return the empty handle. |
| 664 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode( | 675 MUST_USE_RESULT static MaybeHandle<Code> GetOptimizedCode( |
| 665 Handle<JSFunction> function, | 676 Handle<JSFunction> function, Handle<Code> current_code, |
| 666 Handle<Code> current_code, | 677 ConcurrencyMode mode, BailoutId osr_ast_id = BailoutId::None(), |
| 667 ConcurrencyMode mode, | 678 JavaScriptFrame* osr_frame = nullptr); |
| 668 BailoutId osr_ast_id = BailoutId::None()); | |
| 669 | 679 |
| 670 // Generate and return code from previously queued optimization job. | 680 // Generate and return code from previously queued optimization job. |
| 671 // On failure, return the empty handle. | 681 // On failure, return the empty handle. |
| 672 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job); | 682 static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job); |
| 673 | 683 |
| 674 // TODO(titzer): move this method out of the compiler. | 684 // TODO(titzer): move this method out of the compiler. |
| 675 static bool DebuggerWantsEagerCompilation( | 685 static bool DebuggerWantsEagerCompilation( |
| 676 Isolate* isolate, bool allow_lazy_without_ctx = false); | 686 Isolate* isolate, bool allow_lazy_without_ctx = false); |
| 677 }; | 687 }; |
| 678 | 688 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 696 Zone zone_; | 706 Zone zone_; |
| 697 size_t info_zone_start_allocation_size_; | 707 size_t info_zone_start_allocation_size_; |
| 698 base::ElapsedTimer timer_; | 708 base::ElapsedTimer timer_; |
| 699 | 709 |
| 700 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 710 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 701 }; | 711 }; |
| 702 | 712 |
| 703 } } // namespace v8::internal | 713 } } // namespace v8::internal |
| 704 | 714 |
| 705 #endif // V8_COMPILER_H_ | 715 #endif // V8_COMPILER_H_ |
| OLD | NEW |