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 "allocation.h" | 8 #include "allocation.h" |
9 #include "ast.h" | 9 #include "ast.h" |
10 #include "zone.h" | 10 #include "zone.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 Isolate* isolate() const { | 44 Isolate* isolate() const { |
45 return isolate_; | 45 return isolate_; |
46 } | 46 } |
47 Zone* zone() { return zone_; } | 47 Zone* zone() { return zone_; } |
48 bool is_osr() const { return !osr_ast_id_.IsNone(); } | 48 bool is_osr() const { return !osr_ast_id_.IsNone(); } |
49 bool is_lazy() const { return IsLazy::decode(flags_); } | 49 bool is_lazy() const { return IsLazy::decode(flags_); } |
50 bool is_eval() const { return IsEval::decode(flags_); } | 50 bool is_eval() const { return IsEval::decode(flags_); } |
51 bool is_global() const { return IsGlobal::decode(flags_); } | 51 bool is_global() const { return IsGlobal::decode(flags_); } |
52 StrictMode strict_mode() const { return StrictModeField::decode(flags_); } | 52 StrictMode strict_mode() const { return StrictModeField::decode(flags_); } |
53 bool is_in_loop() const { return IsInLoop::decode(flags_); } | |
54 FunctionLiteral* function() const { return function_; } | 53 FunctionLiteral* function() const { return function_; } |
55 Scope* scope() const { return scope_; } | 54 Scope* scope() const { return scope_; } |
56 Scope* global_scope() const { return global_scope_; } | 55 Scope* global_scope() const { return global_scope_; } |
57 Handle<Code> code() const { return code_; } | 56 Handle<Code> code() const { return code_; } |
58 Handle<JSFunction> closure() const { return closure_; } | 57 Handle<JSFunction> closure() const { return closure_; } |
59 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 58 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
60 Handle<Script> script() const { return script_; } | 59 Handle<Script> script() const { return script_; } |
61 HydrogenCodeStub* code_stub() const {return code_stub_; } | 60 HydrogenCodeStub* code_stub() const {return code_stub_; } |
62 v8::Extension* extension() const { return extension_; } | 61 v8::Extension* extension() const { return extension_; } |
63 ScriptData** cached_data() const { return cached_data_; } | 62 ScriptData** cached_data() const { return cached_data_; } |
(...skipping 24 matching lines...) Expand all Loading... |
88 void set_this_has_uses(bool has_no_uses) { | 87 void set_this_has_uses(bool has_no_uses) { |
89 this_has_uses_ = has_no_uses; | 88 this_has_uses_ = has_no_uses; |
90 } | 89 } |
91 bool this_has_uses() { | 90 bool this_has_uses() { |
92 return this_has_uses_; | 91 return this_has_uses_; |
93 } | 92 } |
94 void SetStrictMode(StrictMode strict_mode) { | 93 void SetStrictMode(StrictMode strict_mode) { |
95 ASSERT(this->strict_mode() == SLOPPY || this->strict_mode() == strict_mode); | 94 ASSERT(this->strict_mode() == SLOPPY || this->strict_mode() == strict_mode); |
96 flags_ = StrictModeField::update(flags_, strict_mode); | 95 flags_ = StrictModeField::update(flags_, strict_mode); |
97 } | 96 } |
98 void MarkAsInLoop() { | |
99 ASSERT(is_lazy()); | |
100 flags_ |= IsInLoop::encode(true); | |
101 } | |
102 void MarkAsNative() { | 97 void MarkAsNative() { |
103 flags_ |= IsNative::encode(true); | 98 flags_ |= IsNative::encode(true); |
104 } | 99 } |
105 | 100 |
106 bool is_native() const { | 101 bool is_native() const { |
107 return IsNative::decode(flags_); | 102 return IsNative::decode(flags_); |
108 } | 103 } |
109 | 104 |
110 bool is_calling() const { | 105 bool is_calling() const { |
111 return is_deferred_calling() || is_non_deferred_calling(); | 106 return is_deferred_calling() || is_non_deferred_calling(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 139 } |
145 | 140 |
146 void MarkMustNotHaveEagerFrame() { | 141 void MarkMustNotHaveEagerFrame() { |
147 flags_ |= MustNotHaveEagerFrame::encode(true); | 142 flags_ |= MustNotHaveEagerFrame::encode(true); |
148 } | 143 } |
149 | 144 |
150 bool GetMustNotHaveEagerFrame() const { | 145 bool GetMustNotHaveEagerFrame() const { |
151 return MustNotHaveEagerFrame::decode(flags_); | 146 return MustNotHaveEagerFrame::decode(flags_); |
152 } | 147 } |
153 | 148 |
| 149 void MarkAsDebug() { |
| 150 flags_ |= IsDebug::encode(true); |
| 151 } |
| 152 |
| 153 bool is_debug() const { |
| 154 return IsDebug::decode(flags_); |
| 155 } |
| 156 |
| 157 bool IsCodePreAgingActive() const { |
| 158 return FLAG_optimize_for_size && FLAG_age_code && !is_debug(); |
| 159 } |
| 160 |
154 void SetParseRestriction(ParseRestriction restriction) { | 161 void SetParseRestriction(ParseRestriction restriction) { |
155 flags_ = ParseRestricitonField::update(flags_, restriction); | 162 flags_ = ParseRestricitonField::update(flags_, restriction); |
156 } | 163 } |
157 | 164 |
158 ParseRestriction parse_restriction() const { | 165 ParseRestriction parse_restriction() const { |
159 return ParseRestricitonField::decode(flags_); | 166 return ParseRestricitonField::decode(flags_); |
160 } | 167 } |
161 | 168 |
162 void SetFunction(FunctionLiteral* literal) { | 169 void SetFunction(FunctionLiteral* literal) { |
163 ASSERT(function_ == NULL); | 170 ASSERT(function_ == NULL); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 353 } |
347 | 354 |
348 // Flags using template class BitField<type, start, length>. All are | 355 // Flags using template class BitField<type, start, length>. All are |
349 // false by default. | 356 // false by default. |
350 // | 357 // |
351 // Compilation is either eager or lazy. | 358 // Compilation is either eager or lazy. |
352 class IsLazy: public BitField<bool, 0, 1> {}; | 359 class IsLazy: public BitField<bool, 0, 1> {}; |
353 // Flags that can be set for eager compilation. | 360 // Flags that can be set for eager compilation. |
354 class IsEval: public BitField<bool, 1, 1> {}; | 361 class IsEval: public BitField<bool, 1, 1> {}; |
355 class IsGlobal: public BitField<bool, 2, 1> {}; | 362 class IsGlobal: public BitField<bool, 2, 1> {}; |
356 // Flags that can be set for lazy compilation. | 363 // If the function is being compiled for the debugger. |
357 class IsInLoop: public BitField<bool, 3, 1> {}; | 364 class IsDebug: public BitField<bool, 3, 1> {}; |
358 // Strict mode - used in eager compilation. | 365 // Strict mode - used in eager compilation. |
359 class StrictModeField: public BitField<StrictMode, 4, 1> {}; | 366 class StrictModeField: public BitField<StrictMode, 4, 1> {}; |
360 // Is this a function from our natives. | 367 // Is this a function from our natives. |
361 class IsNative: public BitField<bool, 5, 1> {}; | 368 class IsNative: public BitField<bool, 5, 1> {}; |
362 // Is this code being compiled with support for deoptimization.. | 369 // Is this code being compiled with support for deoptimization.. |
363 class SupportsDeoptimization: public BitField<bool, 6, 1> {}; | 370 class SupportsDeoptimization: public BitField<bool, 6, 1> {}; |
364 // If compiling for debugging produce just full code matching the | 371 // If compiling for debugging produce just full code matching the |
365 // initial mode setting. | 372 // initial mode setting. |
366 class IsCompilingForDebugging: public BitField<bool, 7, 1> {}; | 373 class IsCompilingForDebugging: public BitField<bool, 7, 1> {}; |
367 // If the compiled code contains calls that require building a frame | 374 // If the compiled code contains calls that require building a frame |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 unsigned info_zone_start_allocation_size_; | 693 unsigned info_zone_start_allocation_size_; |
687 ElapsedTimer timer_; | 694 ElapsedTimer timer_; |
688 | 695 |
689 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 696 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
690 }; | 697 }; |
691 | 698 |
692 | 699 |
693 } } // namespace v8::internal | 700 } } // namespace v8::internal |
694 | 701 |
695 #endif // V8_COMPILER_H_ | 702 #endif // V8_COMPILER_H_ |
OLD | NEW |