| OLD | NEW |
| 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void MarkAsStrict() { | 73 void MarkAsStrict() { |
| 74 flags_ |= IsStrict::encode(true); | 74 flags_ |= IsStrict::encode(true); |
| 75 } | 75 } |
| 76 StrictModeFlag StrictMode() { | 76 StrictModeFlag StrictMode() { |
| 77 return is_strict() ? kStrictMode : kNonStrictMode; | 77 return is_strict() ? kStrictMode : kNonStrictMode; |
| 78 } | 78 } |
| 79 void MarkAsInLoop() { | 79 void MarkAsInLoop() { |
| 80 ASSERT(is_lazy()); | 80 ASSERT(is_lazy()); |
| 81 flags_ |= IsInLoop::encode(true); | 81 flags_ |= IsInLoop::encode(true); |
| 82 } | 82 } |
| 83 void MarkAsNative() { |
| 84 flags_ |= IsNative::encode(true); |
| 85 } |
| 86 bool is_native() const { |
| 87 return IsNative::decode(flags_); |
| 88 } |
| 83 void SetFunction(FunctionLiteral* literal) { | 89 void SetFunction(FunctionLiteral* literal) { |
| 84 ASSERT(function_ == NULL); | 90 ASSERT(function_ == NULL); |
| 85 function_ = literal; | 91 function_ = literal; |
| 86 } | 92 } |
| 87 void SetScope(Scope* scope) { | 93 void SetScope(Scope* scope) { |
| 88 ASSERT(scope_ == NULL); | 94 ASSERT(scope_ == NULL); |
| 89 scope_ = scope; | 95 scope_ = scope; |
| 90 } | 96 } |
| 91 void SetCode(Handle<Code> code) { code_ = code; } | 97 void SetCode(Handle<Code> code) { code_ = code; } |
| 92 void SetExtension(v8::Extension* extension) { | 98 void SetExtension(v8::Extension* extension) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 enum Mode { | 151 enum Mode { |
| 146 BASE, | 152 BASE, |
| 147 OPTIMIZE, | 153 OPTIMIZE, |
| 148 NONOPT | 154 NONOPT |
| 149 }; | 155 }; |
| 150 | 156 |
| 151 CompilationInfo() : function_(NULL) {} | 157 CompilationInfo() : function_(NULL) {} |
| 152 | 158 |
| 153 void Initialize(Mode mode) { | 159 void Initialize(Mode mode) { |
| 154 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 160 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
| 161 if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 162 MarkAsNative(); |
| 163 } |
| 155 if (!shared_info_.is_null() && shared_info_->strict_mode()) { | 164 if (!shared_info_.is_null() && shared_info_->strict_mode()) { |
| 156 MarkAsStrict(); | 165 MarkAsStrict(); |
| 157 } | 166 } |
| 158 } | 167 } |
| 159 | 168 |
| 160 void SetMode(Mode mode) { | 169 void SetMode(Mode mode) { |
| 161 ASSERT(V8::UseCrankshaft()); | 170 ASSERT(V8::UseCrankshaft()); |
| 162 mode_ = mode; | 171 mode_ = mode; |
| 163 } | 172 } |
| 164 | 173 |
| 165 // Flags using template class BitField<type, start, length>. All are | 174 // Flags using template class BitField<type, start, length>. All are |
| 166 // false by default. | 175 // false by default. |
| 167 // | 176 // |
| 168 // Compilation is either eager or lazy. | 177 // Compilation is either eager or lazy. |
| 169 class IsLazy: public BitField<bool, 0, 1> {}; | 178 class IsLazy: public BitField<bool, 0, 1> {}; |
| 170 // Flags that can be set for eager compilation. | 179 // Flags that can be set for eager compilation. |
| 171 class IsEval: public BitField<bool, 1, 1> {}; | 180 class IsEval: public BitField<bool, 1, 1> {}; |
| 172 class IsGlobal: public BitField<bool, 2, 1> {}; | 181 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 173 // Flags that can be set for lazy compilation. | 182 // Flags that can be set for lazy compilation. |
| 174 class IsInLoop: public BitField<bool, 3, 1> {}; | 183 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 175 // Strict mode - used in eager compilation. | 184 // Strict mode - used in eager compilation. |
| 176 class IsStrict: public BitField<bool, 4, 1> {}; | 185 class IsStrict: public BitField<bool, 4, 1> {}; |
| 186 // Is this a function from our natives. |
| 187 class IsNative: public BitField<bool, 6, 1> {}; |
| 177 | 188 |
| 178 unsigned flags_; | 189 unsigned flags_; |
| 179 | 190 |
| 180 // Fields filled in by the compilation pipeline. | 191 // Fields filled in by the compilation pipeline. |
| 181 // AST filled in by the parser. | 192 // AST filled in by the parser. |
| 182 FunctionLiteral* function_; | 193 FunctionLiteral* function_; |
| 183 // The scope of the function literal as a convenience. Set to indicate | 194 // The scope of the function literal as a convenience. Set to indicate |
| 184 // that scopes have been analyzed. | 195 // that scopes have been analyzed. |
| 185 Scope* scope_; | 196 Scope* scope_; |
| 186 // The compiled code. | 197 // The compiled code. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 FrameElement::ClearConstantList(); | 292 FrameElement::ClearConstantList(); |
| 282 Result::ClearConstantList(); | 293 Result::ClearConstantList(); |
| 283 } | 294 } |
| 284 } | 295 } |
| 285 }; | 296 }; |
| 286 | 297 |
| 287 | 298 |
| 288 } } // namespace v8::internal | 299 } } // namespace v8::internal |
| 289 | 300 |
| 290 #endif // V8_COMPILER_H_ | 301 #endif // V8_COMPILER_H_ |
| OLD | NEW |