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_FULL_CODEGEN_FULL_CODEGEN_H_ | 5 #ifndef V8_FULL_CODEGEN_FULL_CODEGEN_H_ |
6 #define V8_FULL_CODEGEN_FULL_CODEGEN_H_ | 6 #define V8_FULL_CODEGEN_FULL_CODEGEN_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
11 #include "src/ast/scopes.h" | |
12 #include "src/bit-vector.h" | 11 #include "src/bit-vector.h" |
13 #include "src/code-factory.h" | 12 #include "src/code-factory.h" |
14 #include "src/code-stubs.h" | 13 #include "src/code-stubs.h" |
15 #include "src/codegen.h" | 14 #include "src/codegen.h" |
16 #include "src/compiler.h" | |
17 #include "src/deoptimizer.h" | 15 #include "src/deoptimizer.h" |
18 #include "src/globals.h" | 16 #include "src/globals.h" |
19 #include "src/objects.h" | 17 #include "src/objects.h" |
20 | 18 |
21 namespace v8 { | 19 namespace v8 { |
22 namespace internal { | 20 namespace internal { |
23 | 21 |
24 // Forward declarations. | 22 // Forward declarations. |
| 23 class CompilationInfo; |
| 24 class CompilationJob; |
25 class JumpPatchSite; | 25 class JumpPatchSite; |
| 26 class Scope; |
26 | 27 |
27 // ----------------------------------------------------------------------------- | 28 // ----------------------------------------------------------------------------- |
28 // Full code generator. | 29 // Full code generator. |
29 | 30 |
30 class FullCodeGenerator final : public AstVisitor<FullCodeGenerator> { | 31 class FullCodeGenerator final : public AstVisitor<FullCodeGenerator> { |
31 public: | 32 public: |
32 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info, | 33 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info, |
33 uintptr_t stack_limit) | 34 uintptr_t stack_limit); |
34 : masm_(masm), | |
35 info_(info), | |
36 isolate_(info->isolate()), | |
37 zone_(info->zone()), | |
38 scope_(info->scope()), | |
39 nesting_stack_(NULL), | |
40 loop_depth_(0), | |
41 operand_stack_depth_(0), | |
42 globals_(NULL), | |
43 context_(NULL), | |
44 bailout_entries_(info->HasDeoptimizationSupport() | |
45 ? info->literal()->ast_node_count() | |
46 : 0, | |
47 info->zone()), | |
48 back_edges_(2, info->zone()), | |
49 handler_table_(info->zone()), | |
50 source_position_table_builder_(info->zone(), | |
51 info->SourcePositionRecordingMode()), | |
52 ic_total_count_(0) { | |
53 DCHECK(!info->IsStub()); | |
54 Initialize(stack_limit); | |
55 } | |
56 | 35 |
57 void Initialize(uintptr_t stack_limit); | 36 void Initialize(uintptr_t stack_limit); |
58 | 37 |
59 static CompilationJob* NewCompilationJob(CompilationInfo* info); | 38 static CompilationJob* NewCompilationJob(CompilationInfo* info); |
60 | 39 |
61 static bool MakeCode(CompilationInfo* info, uintptr_t stack_limit); | 40 static bool MakeCode(CompilationInfo* info, uintptr_t stack_limit); |
62 static bool MakeCode(CompilationInfo* info) { | 41 static bool MakeCode(CompilationInfo* info); |
63 return MakeCode(info, info->isolate()->stack_guard()->real_climit()); | |
64 } | |
65 | 42 |
66 // Encode bailout state and pc-offset as a BitField<type, start, size>. | 43 // Encode bailout state and pc-offset as a BitField<type, start, size>. |
67 // Only use 30 bits because we encode the result as a smi. | 44 // Only use 30 bits because we encode the result as a smi. |
68 class BailoutStateField : public BitField<Deoptimizer::BailoutState, 0, 1> {}; | 45 class BailoutStateField : public BitField<Deoptimizer::BailoutState, 0, 1> {}; |
69 class PcField : public BitField<unsigned, 1, 30 - 1> {}; | 46 class PcField : public BitField<unsigned, 1, 30 - 1> {}; |
70 | 47 |
71 static const int kMaxBackEdgeWeight = 127; | 48 static const int kMaxBackEdgeWeight = 127; |
72 | 49 |
73 // Platform-specific code size multiplier. | 50 // Platform-specific code size multiplier. |
74 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 | 51 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 } | 671 } |
695 | 672 |
696 MacroAssembler* masm() const { return masm_; } | 673 MacroAssembler* masm() const { return masm_; } |
697 | 674 |
698 class ExpressionContext; | 675 class ExpressionContext; |
699 const ExpressionContext* context() { return context_; } | 676 const ExpressionContext* context() { return context_; } |
700 void set_new_context(const ExpressionContext* context) { context_ = context; } | 677 void set_new_context(const ExpressionContext* context) { context_ = context; } |
701 | 678 |
702 Isolate* isolate() const { return isolate_; } | 679 Isolate* isolate() const { return isolate_; } |
703 Zone* zone() const { return zone_; } | 680 Zone* zone() const { return zone_; } |
704 Handle<Script> script() { return info_->script(); } | 681 Handle<Script> script(); |
705 LanguageMode language_mode() { return scope()->language_mode(); } | 682 LanguageMode language_mode(); |
706 bool has_simple_parameters() { return info_->has_simple_parameters(); } | 683 bool has_simple_parameters(); |
707 FunctionLiteral* literal() const { return info_->literal(); } | 684 FunctionLiteral* literal() const; |
708 Scope* scope() { return scope_; } | 685 Scope* scope() { return scope_; } |
709 | 686 |
710 static Register context_register(); | 687 static Register context_register(); |
711 | 688 |
712 // Get fields from the stack frame. Offsets are the frame pointer relative | 689 // Get fields from the stack frame. Offsets are the frame pointer relative |
713 // offsets defined in, e.g., StandardFrameConstants. | 690 // offsets defined in, e.g., StandardFrameConstants. |
714 void LoadFromFrameField(int frame_offset, Register value); | 691 void LoadFromFrameField(int frame_offset, Register value); |
715 // Set fields in the stack frame. Offsets are the frame pointer relative | 692 // Set fields in the stack frame. Offsets are the frame pointer relative |
716 // offsets defined in, e.g., StandardFrameConstants. | 693 // offsets defined in, e.g., StandardFrameConstants. |
717 void StoreToFrameField(int frame_offset, Register value); | 694 void StoreToFrameField(int frame_offset, Register value); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 Address start_; | 1021 Address start_; |
1045 Address instruction_start_; | 1022 Address instruction_start_; |
1046 uint32_t length_; | 1023 uint32_t length_; |
1047 }; | 1024 }; |
1048 | 1025 |
1049 | 1026 |
1050 } // namespace internal | 1027 } // namespace internal |
1051 } // namespace v8 | 1028 } // namespace v8 |
1052 | 1029 |
1053 #endif // V8_FULL_CODEGEN_FULL_CODEGEN_H_ | 1030 #endif // V8_FULL_CODEGEN_FULL_CODEGEN_H_ |
OLD | NEW |