Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 // is constructed based on the resources available at compile-time. | 42 // is constructed based on the resources available at compile-time. |
| 43 class CompilationInfo BASE_EMBEDDED { | 43 class CompilationInfo BASE_EMBEDDED { |
| 44 public: | 44 public: |
| 45 explicit CompilationInfo(Handle<Script> script); | 45 explicit CompilationInfo(Handle<Script> script); |
| 46 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); | 46 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); |
| 47 explicit CompilationInfo(Handle<JSFunction> closure); | 47 explicit CompilationInfo(Handle<JSFunction> closure); |
| 48 | 48 |
| 49 bool is_lazy() const { return (flags_ & IsLazy::mask()) != 0; } | 49 bool is_lazy() const { return (flags_ & IsLazy::mask()) != 0; } |
| 50 bool is_eval() const { return (flags_ & IsEval::mask()) != 0; } | 50 bool is_eval() const { return (flags_ & IsEval::mask()) != 0; } |
| 51 bool is_global() const { return (flags_ & IsGlobal::mask()) != 0; } | 51 bool is_global() const { return (flags_ & IsGlobal::mask()) != 0; } |
| 52 bool is_strict() const { return (flags_ & IsStrict::mask()) != 0; } | |
| 52 bool is_in_loop() const { return (flags_ & IsInLoop::mask()) != 0; } | 53 bool is_in_loop() const { return (flags_ & IsInLoop::mask()) != 0; } |
| 53 FunctionLiteral* function() const { return function_; } | 54 FunctionLiteral* function() const { return function_; } |
| 54 Scope* scope() const { return scope_; } | 55 Scope* scope() const { return scope_; } |
| 55 Handle<Code> code() const { return code_; } | 56 Handle<Code> code() const { return code_; } |
| 56 Handle<JSFunction> closure() const { return closure_; } | 57 Handle<JSFunction> closure() const { return closure_; } |
| 57 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 58 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 58 Handle<Script> script() const { return script_; } | 59 Handle<Script> script() const { return script_; } |
| 59 v8::Extension* extension() const { return extension_; } | 60 v8::Extension* extension() const { return extension_; } |
| 60 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } | 61 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } |
| 61 Handle<Context> calling_context() const { return calling_context_; } | 62 Handle<Context> calling_context() const { return calling_context_; } |
| 62 int osr_ast_id() const { return osr_ast_id_; } | 63 int osr_ast_id() const { return osr_ast_id_; } |
| 63 | 64 |
| 64 void MarkAsEval() { | 65 void MarkAsEval() { |
| 65 ASSERT(!is_lazy()); | 66 ASSERT(!is_lazy()); |
| 66 flags_ |= IsEval::encode(true); | 67 flags_ |= IsEval::encode(true); |
| 67 } | 68 } |
| 68 void MarkAsGlobal() { | 69 void MarkAsGlobal() { |
| 69 ASSERT(!is_lazy()); | 70 ASSERT(!is_lazy()); |
| 70 flags_ |= IsGlobal::encode(true); | 71 flags_ |= IsGlobal::encode(true); |
| 71 } | 72 } |
| 73 void MarkAsStrict() { | |
| 74 ASSERT(!is_lazy()); | |
| 75 flags_ |= IsStrict::encode(true); | |
| 76 } | |
| 72 void MarkAsInLoop() { | 77 void MarkAsInLoop() { |
| 73 ASSERT(is_lazy()); | 78 ASSERT(is_lazy()); |
| 74 flags_ |= IsInLoop::encode(true); | 79 flags_ |= IsInLoop::encode(true); |
| 75 } | 80 } |
| 76 void SetFunction(FunctionLiteral* literal) { | 81 void SetFunction(FunctionLiteral* literal) { |
| 77 ASSERT(function_ == NULL); | 82 ASSERT(function_ == NULL); |
| 78 function_ = literal; | 83 function_ = literal; |
| 79 } | 84 } |
| 80 void SetScope(Scope* scope) { | 85 void SetScope(Scope* scope) { |
| 81 ASSERT(scope_ == NULL); | 86 ASSERT(scope_ == NULL); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 } | 158 } |
| 154 | 159 |
| 155 // Flags using template class BitField<type, start, length>. All are | 160 // Flags using template class BitField<type, start, length>. All are |
| 156 // false by default. | 161 // false by default. |
| 157 // | 162 // |
| 158 // Compilation is either eager or lazy. | 163 // Compilation is either eager or lazy. |
| 159 class IsLazy: public BitField<bool, 0, 1> {}; | 164 class IsLazy: public BitField<bool, 0, 1> {}; |
| 160 // Flags that can be set for eager compilation. | 165 // Flags that can be set for eager compilation. |
| 161 class IsEval: public BitField<bool, 1, 1> {}; | 166 class IsEval: public BitField<bool, 1, 1> {}; |
| 162 class IsGlobal: public BitField<bool, 2, 1> {}; | 167 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 168 class IsStrict: public BitField<bool, 4, 1> {}; | |
|
Lasse Reichstein
2011/02/03 12:36:01
Move it below IsInLoop, to keep bits in order.
Martin Maly
2011/02/04 01:02:34
Done. Added comment to clarify that IsStrict is us
| |
| 163 // Flags that can be set for lazy compilation. | 169 // Flags that can be set for lazy compilation. |
| 164 class IsInLoop: public BitField<bool, 3, 1> {}; | 170 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 165 | 171 |
| 166 unsigned flags_; | 172 unsigned flags_; |
| 167 | 173 |
| 168 // Fields filled in by the compilation pipeline. | 174 // Fields filled in by the compilation pipeline. |
| 169 // AST filled in by the parser. | 175 // AST filled in by the parser. |
| 170 FunctionLiteral* function_; | 176 FunctionLiteral* function_; |
| 171 // The scope of the function literal as a convenience. Set to indicate | 177 // The scope of the function literal as a convenience. Set to indicate |
| 172 // that scopes have been analyzed. | 178 // that scopes have been analyzed. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 int line_offset, | 229 int line_offset, |
| 224 int column_offset, | 230 int column_offset, |
| 225 v8::Extension* extension, | 231 v8::Extension* extension, |
| 226 ScriptDataImpl* pre_data, | 232 ScriptDataImpl* pre_data, |
| 227 Handle<Object> script_data, | 233 Handle<Object> script_data, |
| 228 NativesFlag is_natives_code); | 234 NativesFlag is_natives_code); |
| 229 | 235 |
| 230 // Compile a String source within a context for Eval. | 236 // Compile a String source within a context for Eval. |
| 231 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, | 237 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, |
| 232 Handle<Context> context, | 238 Handle<Context> context, |
| 233 bool is_global); | 239 bool is_global, |
| 240 bool is_strict); | |
| 234 | 241 |
| 235 // Compile from function info (used for lazy compilation). Returns true on | 242 // Compile from function info (used for lazy compilation). Returns true on |
| 236 // success and false if the compilation resulted in a stack overflow. | 243 // success and false if the compilation resulted in a stack overflow. |
| 237 static bool CompileLazy(CompilationInfo* info); | 244 static bool CompileLazy(CompilationInfo* info); |
| 238 | 245 |
| 239 // Compile a shared function info object (the function is possibly lazily | 246 // Compile a shared function info object (the function is possibly lazily |
| 240 // compiled). | 247 // compiled). |
| 241 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 248 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
| 242 Handle<Script> script); | 249 Handle<Script> script); |
| 243 | 250 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 269 FrameElement::ClearConstantList(); | 276 FrameElement::ClearConstantList(); |
| 270 Result::ClearConstantList(); | 277 Result::ClearConstantList(); |
| 271 } | 278 } |
| 272 } | 279 } |
| 273 }; | 280 }; |
| 274 | 281 |
| 275 | 282 |
| 276 } } // namespace v8::internal | 283 } } // namespace v8::internal |
| 277 | 284 |
| 278 #endif // V8_COMPILER_H_ | 285 #endif // V8_COMPILER_H_ |
| OLD | NEW |