| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 void MarkAsStrictMode() { | 76 void MarkAsStrictMode() { |
| 77 flags_ |= IsStrictMode::encode(true); | 77 flags_ |= IsStrictMode::encode(true); |
| 78 } | 78 } |
| 79 StrictModeFlag StrictMode() { | 79 StrictModeFlag StrictMode() { |
| 80 return is_strict_mode() ? kStrictMode : kNonStrictMode; | 80 return is_strict_mode() ? kStrictMode : kNonStrictMode; |
| 81 } | 81 } |
| 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 MarkAsNative() { |
| 87 flags_ |= IsNativesSyntaxAllowed::encode(true); | 87 flags_ |= IsNative::encode(true); |
| 88 } | 88 } |
| 89 bool allows_natives_syntax() const { | 89 bool is_native() const { |
| 90 return IsNativesSyntaxAllowed::decode(flags_); | 90 return IsNative::decode(flags_); |
| 91 } | 91 } |
| 92 void SetFunction(FunctionLiteral* literal) { | 92 void SetFunction(FunctionLiteral* literal) { |
| 93 ASSERT(function_ == NULL); | 93 ASSERT(function_ == NULL); |
| 94 function_ = literal; | 94 function_ = literal; |
| 95 } | 95 } |
| 96 void SetScope(Scope* scope) { | 96 void SetScope(Scope* scope) { |
| 97 ASSERT(scope_ == NULL); | 97 ASSERT(scope_ == NULL); |
| 98 scope_ = scope; | 98 scope_ = scope; |
| 99 } | 99 } |
| 100 void SetCode(Handle<Code> code) { code_ = code; } | 100 void SetCode(Handle<Code> code) { code_ = code; } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 enum Mode { | 160 enum Mode { |
| 161 BASE, | 161 BASE, |
| 162 OPTIMIZE, | 162 OPTIMIZE, |
| 163 NONOPT | 163 NONOPT |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 CompilationInfo() : function_(NULL) {} | 166 CompilationInfo() : function_(NULL) {} |
| 167 | 167 |
| 168 void Initialize(Mode mode) { | 168 void Initialize(Mode mode) { |
| 169 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 169 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
| 170 if (script_->type()->value() == Script::TYPE_NATIVE) { |
| 171 MarkAsNative(); |
| 172 } |
| 170 if (!shared_info_.is_null() && shared_info_->strict_mode()) { | 173 if (!shared_info_.is_null() && shared_info_->strict_mode()) { |
| 171 MarkAsStrictMode(); | 174 MarkAsStrictMode(); |
| 172 } | 175 } |
| 173 } | 176 } |
| 174 | 177 |
| 175 void SetMode(Mode mode) { | 178 void SetMode(Mode mode) { |
| 176 ASSERT(V8::UseCrankshaft()); | 179 ASSERT(V8::UseCrankshaft()); |
| 177 mode_ = mode; | 180 mode_ = mode; |
| 178 } | 181 } |
| 179 | 182 |
| 180 // Flags using template class BitField<type, start, length>. All are | 183 // Flags using template class BitField<type, start, length>. All are |
| 181 // false by default. | 184 // false by default. |
| 182 // | 185 // |
| 183 // Compilation is either eager or lazy. | 186 // Compilation is either eager or lazy. |
| 184 class IsLazy: public BitField<bool, 0, 1> {}; | 187 class IsLazy: public BitField<bool, 0, 1> {}; |
| 185 // Flags that can be set for eager compilation. | 188 // Flags that can be set for eager compilation. |
| 186 class IsEval: public BitField<bool, 1, 1> {}; | 189 class IsEval: public BitField<bool, 1, 1> {}; |
| 187 class IsGlobal: public BitField<bool, 2, 1> {}; | 190 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 188 // Flags that can be set for lazy compilation. | 191 // Flags that can be set for lazy compilation. |
| 189 class IsInLoop: public BitField<bool, 3, 1> {}; | 192 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 190 // Strict mode - used in eager compilation. | 193 // Strict mode - used in eager compilation. |
| 191 class IsStrictMode: public BitField<bool, 4, 1> {}; | 194 class IsStrictMode: public BitField<bool, 4, 1> {}; |
| 192 // Native syntax (%-stuff) allowed? | 195 // Is this a function from our natives. |
| 193 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; | 196 class IsNative: public BitField<bool, 6, 1> {}; |
| 194 | 197 |
| 195 unsigned flags_; | 198 unsigned flags_; |
| 196 | 199 |
| 197 // Fields filled in by the compilation pipeline. | 200 // Fields filled in by the compilation pipeline. |
| 198 // AST filled in by the parser. | 201 // AST filled in by the parser. |
| 199 FunctionLiteral* function_; | 202 FunctionLiteral* function_; |
| 200 // The scope of the function literal as a convenience. Set to indicate | 203 // The scope of the function literal as a convenience. Set to indicate |
| 201 // that scopes have been analyzed. | 204 // that scopes have been analyzed. |
| 202 Scope* scope_; | 205 Scope* scope_; |
| 203 // The compiled code. | 206 // The compiled code. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 isolate->frame_element_constant_list()->Clear(); | 306 isolate->frame_element_constant_list()->Clear(); |
| 304 isolate->result_constant_list()->Clear(); | 307 isolate->result_constant_list()->Clear(); |
| 305 } | 308 } |
| 306 } | 309 } |
| 307 }; | 310 }; |
| 308 | 311 |
| 309 | 312 |
| 310 } } // namespace v8::internal | 313 } } // namespace v8::internal |
| 311 | 314 |
| 312 #endif // V8_COMPILER_H_ | 315 #endif // V8_COMPILER_H_ |
| OLD | NEW |