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 MarkAsES5Native() { | |
Lasse Reichstein
2011/05/26 08:26:55
Why ES5Native and not just Native?
Is there any na
Mads Ager (chromium)
2011/05/26 10:14:07
Following naming elsewhere to not have two names f
| |
93 flags_ |= IsES5Native::encode(true); | |
94 } | |
95 bool is_es5_native() const { | |
96 return IsES5Native::decode(flags_); | |
97 } | |
92 void SetFunction(FunctionLiteral* literal) { | 98 void SetFunction(FunctionLiteral* literal) { |
93 ASSERT(function_ == NULL); | 99 ASSERT(function_ == NULL); |
94 function_ = literal; | 100 function_ = literal; |
95 } | 101 } |
96 void SetScope(Scope* scope) { | 102 void SetScope(Scope* scope) { |
97 ASSERT(scope_ == NULL); | 103 ASSERT(scope_ == NULL); |
98 scope_ = scope; | 104 scope_ = scope; |
99 } | 105 } |
100 void SetCode(Handle<Code> code) { code_ = code; } | 106 void SetCode(Handle<Code> code) { code_ = code; } |
101 void SetExtension(v8::Extension* extension) { | 107 void SetExtension(v8::Extension* extension) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 enum Mode { | 166 enum Mode { |
161 BASE, | 167 BASE, |
162 OPTIMIZE, | 168 OPTIMIZE, |
163 NONOPT | 169 NONOPT |
164 }; | 170 }; |
165 | 171 |
166 CompilationInfo() : function_(NULL) {} | 172 CompilationInfo() : function_(NULL) {} |
167 | 173 |
168 void Initialize(Mode mode) { | 174 void Initialize(Mode mode) { |
169 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 175 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
170 if (!shared_info_.is_null() && shared_info_->strict_mode()) { | 176 if (!shared_info_.is_null()) { |
171 MarkAsStrictMode(); | 177 if (shared_info_->strict_mode()) MarkAsStrictMode(); |
178 if (shared_info_->es5_native()) MarkAsES5Native(); | |
172 } | 179 } |
180 | |
173 } | 181 } |
174 | 182 |
175 void SetMode(Mode mode) { | 183 void SetMode(Mode mode) { |
176 ASSERT(V8::UseCrankshaft()); | 184 ASSERT(V8::UseCrankshaft()); |
177 mode_ = mode; | 185 mode_ = mode; |
178 } | 186 } |
179 | 187 |
180 // Flags using template class BitField<type, start, length>. All are | 188 // Flags using template class BitField<type, start, length>. All are |
181 // false by default. | 189 // false by default. |
182 // | 190 // |
183 // Compilation is either eager or lazy. | 191 // Compilation is either eager or lazy. |
184 class IsLazy: public BitField<bool, 0, 1> {}; | 192 class IsLazy: public BitField<bool, 0, 1> {}; |
185 // Flags that can be set for eager compilation. | 193 // Flags that can be set for eager compilation. |
186 class IsEval: public BitField<bool, 1, 1> {}; | 194 class IsEval: public BitField<bool, 1, 1> {}; |
187 class IsGlobal: public BitField<bool, 2, 1> {}; | 195 class IsGlobal: public BitField<bool, 2, 1> {}; |
188 // Flags that can be set for lazy compilation. | 196 // Flags that can be set for lazy compilation. |
189 class IsInLoop: public BitField<bool, 3, 1> {}; | 197 class IsInLoop: public BitField<bool, 3, 1> {}; |
190 // Strict mode - used in eager compilation. | 198 // Strict mode - used in eager compilation. |
191 class IsStrictMode: public BitField<bool, 4, 1> {}; | 199 class IsStrictMode: public BitField<bool, 4, 1> {}; |
192 // Native syntax (%-stuff) allowed? | 200 // Native syntax (%-stuff) allowed? |
193 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; | 201 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; |
202 // Is this a function from our natives. | |
203 class IsES5Native: public BitField<bool, 6, 1> {}; | |
204 | |
194 | 205 |
195 unsigned flags_; | 206 unsigned flags_; |
196 | 207 |
197 // Fields filled in by the compilation pipeline. | 208 // Fields filled in by the compilation pipeline. |
198 // AST filled in by the parser. | 209 // AST filled in by the parser. |
199 FunctionLiteral* function_; | 210 FunctionLiteral* function_; |
200 // The scope of the function literal as a convenience. Set to indicate | 211 // The scope of the function literal as a convenience. Set to indicate |
201 // that scopes have been analyzed. | 212 // that scopes have been analyzed. |
202 Scope* scope_; | 213 Scope* scope_; |
203 // The compiled code. | 214 // The compiled code. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 isolate->frame_element_constant_list()->Clear(); | 314 isolate->frame_element_constant_list()->Clear(); |
304 isolate->result_constant_list()->Clear(); | 315 isolate->result_constant_list()->Clear(); |
305 } | 316 } |
306 } | 317 } |
307 }; | 318 }; |
308 | 319 |
309 | 320 |
310 } } // namespace v8::internal | 321 } } // namespace v8::internal |
311 | 322 |
312 #endif // V8_COMPILER_H_ | 323 #endif // V8_COMPILER_H_ |
OLD | NEW |