| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 62 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 MarkAsAllowingNativesSyntax() { |
| 84 flags_ |= IsNativesSyntaxAllowed::encode(true); |
| 85 } |
| 86 bool allows_natives_syntax() const { |
| 87 return IsNativesSyntaxAllowed::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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // | 173 // |
| 168 // Compilation is either eager or lazy. | 174 // Compilation is either eager or lazy. |
| 169 class IsLazy: public BitField<bool, 0, 1> {}; | 175 class IsLazy: public BitField<bool, 0, 1> {}; |
| 170 // Flags that can be set for eager compilation. | 176 // Flags that can be set for eager compilation. |
| 171 class IsEval: public BitField<bool, 1, 1> {}; | 177 class IsEval: public BitField<bool, 1, 1> {}; |
| 172 class IsGlobal: public BitField<bool, 2, 1> {}; | 178 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 173 // Flags that can be set for lazy compilation. | 179 // Flags that can be set for lazy compilation. |
| 174 class IsInLoop: public BitField<bool, 3, 1> {}; | 180 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 175 // Strict mode - used in eager compilation. | 181 // Strict mode - used in eager compilation. |
| 176 class IsStrict: public BitField<bool, 4, 1> {}; | 182 class IsStrict: public BitField<bool, 4, 1> {}; |
| 183 // Native syntax (%-stuff) allowed? |
| 184 class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {}; |
| 177 | 185 |
| 178 unsigned flags_; | 186 unsigned flags_; |
| 179 | 187 |
| 180 // Fields filled in by the compilation pipeline. | 188 // Fields filled in by the compilation pipeline. |
| 181 // AST filled in by the parser. | 189 // AST filled in by the parser. |
| 182 FunctionLiteral* function_; | 190 FunctionLiteral* function_; |
| 183 // The scope of the function literal as a convenience. Set to indicate | 191 // The scope of the function literal as a convenience. Set to indicate |
| 184 // that scopes have been analyzed. | 192 // that scopes have been analyzed. |
| 185 Scope* scope_; | 193 Scope* scope_; |
| 186 // The compiled code. | 194 // The compiled code. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | 266 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
| 259 FunctionLiteral* lit, | 267 FunctionLiteral* lit, |
| 260 bool is_toplevel, | 268 bool is_toplevel, |
| 261 Handle<Script> script); | 269 Handle<Script> script); |
| 262 | 270 |
| 263 #ifdef ENABLE_DEBUGGER_SUPPORT | 271 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 264 static bool MakeCodeForLiveEdit(CompilationInfo* info); | 272 static bool MakeCodeForLiveEdit(CompilationInfo* info); |
| 265 #endif | 273 #endif |
| 266 | 274 |
| 267 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 275 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| 268 Handle<String> name, | 276 CompilationInfo* info, |
| 269 int start_position, | 277 Handle<SharedFunctionInfo> shared); |
| 270 CompilationInfo* info); | |
| 271 }; | 278 }; |
| 272 | 279 |
| 273 | 280 |
| 274 // During compilation we need a global list of handles to constants | 281 // During compilation we need a global list of handles to constants |
| 275 // for frame elements. When the zone gets deleted, we make sure to | 282 // for frame elements. When the zone gets deleted, we make sure to |
| 276 // clear this list of handles as well. | 283 // clear this list of handles as well. |
| 277 class CompilationZoneScope : public ZoneScope { | 284 class CompilationZoneScope : public ZoneScope { |
| 278 public: | 285 public: |
| 279 explicit CompilationZoneScope(ZoneScopeMode mode) : ZoneScope(mode) { } | 286 explicit CompilationZoneScope(ZoneScopeMode mode) : ZoneScope(mode) { } |
| 280 virtual ~CompilationZoneScope() { | 287 virtual ~CompilationZoneScope() { |
| 281 if (ShouldDeleteOnExit()) { | 288 if (ShouldDeleteOnExit()) { |
| 282 FrameElement::ClearConstantList(); | 289 FrameElement::ClearConstantList(); |
| 283 Result::ClearConstantList(); | 290 Result::ClearConstantList(); |
| 284 } | 291 } |
| 285 } | 292 } |
| 286 }; | 293 }; |
| 287 | 294 |
| 288 | 295 |
| 289 } } // namespace v8::internal | 296 } } // namespace v8::internal |
| 290 | 297 |
| 291 #endif // V8_COMPILER_H_ | 298 #endif // V8_COMPILER_H_ |
| OLD | NEW |