| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Isolate* isolate() { | 49 Isolate* isolate() { |
| 50 ASSERT(Isolate::Current() == isolate_); | 50 ASSERT(Isolate::Current() == isolate_); |
| 51 return isolate_; | 51 return isolate_; |
| 52 } | 52 } |
| 53 bool is_lazy() const { return (flags_ & IsLazy::mask()) != 0; } | 53 bool is_lazy() const { return (flags_ & IsLazy::mask()) != 0; } |
| 54 bool is_eval() const { return (flags_ & IsEval::mask()) != 0; } | 54 bool is_eval() const { return (flags_ & IsEval::mask()) != 0; } |
| 55 bool is_global() const { return (flags_ & IsGlobal::mask()) != 0; } | 55 bool is_global() const { return (flags_ & IsGlobal::mask()) != 0; } |
| 56 bool is_strict() const { return (flags_ & IsStrict::mask()) != 0; } |
| 56 bool is_in_loop() const { return (flags_ & IsInLoop::mask()) != 0; } | 57 bool is_in_loop() const { return (flags_ & IsInLoop::mask()) != 0; } |
| 57 FunctionLiteral* function() const { return function_; } | 58 FunctionLiteral* function() const { return function_; } |
| 58 Scope* scope() const { return scope_; } | 59 Scope* scope() const { return scope_; } |
| 59 Handle<Code> code() const { return code_; } | 60 Handle<Code> code() const { return code_; } |
| 60 Handle<JSFunction> closure() const { return closure_; } | 61 Handle<JSFunction> closure() const { return closure_; } |
| 61 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 62 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 62 Handle<Script> script() const { return script_; } | 63 Handle<Script> script() const { return script_; } |
| 63 v8::Extension* extension() const { return extension_; } | 64 v8::Extension* extension() const { return extension_; } |
| 64 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } | 65 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } |
| 65 Handle<Context> calling_context() const { return calling_context_; } | 66 Handle<Context> calling_context() const { return calling_context_; } |
| 66 int osr_ast_id() const { return osr_ast_id_; } | 67 int osr_ast_id() const { return osr_ast_id_; } |
| 67 | 68 |
| 68 void MarkAsEval() { | 69 void MarkAsEval() { |
| 69 ASSERT(!is_lazy()); | 70 ASSERT(!is_lazy()); |
| 70 flags_ |= IsEval::encode(true); | 71 flags_ |= IsEval::encode(true); |
| 71 } | 72 } |
| 72 void MarkAsGlobal() { | 73 void MarkAsGlobal() { |
| 73 ASSERT(!is_lazy()); | 74 ASSERT(!is_lazy()); |
| 74 flags_ |= IsGlobal::encode(true); | 75 flags_ |= IsGlobal::encode(true); |
| 75 } | 76 } |
| 77 void MarkAsStrict() { |
| 78 ASSERT(!is_lazy()); |
| 79 flags_ |= IsStrict::encode(true); |
| 80 } |
| 81 StrictModeFlag StrictMode() { |
| 82 return is_strict() ? kStrictMode : kNonStrictMode; |
| 83 } |
| 76 void MarkAsInLoop() { | 84 void MarkAsInLoop() { |
| 77 ASSERT(is_lazy()); | 85 ASSERT(is_lazy()); |
| 78 flags_ |= IsInLoop::encode(true); | 86 flags_ |= IsInLoop::encode(true); |
| 79 } | 87 } |
| 80 void SetFunction(FunctionLiteral* literal) { | 88 void SetFunction(FunctionLiteral* literal) { |
| 81 ASSERT(function_ == NULL); | 89 ASSERT(function_ == NULL); |
| 82 function_ = literal; | 90 function_ = literal; |
| 83 } | 91 } |
| 84 void SetScope(Scope* scope) { | 92 void SetScope(Scope* scope) { |
| 85 ASSERT(scope_ == NULL); | 93 ASSERT(scope_ == NULL); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // Flags using template class BitField<type, start, length>. All are | 169 // Flags using template class BitField<type, start, length>. All are |
| 162 // false by default. | 170 // false by default. |
| 163 // | 171 // |
| 164 // Compilation is either eager or lazy. | 172 // Compilation is either eager or lazy. |
| 165 class IsLazy: public BitField<bool, 0, 1> {}; | 173 class IsLazy: public BitField<bool, 0, 1> {}; |
| 166 // Flags that can be set for eager compilation. | 174 // Flags that can be set for eager compilation. |
| 167 class IsEval: public BitField<bool, 1, 1> {}; | 175 class IsEval: public BitField<bool, 1, 1> {}; |
| 168 class IsGlobal: public BitField<bool, 2, 1> {}; | 176 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 169 // Flags that can be set for lazy compilation. | 177 // Flags that can be set for lazy compilation. |
| 170 class IsInLoop: public BitField<bool, 3, 1> {}; | 178 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 179 // Strict mode - used in eager compilation. |
| 180 class IsStrict: public BitField<bool, 4, 1> {}; |
| 171 | 181 |
| 172 unsigned flags_; | 182 unsigned flags_; |
| 173 | 183 |
| 174 // Fields filled in by the compilation pipeline. | 184 // Fields filled in by the compilation pipeline. |
| 175 // AST filled in by the parser. | 185 // AST filled in by the parser. |
| 176 FunctionLiteral* function_; | 186 FunctionLiteral* function_; |
| 177 // The scope of the function literal as a convenience. Set to indicate | 187 // The scope of the function literal as a convenience. Set to indicate |
| 178 // that scopes have been analyzed. | 188 // that scopes have been analyzed. |
| 179 Scope* scope_; | 189 Scope* scope_; |
| 180 // The compiled code. | 190 // The compiled code. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 int line_offset, | 239 int line_offset, |
| 230 int column_offset, | 240 int column_offset, |
| 231 v8::Extension* extension, | 241 v8::Extension* extension, |
| 232 ScriptDataImpl* pre_data, | 242 ScriptDataImpl* pre_data, |
| 233 Handle<Object> script_data, | 243 Handle<Object> script_data, |
| 234 NativesFlag is_natives_code); | 244 NativesFlag is_natives_code); |
| 235 | 245 |
| 236 // Compile a String source within a context for Eval. | 246 // Compile a String source within a context for Eval. |
| 237 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, | 247 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, |
| 238 Handle<Context> context, | 248 Handle<Context> context, |
| 239 bool is_global); | 249 bool is_global, |
| 250 StrictModeFlag strict_mode); |
| 240 | 251 |
| 241 // Compile from function info (used for lazy compilation). Returns true on | 252 // Compile from function info (used for lazy compilation). Returns true on |
| 242 // success and false if the compilation resulted in a stack overflow. | 253 // success and false if the compilation resulted in a stack overflow. |
| 243 static bool CompileLazy(CompilationInfo* info); | 254 static bool CompileLazy(CompilationInfo* info); |
| 244 | 255 |
| 245 // Compile a shared function info object (the function is possibly lazily | 256 // Compile a shared function info object (the function is possibly lazily |
| 246 // compiled). | 257 // compiled). |
| 247 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 258 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
| 248 Handle<Script> script); | 259 Handle<Script> script); |
| 249 | 260 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 276 isolate->frame_element_constant_list()->Clear(); | 287 isolate->frame_element_constant_list()->Clear(); |
| 277 isolate->result_constant_list()->Clear(); | 288 isolate->result_constant_list()->Clear(); |
| 278 } | 289 } |
| 279 } | 290 } |
| 280 }; | 291 }; |
| 281 | 292 |
| 282 | 293 |
| 283 } } // namespace v8::internal | 294 } } // namespace v8::internal |
| 284 | 295 |
| 285 #endif // V8_COMPILER_H_ | 296 #endif // V8_COMPILER_H_ |
| OLD | NEW |