| 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 } |
| 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_->native()) MarkAsNative(); |
| 172 } | 179 } |
| 173 } | 180 } |
| 174 | 181 |
| 175 void SetMode(Mode mode) { | 182 void SetMode(Mode mode) { |
| 176 ASSERT(V8::UseCrankshaft()); | 183 ASSERT(V8::UseCrankshaft()); |
| 177 mode_ = mode; | 184 mode_ = mode; |
| 178 } | 185 } |
| 179 | 186 |
| 180 // Flags using template class BitField<type, start, length>. All are | 187 // Flags using template class BitField<type, start, length>. All are |
| 181 // false by default. | 188 // false by default. |
| 182 // | 189 // |
| 183 // Compilation is either eager or lazy. | 190 // Compilation is either eager or lazy. |
| 184 class IsLazy: public BitField<bool, 0, 1> {}; | 191 class IsLazy: public BitField<bool, 0, 1> {}; |
| 185 // Flags that can be set for eager compilation. | 192 // Flags that can be set for eager compilation. |
| 186 class IsEval: public BitField<bool, 1, 1> {}; | 193 class IsEval: public BitField<bool, 1, 1> {}; |
| 187 class IsGlobal: public BitField<bool, 2, 1> {}; | 194 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 188 // Flags that can be set for lazy compilation. | 195 // Flags that can be set for lazy compilation. |
| 189 class IsInLoop: public BitField<bool, 3, 1> {}; | 196 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 190 // Strict mode - used in eager compilation. | 197 // Strict mode - used in eager compilation. |
| 191 class IsStrictMode: public BitField<bool, 4, 1> {}; | 198 class IsStrictMode: public BitField<bool, 4, 1> {}; |
| 192 // Native syntax (%-stuff) allowed? | 199 // Native syntax (%-stuff) allowed? |
| 193 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; | 200 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; |
| 201 // Is this a function from our natives. |
| 202 class IsNative: public BitField<bool, 6, 1> {}; |
| 203 |
| 194 | 204 |
| 195 unsigned flags_; | 205 unsigned flags_; |
| 196 | 206 |
| 197 // Fields filled in by the compilation pipeline. | 207 // Fields filled in by the compilation pipeline. |
| 198 // AST filled in by the parser. | 208 // AST filled in by the parser. |
| 199 FunctionLiteral* function_; | 209 FunctionLiteral* function_; |
| 200 // The scope of the function literal as a convenience. Set to indicate | 210 // The scope of the function literal as a convenience. Set to indicate |
| 201 // that scopes have been analyzed. | 211 // that scopes have been analyzed. |
| 202 Scope* scope_; | 212 Scope* scope_; |
| 203 // The compiled code. | 213 // The compiled code. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 #ifdef ENABLE_DEBUGGER_SUPPORT | 292 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 283 static bool MakeCodeForLiveEdit(CompilationInfo* info); | 293 static bool MakeCodeForLiveEdit(CompilationInfo* info); |
| 284 #endif | 294 #endif |
| 285 | 295 |
| 286 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 296 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| 287 CompilationInfo* info, | 297 CompilationInfo* info, |
| 288 Handle<SharedFunctionInfo> shared); | 298 Handle<SharedFunctionInfo> shared); |
| 289 }; | 299 }; |
| 290 | 300 |
| 291 | 301 |
| 292 // During compilation we need a global list of handles to constants | |
| 293 // for frame elements. When the zone gets deleted, we make sure to | |
| 294 // clear this list of handles as well. | |
| 295 class CompilationZoneScope : public ZoneScope { | |
| 296 public: | |
| 297 CompilationZoneScope(Isolate* isolate, ZoneScopeMode mode) | |
| 298 : ZoneScope(isolate, mode) {} | |
| 299 | |
| 300 virtual ~CompilationZoneScope() { | |
| 301 if (ShouldDeleteOnExit()) { | |
| 302 Isolate* isolate = Isolate::Current(); | |
| 303 isolate->frame_element_constant_list()->Clear(); | |
| 304 isolate->result_constant_list()->Clear(); | |
| 305 } | |
| 306 } | |
| 307 }; | |
| 308 | |
| 309 | |
| 310 } } // namespace v8::internal | 302 } } // namespace v8::internal |
| 311 | 303 |
| 312 #endif // V8_COMPILER_H_ | 304 #endif // V8_COMPILER_H_ |
| OLD | NEW |