OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 void MarkAsInLoop() { | 82 void MarkAsInLoop() { |
83 ASSERT(is_lazy()); | 83 ASSERT(is_lazy()); |
84 flags_ |= IsInLoop::encode(true); | 84 flags_ |= IsInLoop::encode(true); |
85 } | 85 } |
86 void MarkAsAllowingNativesSyntax() { | 86 void MarkAsAllowingNativesSyntax() { |
87 flags_ |= IsNativesSyntaxAllowed::encode(true); | 87 flags_ |= IsNativesSyntaxAllowed::encode(true); |
88 } | 88 } |
89 bool allows_natives_syntax() const { | 89 bool allows_natives_syntax() const { |
90 return IsNativesSyntaxAllowed::decode(flags_); | 90 return IsNativesSyntaxAllowed::decode(flags_); |
91 } | 91 } |
92 void MarkAsNative() { | |
93 flags_ |= IsNative::encode(true); | |
94 } | |
95 bool is_native() const { | |
96 return IsNative::decode(flags_); | |
97 } | |
98 void SetFunction(FunctionLiteral* literal) { | 92 void SetFunction(FunctionLiteral* literal) { |
99 ASSERT(function_ == NULL); | 93 ASSERT(function_ == NULL); |
100 function_ = literal; | 94 function_ = literal; |
101 } | 95 } |
102 void SetScope(Scope* scope) { | 96 void SetScope(Scope* scope) { |
103 ASSERT(scope_ == NULL); | 97 ASSERT(scope_ == NULL); |
104 scope_ = scope; | 98 scope_ = scope; |
105 } | 99 } |
106 void SetCode(Handle<Code> code) { code_ = code; } | 100 void SetCode(Handle<Code> code) { code_ = code; } |
107 void SetExtension(v8::Extension* extension) { | 101 void SetExtension(v8::Extension* extension) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 enum Mode { | 160 enum Mode { |
167 BASE, | 161 BASE, |
168 OPTIMIZE, | 162 OPTIMIZE, |
169 NONOPT | 163 NONOPT |
170 }; | 164 }; |
171 | 165 |
172 CompilationInfo() : function_(NULL) {} | 166 CompilationInfo() : function_(NULL) {} |
173 | 167 |
174 void Initialize(Mode mode) { | 168 void Initialize(Mode mode) { |
175 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 169 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
176 if (!shared_info_.is_null()) { | 170 if (!shared_info_.is_null() && shared_info_->strict_mode()) { |
177 if (shared_info_->strict_mode()) MarkAsStrictMode(); | 171 MarkAsStrictMode(); |
178 if (shared_info_->native()) MarkAsNative(); | |
179 } | 172 } |
180 | |
181 } | 173 } |
182 | 174 |
183 void SetMode(Mode mode) { | 175 void SetMode(Mode mode) { |
184 ASSERT(V8::UseCrankshaft()); | 176 ASSERT(V8::UseCrankshaft()); |
185 mode_ = mode; | 177 mode_ = mode; |
186 } | 178 } |
187 | 179 |
188 // Flags using template class BitField<type, start, length>. All are | 180 // Flags using template class BitField<type, start, length>. All are |
189 // false by default. | 181 // false by default. |
190 // | 182 // |
191 // Compilation is either eager or lazy. | 183 // Compilation is either eager or lazy. |
192 class IsLazy: public BitField<bool, 0, 1> {}; | 184 class IsLazy: public BitField<bool, 0, 1> {}; |
193 // Flags that can be set for eager compilation. | 185 // Flags that can be set for eager compilation. |
194 class IsEval: public BitField<bool, 1, 1> {}; | 186 class IsEval: public BitField<bool, 1, 1> {}; |
195 class IsGlobal: public BitField<bool, 2, 1> {}; | 187 class IsGlobal: public BitField<bool, 2, 1> {}; |
196 // Flags that can be set for lazy compilation. | 188 // Flags that can be set for lazy compilation. |
197 class IsInLoop: public BitField<bool, 3, 1> {}; | 189 class IsInLoop: public BitField<bool, 3, 1> {}; |
198 // Strict mode - used in eager compilation. | 190 // Strict mode - used in eager compilation. |
199 class IsStrictMode: public BitField<bool, 4, 1> {}; | 191 class IsStrictMode: public BitField<bool, 4, 1> {}; |
200 // Native syntax (%-stuff) allowed? | 192 // Native syntax (%-stuff) allowed? |
201 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; | 193 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; |
202 // Is this a function from our natives. | |
203 class IsNative: public BitField<bool, 6, 1> {}; | |
204 | |
205 | 194 |
206 unsigned flags_; | 195 unsigned flags_; |
207 | 196 |
208 // Fields filled in by the compilation pipeline. | 197 // Fields filled in by the compilation pipeline. |
209 // AST filled in by the parser. | 198 // AST filled in by the parser. |
210 FunctionLiteral* function_; | 199 FunctionLiteral* function_; |
211 // The scope of the function literal as a convenience. Set to indicate | 200 // The scope of the function literal as a convenience. Set to indicate |
212 // that scopes have been analyzed. | 201 // that scopes have been analyzed. |
213 Scope* scope_; | 202 Scope* scope_; |
214 // The compiled code. | 203 // The compiled code. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 isolate->frame_element_constant_list()->Clear(); | 303 isolate->frame_element_constant_list()->Clear(); |
315 isolate->result_constant_list()->Clear(); | 304 isolate->result_constant_list()->Clear(); |
316 } | 305 } |
317 } | 306 } |
318 }; | 307 }; |
319 | 308 |
320 | 309 |
321 } } // namespace v8::internal | 310 } } // namespace v8::internal |
322 | 311 |
323 #endif // V8_COMPILER_H_ | 312 #endif // V8_COMPILER_H_ |
OLD | NEW |