| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 flags_ |= IsEval::encode(true); | 66 flags_ |= IsEval::encode(true); |
| 67 } | 67 } |
| 68 void MarkAsGlobal() { | 68 void MarkAsGlobal() { |
| 69 ASSERT(!is_lazy()); | 69 ASSERT(!is_lazy()); |
| 70 flags_ |= IsGlobal::encode(true); | 70 flags_ |= IsGlobal::encode(true); |
| 71 } | 71 } |
| 72 void MarkAsInLoop() { | 72 void MarkAsInLoop() { |
| 73 ASSERT(is_lazy()); | 73 ASSERT(is_lazy()); |
| 74 flags_ |= IsInLoop::encode(true); | 74 flags_ |= IsInLoop::encode(true); |
| 75 } | 75 } |
| 76 void MarkAsNative() { |
| 77 flags_ |= IsNative::encode(true); |
| 78 } |
| 79 bool is_native() const { |
| 80 return IsNative::decode(flags_); |
| 81 } |
| 76 void SetFunction(FunctionLiteral* literal) { | 82 void SetFunction(FunctionLiteral* literal) { |
| 77 ASSERT(function_ == NULL); | 83 ASSERT(function_ == NULL); |
| 78 function_ = literal; | 84 function_ = literal; |
| 79 } | 85 } |
| 80 void SetScope(Scope* scope) { | 86 void SetScope(Scope* scope) { |
| 81 ASSERT(scope_ == NULL); | 87 ASSERT(scope_ == NULL); |
| 82 scope_ = scope; | 88 scope_ = scope; |
| 83 } | 89 } |
| 84 void SetCode(Handle<Code> code) { code_ = code; } | 90 void SetCode(Handle<Code> code) { code_ = code; } |
| 85 void SetExtension(v8::Extension* extension) { | 91 void SetExtension(v8::Extension* extension) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 enum Mode { | 144 enum Mode { |
| 139 BASE, | 145 BASE, |
| 140 OPTIMIZE, | 146 OPTIMIZE, |
| 141 NONOPT | 147 NONOPT |
| 142 }; | 148 }; |
| 143 | 149 |
| 144 CompilationInfo() : function_(NULL) {} | 150 CompilationInfo() : function_(NULL) {} |
| 145 | 151 |
| 146 void Initialize(Mode mode) { | 152 void Initialize(Mode mode) { |
| 147 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 153 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
| 154 if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 155 MarkAsNative(); |
| 156 } |
| 148 } | 157 } |
| 149 | 158 |
| 150 void SetMode(Mode mode) { | 159 void SetMode(Mode mode) { |
| 151 ASSERT(V8::UseCrankshaft()); | 160 ASSERT(V8::UseCrankshaft()); |
| 152 mode_ = mode; | 161 mode_ = mode; |
| 153 } | 162 } |
| 154 | 163 |
| 155 // Flags using template class BitField<type, start, length>. All are | 164 // Flags using template class BitField<type, start, length>. All are |
| 156 // false by default. | 165 // false by default. |
| 157 // | 166 // |
| 158 // Compilation is either eager or lazy. | 167 // Compilation is either eager or lazy. |
| 159 class IsLazy: public BitField<bool, 0, 1> {}; | 168 class IsLazy: public BitField<bool, 0, 1> {}; |
| 160 // Flags that can be set for eager compilation. | 169 // Flags that can be set for eager compilation. |
| 161 class IsEval: public BitField<bool, 1, 1> {}; | 170 class IsEval: public BitField<bool, 1, 1> {}; |
| 162 class IsGlobal: public BitField<bool, 2, 1> {}; | 171 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 163 // Flags that can be set for lazy compilation. | 172 // Flags that can be set for lazy compilation. |
| 164 class IsInLoop: public BitField<bool, 3, 1> {}; | 173 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 174 // Is this a function from our natives. |
| 175 class IsNative: public BitField<bool, 6, 1> {}; |
| 165 | 176 |
| 166 unsigned flags_; | 177 unsigned flags_; |
| 167 | 178 |
| 168 // Fields filled in by the compilation pipeline. | 179 // Fields filled in by the compilation pipeline. |
| 169 // AST filled in by the parser. | 180 // AST filled in by the parser. |
| 170 FunctionLiteral* function_; | 181 FunctionLiteral* function_; |
| 171 // The scope of the function literal as a convenience. Set to indicate | 182 // The scope of the function literal as a convenience. Set to indicate |
| 172 // that scopes have been analyzed. | 183 // that scopes have been analyzed. |
| 173 Scope* scope_; | 184 Scope* scope_; |
| 174 // The compiled code. | 185 // The compiled code. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 FrameElement::ClearConstantList(); | 280 FrameElement::ClearConstantList(); |
| 270 Result::ClearConstantList(); | 281 Result::ClearConstantList(); |
| 271 } | 282 } |
| 272 } | 283 } |
| 273 }; | 284 }; |
| 274 | 285 |
| 275 | 286 |
| 276 } } // namespace v8::internal | 287 } } // namespace v8::internal |
| 277 | 288 |
| 278 #endif // V8_COMPILER_H_ | 289 #endif // V8_COMPILER_H_ |
| OLD | NEW |