| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 45   explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); | 45   explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); | 
| 46   explicit CompilationInfo(Handle<JSFunction> closure); | 46   explicit CompilationInfo(Handle<JSFunction> closure); | 
| 47 | 47 | 
| 48   Isolate* isolate() { | 48   Isolate* isolate() { | 
| 49     ASSERT(Isolate::Current() == isolate_); | 49     ASSERT(Isolate::Current() == isolate_); | 
| 50     return isolate_; | 50     return isolate_; | 
| 51   } | 51   } | 
| 52   bool is_lazy() const { return IsLazy::decode(flags_); } | 52   bool is_lazy() const { return IsLazy::decode(flags_); } | 
| 53   bool is_eval() const { return IsEval::decode(flags_); } | 53   bool is_eval() const { return IsEval::decode(flags_); } | 
| 54   bool is_global() const { return IsGlobal::decode(flags_); } | 54   bool is_global() const { return IsGlobal::decode(flags_); } | 
| 55   bool is_strict_mode() const { return strict_mode_flag() == kStrictMode; } | 55   bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } | 
| 56   StrictModeFlag strict_mode_flag() const { | 56   bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } | 
| 57     return StrictModeFlagField::decode(flags_); | 57   LanguageMode language_mode() const { | 
|  | 58     return LanguageModeField::decode(flags_); | 
| 58   } | 59   } | 
| 59   bool is_in_loop() const { return IsInLoop::decode(flags_); } | 60   bool is_in_loop() const { return IsInLoop::decode(flags_); } | 
| 60   FunctionLiteral* function() const { return function_; } | 61   FunctionLiteral* function() const { return function_; } | 
| 61   Scope* scope() const { return scope_; } | 62   Scope* scope() const { return scope_; } | 
| 62   Handle<Code> code() const { return code_; } | 63   Handle<Code> code() const { return code_; } | 
| 63   Handle<JSFunction> closure() const { return closure_; } | 64   Handle<JSFunction> closure() const { return closure_; } | 
| 64   Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 65   Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 
| 65   Handle<Script> script() const { return script_; } | 66   Handle<Script> script() const { return script_; } | 
| 66   v8::Extension* extension() const { return extension_; } | 67   v8::Extension* extension() const { return extension_; } | 
| 67   ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } | 68   ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } | 
| 68   Handle<Context> calling_context() const { return calling_context_; } | 69   Handle<Context> calling_context() const { return calling_context_; } | 
| 69   int osr_ast_id() const { return osr_ast_id_; } | 70   int osr_ast_id() const { return osr_ast_id_; } | 
| 70 | 71 | 
| 71   void MarkAsEval() { | 72   void MarkAsEval() { | 
| 72     ASSERT(!is_lazy()); | 73     ASSERT(!is_lazy()); | 
| 73     flags_ |= IsEval::encode(true); | 74     flags_ |= IsEval::encode(true); | 
| 74   } | 75   } | 
| 75   void MarkAsGlobal() { | 76   void MarkAsGlobal() { | 
| 76     ASSERT(!is_lazy()); | 77     ASSERT(!is_lazy()); | 
| 77     flags_ |= IsGlobal::encode(true); | 78     flags_ |= IsGlobal::encode(true); | 
| 78   } | 79   } | 
| 79   void SetStrictModeFlag(StrictModeFlag strict_mode_flag) { | 80   void SetLanguageMode(LanguageMode language_mode) { | 
| 80     ASSERT(StrictModeFlagField::decode(flags_) == kNonStrictMode || | 81     ASSERT(this->language_mode() == CLASSIC_MODE || | 
| 81            StrictModeFlagField::decode(flags_) == strict_mode_flag); | 82            this->language_mode() == language_mode || | 
| 82     flags_ = StrictModeFlagField::update(flags_, strict_mode_flag); | 83            language_mode == EXTENDED_MODE); | 
|  | 84     flags_ = LanguageModeField::update(flags_, language_mode); | 
| 83   } | 85   } | 
| 84   void MarkAsInLoop() { | 86   void MarkAsInLoop() { | 
| 85     ASSERT(is_lazy()); | 87     ASSERT(is_lazy()); | 
| 86     flags_ |= IsInLoop::encode(true); | 88     flags_ |= IsInLoop::encode(true); | 
| 87   } | 89   } | 
| 88   void MarkAsNative() { | 90   void MarkAsNative() { | 
| 89     flags_ |= IsNative::encode(true); | 91     flags_ |= IsNative::encode(true); | 
| 90   } | 92   } | 
| 91   bool is_native() const { | 93   bool is_native() const { | 
| 92     return IsNative::decode(flags_); | 94     return IsNative::decode(flags_); | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 182 | 184 | 
| 183   CompilationInfo() : function_(NULL) {} | 185   CompilationInfo() : function_(NULL) {} | 
| 184 | 186 | 
| 185   void Initialize(Mode mode) { | 187   void Initialize(Mode mode) { | 
| 186     mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 188     mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 
| 187     ASSERT(!script_.is_null()); | 189     ASSERT(!script_.is_null()); | 
| 188     if (script_->type()->value() == Script::TYPE_NATIVE) { | 190     if (script_->type()->value() == Script::TYPE_NATIVE) { | 
| 189       MarkAsNative(); | 191       MarkAsNative(); | 
| 190     } | 192     } | 
| 191     if (!shared_info_.is_null()) { | 193     if (!shared_info_.is_null()) { | 
| 192       ASSERT(strict_mode_flag() == kNonStrictMode); | 194       ASSERT(language_mode() == CLASSIC_MODE); | 
| 193       SetStrictModeFlag(shared_info_->strict_mode_flag()); | 195       SetLanguageMode(shared_info_->language_mode()); | 
| 194     } | 196     } | 
| 195   } | 197   } | 
| 196 | 198 | 
| 197   void SetMode(Mode mode) { | 199   void SetMode(Mode mode) { | 
| 198     ASSERT(V8::UseCrankshaft()); | 200     ASSERT(V8::UseCrankshaft()); | 
| 199     mode_ = mode; | 201     mode_ = mode; | 
| 200   } | 202   } | 
| 201 | 203 | 
| 202   // Flags using template class BitField<type, start, length>.  All are | 204   // Flags using template class BitField<type, start, length>.  All are | 
| 203   // false by default. | 205   // false by default. | 
| 204   // | 206   // | 
| 205   // Compilation is either eager or lazy. | 207   // Compilation is either eager or lazy. | 
| 206   class IsLazy:   public BitField<bool, 0, 1> {}; | 208   class IsLazy:   public BitField<bool, 0, 1> {}; | 
| 207   // Flags that can be set for eager compilation. | 209   // Flags that can be set for eager compilation. | 
| 208   class IsEval:   public BitField<bool, 1, 1> {}; | 210   class IsEval:   public BitField<bool, 1, 1> {}; | 
| 209   class IsGlobal: public BitField<bool, 2, 1> {}; | 211   class IsGlobal: public BitField<bool, 2, 1> {}; | 
| 210   // Flags that can be set for lazy compilation. | 212   // Flags that can be set for lazy compilation. | 
| 211   class IsInLoop: public BitField<bool, 3, 1> {}; | 213   class IsInLoop: public BitField<bool, 3, 1> {}; | 
| 212   // Strict mode - used in eager compilation. | 214   // Strict mode - used in eager compilation. | 
| 213   class StrictModeFlagField: public BitField<StrictModeFlag, 4, 1> {}; | 215   class LanguageModeField: public BitField<LanguageMode, 4, 2> {}; | 
| 214   // Is this a function from our natives. | 216   // Is this a function from our natives. | 
| 215   class IsNative: public BitField<bool, 6, 1> {}; | 217   class IsNative: public BitField<bool, 6, 1> {}; | 
| 216   // Is this code being compiled with support for deoptimization.. | 218   // Is this code being compiled with support for deoptimization.. | 
| 217   class SupportsDeoptimization: public BitField<bool, 7, 1> {}; | 219   class SupportsDeoptimization: public BitField<bool, 7, 1> {}; | 
| 218   // If compiling for debugging produce just full code matching the | 220   // If compiling for debugging produce just full code matching the | 
| 219   // initial mode setting. | 221   // initial mode setting. | 
| 220   class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; | 222   class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; | 
| 221 | 223 | 
| 222 | 224 | 
| 223   unsigned flags_; | 225   unsigned flags_; | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 282                                             int column_offset, | 284                                             int column_offset, | 
| 283                                             v8::Extension* extension, | 285                                             v8::Extension* extension, | 
| 284                                             ScriptDataImpl* pre_data, | 286                                             ScriptDataImpl* pre_data, | 
| 285                                             Handle<Object> script_data, | 287                                             Handle<Object> script_data, | 
| 286                                             NativesFlag is_natives_code); | 288                                             NativesFlag is_natives_code); | 
| 287 | 289 | 
| 288   // Compile a String source within a context for Eval. | 290   // Compile a String source within a context for Eval. | 
| 289   static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, | 291   static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, | 
| 290                                                 Handle<Context> context, | 292                                                 Handle<Context> context, | 
| 291                                                 bool is_global, | 293                                                 bool is_global, | 
| 292                                                 StrictModeFlag strict_mode, | 294                                                 LanguageMode language_mode, | 
| 293                                                 int scope_position); | 295                                                 int scope_position); | 
| 294 | 296 | 
| 295   // Compile from function info (used for lazy compilation). Returns true on | 297   // Compile from function info (used for lazy compilation). Returns true on | 
| 296   // success and false if the compilation resulted in a stack overflow. | 298   // success and false if the compilation resulted in a stack overflow. | 
| 297   static bool CompileLazy(CompilationInfo* info); | 299   static bool CompileLazy(CompilationInfo* info); | 
| 298 | 300 | 
| 299   // Compile a shared function info object (the function is possibly lazily | 301   // Compile a shared function info object (the function is possibly lazily | 
| 300   // compiled). | 302   // compiled). | 
| 301   static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 303   static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 
| 302                                                       Handle<Script> script); | 304                                                       Handle<Script> script); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 313 | 315 | 
| 314   static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 316   static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 
| 315                                         CompilationInfo* info, | 317                                         CompilationInfo* info, | 
| 316                                         Handle<SharedFunctionInfo> shared); | 318                                         Handle<SharedFunctionInfo> shared); | 
| 317 }; | 319 }; | 
| 318 | 320 | 
| 319 | 321 | 
| 320 } }  // namespace v8::internal | 322 } }  // namespace v8::internal | 
| 321 | 323 | 
| 322 #endif  // V8_COMPILER_H_ | 324 #endif  // V8_COMPILER_H_ | 
| OLD | NEW | 
|---|