| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 virtual ~CompilationInfo(); | 59 virtual ~CompilationInfo(); |
| 60 | 60 |
| 61 Isolate* isolate() const { | 61 Isolate* isolate() const { |
| 62 return isolate_; | 62 return isolate_; |
| 63 } | 63 } |
| 64 Zone* zone() { return zone_; } | 64 Zone* zone() { return zone_; } |
| 65 bool is_osr() const { return !osr_ast_id_.IsNone(); } | 65 bool is_osr() const { return !osr_ast_id_.IsNone(); } |
| 66 bool is_lazy() const { return IsLazy::decode(flags_); } | 66 bool is_lazy() const { return IsLazy::decode(flags_); } |
| 67 bool is_eval() const { return IsEval::decode(flags_); } | 67 bool is_eval() const { return IsEval::decode(flags_); } |
| 68 bool is_global() const { return IsGlobal::decode(flags_); } | 68 bool is_global() const { return IsGlobal::decode(flags_); } |
| 69 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } | 69 StrictMode strict_mode() const { return StrictModeField::decode(flags_); } |
| 70 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } | |
| 71 LanguageMode language_mode() const { | |
| 72 return LanguageModeField::decode(flags_); | |
| 73 } | |
| 74 bool is_in_loop() const { return IsInLoop::decode(flags_); } | 70 bool is_in_loop() const { return IsInLoop::decode(flags_); } |
| 75 FunctionLiteral* function() const { return function_; } | 71 FunctionLiteral* function() const { return function_; } |
| 76 Scope* scope() const { return scope_; } | 72 Scope* scope() const { return scope_; } |
| 77 Scope* global_scope() const { return global_scope_; } | 73 Scope* global_scope() const { return global_scope_; } |
| 78 Handle<Code> code() const { return code_; } | 74 Handle<Code> code() const { return code_; } |
| 79 Handle<JSFunction> closure() const { return closure_; } | 75 Handle<JSFunction> closure() const { return closure_; } |
| 80 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 76 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 81 Handle<Script> script() const { return script_; } | 77 Handle<Script> script() const { return script_; } |
| 82 HydrogenCodeStub* code_stub() const {return code_stub_; } | 78 HydrogenCodeStub* code_stub() const {return code_stub_; } |
| 83 v8::Extension* extension() const { return extension_; } | 79 v8::Extension* extension() const { return extension_; } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 102 ASSERT(IsStub()); | 98 ASSERT(IsStub()); |
| 103 parameter_count_ = parameter_count; | 99 parameter_count_ = parameter_count; |
| 104 } | 100 } |
| 105 | 101 |
| 106 void set_this_has_uses(bool has_no_uses) { | 102 void set_this_has_uses(bool has_no_uses) { |
| 107 this_has_uses_ = has_no_uses; | 103 this_has_uses_ = has_no_uses; |
| 108 } | 104 } |
| 109 bool this_has_uses() { | 105 bool this_has_uses() { |
| 110 return this_has_uses_; | 106 return this_has_uses_; |
| 111 } | 107 } |
| 112 void SetLanguageMode(LanguageMode language_mode) { | 108 void SetStrictMode(StrictMode strict_mode) { |
| 113 ASSERT(this->language_mode() == CLASSIC_MODE || | 109 ASSERT(this->strict_mode() == SLOPPY || this->strict_mode() == strict_mode); |
| 114 this->language_mode() == language_mode || | 110 flags_ = StrictModeField::update(flags_, strict_mode); |
| 115 language_mode == EXTENDED_MODE); | |
| 116 flags_ = LanguageModeField::update(flags_, language_mode); | |
| 117 } | 111 } |
| 118 void MarkAsInLoop() { | 112 void MarkAsInLoop() { |
| 119 ASSERT(is_lazy()); | 113 ASSERT(is_lazy()); |
| 120 flags_ |= IsInLoop::encode(true); | 114 flags_ |= IsInLoop::encode(true); |
| 121 } | 115 } |
| 122 void MarkAsNative() { | 116 void MarkAsNative() { |
| 123 flags_ |= IsNative::encode(true); | 117 flags_ |= IsNative::encode(true); |
| 124 } | 118 } |
| 125 | 119 |
| 126 bool is_native() const { | 120 bool is_native() const { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 void SetFunction(FunctionLiteral* literal) { | 168 void SetFunction(FunctionLiteral* literal) { |
| 175 ASSERT(function_ == NULL); | 169 ASSERT(function_ == NULL); |
| 176 function_ = literal; | 170 function_ = literal; |
| 177 } | 171 } |
| 178 // When the scope is applied, we may have deferred work to do on the function. | 172 // When the scope is applied, we may have deferred work to do on the function. |
| 179 void PrepareForCompilation(Scope* scope); | 173 void PrepareForCompilation(Scope* scope); |
| 180 void SetGlobalScope(Scope* global_scope) { | 174 void SetGlobalScope(Scope* global_scope) { |
| 181 ASSERT(global_scope_ == NULL); | 175 ASSERT(global_scope_ == NULL); |
| 182 global_scope_ = global_scope; | 176 global_scope_ = global_scope; |
| 183 } | 177 } |
| 178 Handle<FixedArray> feedback_vector() const { |
| 179 return feedback_vector_; |
| 180 } |
| 184 void SetCode(Handle<Code> code) { code_ = code; } | 181 void SetCode(Handle<Code> code) { code_ = code; } |
| 185 void SetExtension(v8::Extension* extension) { | 182 void SetExtension(v8::Extension* extension) { |
| 186 ASSERT(!is_lazy()); | 183 ASSERT(!is_lazy()); |
| 187 extension_ = extension; | 184 extension_ = extension; |
| 188 } | 185 } |
| 189 void SetPreParseData(ScriptDataImpl* pre_parse_data) { | 186 void SetPreParseData(ScriptDataImpl* pre_parse_data) { |
| 190 ASSERT(!is_lazy()); | 187 ASSERT(!is_lazy()); |
| 191 pre_parse_data_ = pre_parse_data; | 188 pre_parse_data_ = pre_parse_data; |
| 192 } | 189 } |
| 193 void SetContext(Handle<Context> context) { | 190 void SetContext(Handle<Context> context) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // false by default. | 350 // false by default. |
| 354 // | 351 // |
| 355 // Compilation is either eager or lazy. | 352 // Compilation is either eager or lazy. |
| 356 class IsLazy: public BitField<bool, 0, 1> {}; | 353 class IsLazy: public BitField<bool, 0, 1> {}; |
| 357 // Flags that can be set for eager compilation. | 354 // Flags that can be set for eager compilation. |
| 358 class IsEval: public BitField<bool, 1, 1> {}; | 355 class IsEval: public BitField<bool, 1, 1> {}; |
| 359 class IsGlobal: public BitField<bool, 2, 1> {}; | 356 class IsGlobal: public BitField<bool, 2, 1> {}; |
| 360 // Flags that can be set for lazy compilation. | 357 // Flags that can be set for lazy compilation. |
| 361 class IsInLoop: public BitField<bool, 3, 1> {}; | 358 class IsInLoop: public BitField<bool, 3, 1> {}; |
| 362 // Strict mode - used in eager compilation. | 359 // Strict mode - used in eager compilation. |
| 363 class LanguageModeField: public BitField<LanguageMode, 4, 2> {}; | 360 class StrictModeField: public BitField<StrictMode, 4, 1> {}; |
| 364 // Is this a function from our natives. | 361 // Is this a function from our natives. |
| 365 class IsNative: public BitField<bool, 6, 1> {}; | 362 class IsNative: public BitField<bool, 5, 1> {}; |
| 366 // Is this code being compiled with support for deoptimization.. | 363 // Is this code being compiled with support for deoptimization.. |
| 367 class SupportsDeoptimization: public BitField<bool, 7, 1> {}; | 364 class SupportsDeoptimization: public BitField<bool, 6, 1> {}; |
| 368 // If compiling for debugging produce just full code matching the | 365 // If compiling for debugging produce just full code matching the |
| 369 // initial mode setting. | 366 // initial mode setting. |
| 370 class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; | 367 class IsCompilingForDebugging: public BitField<bool, 7, 1> {}; |
| 371 // If the compiled code contains calls that require building a frame | 368 // If the compiled code contains calls that require building a frame |
| 372 class IsCalling: public BitField<bool, 9, 1> {}; | 369 class IsCalling: public BitField<bool, 8, 1> {}; |
| 373 // If the compiled code contains calls that require building a frame | 370 // If the compiled code contains calls that require building a frame |
| 374 class IsDeferredCalling: public BitField<bool, 10, 1> {}; | 371 class IsDeferredCalling: public BitField<bool, 9, 1> {}; |
| 375 // If the compiled code contains calls that require building a frame | 372 // If the compiled code contains calls that require building a frame |
| 376 class IsNonDeferredCalling: public BitField<bool, 11, 1> {}; | 373 class IsNonDeferredCalling: public BitField<bool, 10, 1> {}; |
| 377 // If the compiled code saves double caller registers that it clobbers. | 374 // If the compiled code saves double caller registers that it clobbers. |
| 378 class SavesCallerDoubles: public BitField<bool, 12, 1> {}; | 375 class SavesCallerDoubles: public BitField<bool, 11, 1> {}; |
| 379 // If the set of valid statements is restricted. | 376 // If the set of valid statements is restricted. |
| 380 class ParseRestricitonField: public BitField<ParseRestriction, 13, 1> {}; | 377 class ParseRestricitonField: public BitField<ParseRestriction, 12, 1> {}; |
| 381 // If the function requires a frame (for unspecified reasons) | 378 // If the function requires a frame (for unspecified reasons) |
| 382 class RequiresFrame: public BitField<bool, 14, 1> {}; | 379 class RequiresFrame: public BitField<bool, 13, 1> {}; |
| 383 | 380 |
| 384 unsigned flags_; | 381 unsigned flags_; |
| 385 | 382 |
| 386 // Fields filled in by the compilation pipeline. | 383 // Fields filled in by the compilation pipeline. |
| 387 // AST filled in by the parser. | 384 // AST filled in by the parser. |
| 388 FunctionLiteral* function_; | 385 FunctionLiteral* function_; |
| 389 // The scope of the function literal as a convenience. Set to indicate | 386 // The scope of the function literal as a convenience. Set to indicate |
| 390 // that scopes have been analyzed. | 387 // that scopes have been analyzed. |
| 391 Scope* scope_; | 388 Scope* scope_; |
| 392 // The global scope provided as a convenience. | 389 // The global scope provided as a convenience. |
| 393 Scope* global_scope_; | 390 Scope* global_scope_; |
| 394 // For compiled stubs, the stub object | 391 // For compiled stubs, the stub object |
| 395 HydrogenCodeStub* code_stub_; | 392 HydrogenCodeStub* code_stub_; |
| 396 // The compiled code. | 393 // The compiled code. |
| 397 Handle<Code> code_; | 394 Handle<Code> code_; |
| 398 | 395 |
| 399 // Possible initial inputs to the compilation process. | 396 // Possible initial inputs to the compilation process. |
| 400 Handle<JSFunction> closure_; | 397 Handle<JSFunction> closure_; |
| 401 Handle<SharedFunctionInfo> shared_info_; | 398 Handle<SharedFunctionInfo> shared_info_; |
| 402 Handle<Script> script_; | 399 Handle<Script> script_; |
| 403 | 400 |
| 404 // Fields possibly needed for eager compilation, NULL by default. | 401 // Fields possibly needed for eager compilation, NULL by default. |
| 405 v8::Extension* extension_; | 402 v8::Extension* extension_; |
| 406 ScriptDataImpl* pre_parse_data_; | 403 ScriptDataImpl* pre_parse_data_; |
| 407 | 404 |
| 408 // The context of the caller for eval code, and the global context for a | 405 // The context of the caller for eval code, and the global context for a |
| 409 // global script. Will be a null handle otherwise. | 406 // global script. Will be a null handle otherwise. |
| 410 Handle<Context> context_; | 407 Handle<Context> context_; |
| 411 | 408 |
| 409 // Used by codegen, ultimately kept rooted by the SharedFunctionInfo. |
| 410 Handle<FixedArray> feedback_vector_; |
| 411 |
| 412 // Compilation mode flag and whether deoptimization is allowed. | 412 // Compilation mode flag and whether deoptimization is allowed. |
| 413 Mode mode_; | 413 Mode mode_; |
| 414 BailoutId osr_ast_id_; | 414 BailoutId osr_ast_id_; |
| 415 // The unoptimized code we patched for OSR may not be the shared code | 415 // The unoptimized code we patched for OSR may not be the shared code |
| 416 // afterwards, since we may need to compile it again to include deoptimization | 416 // afterwards, since we may need to compile it again to include deoptimization |
| 417 // data. Keep track which code we patched. | 417 // data. Keep track which code we patched. |
| 418 Handle<Code> unoptimized_code_; | 418 Handle<Code> unoptimized_code_; |
| 419 | 419 |
| 420 // Flag whether compilation needs to be aborted due to dependency change. | 420 // Flag whether compilation needs to be aborted due to dependency change. |
| 421 bool abort_due_to_dependency_; | 421 bool abort_due_to_dependency_; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 ClearExceptionFlag flag); | 611 ClearExceptionFlag flag); |
| 612 static Handle<Code> GetCodeForDebugging(Handle<JSFunction> function); | 612 static Handle<Code> GetCodeForDebugging(Handle<JSFunction> function); |
| 613 | 613 |
| 614 #ifdef ENABLE_DEBUGGER_SUPPORT | 614 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 615 static void CompileForLiveEdit(Handle<Script> script); | 615 static void CompileForLiveEdit(Handle<Script> script); |
| 616 #endif | 616 #endif |
| 617 | 617 |
| 618 // Compile a String source within a context for eval. | 618 // Compile a String source within a context for eval. |
| 619 static Handle<JSFunction> GetFunctionFromEval(Handle<String> source, | 619 static Handle<JSFunction> GetFunctionFromEval(Handle<String> source, |
| 620 Handle<Context> context, | 620 Handle<Context> context, |
| 621 LanguageMode language_mode, | 621 StrictMode strict_mode, |
| 622 ParseRestriction restriction, | 622 ParseRestriction restriction, |
| 623 int scope_position); | 623 int scope_position); |
| 624 | 624 |
| 625 // Compile a String source within a context. | 625 // Compile a String source within a context. |
| 626 static Handle<SharedFunctionInfo> CompileScript(Handle<String> source, | 626 static Handle<SharedFunctionInfo> CompileScript(Handle<String> source, |
| 627 Handle<Object> script_name, | 627 Handle<Object> script_name, |
| 628 int line_offset, | 628 int line_offset, |
| 629 int column_offset, | 629 int column_offset, |
| 630 bool is_shared_cross_origin, | 630 bool is_shared_cross_origin, |
| 631 Handle<Context> context, | 631 Handle<Context> context, |
| 632 v8::Extension* extension, | 632 v8::Extension* extension, |
| 633 ScriptDataImpl* pre_data, | 633 ScriptDataImpl* pre_data, |
| 634 Handle<Object> script_data, | |
| 635 NativesFlag is_natives_code); | 634 NativesFlag is_natives_code); |
| 636 | 635 |
| 637 // Create a shared function info object (the code may be lazily compiled). | 636 // Create a shared function info object (the code may be lazily compiled). |
| 638 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 637 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
| 639 Handle<Script> script); | 638 Handle<Script> script); |
| 640 | 639 |
| 641 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; | 640 enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; |
| 642 | 641 |
| 643 // Generate and return optimized code or start a concurrent optimization job. | 642 // Generate and return optimized code or start a concurrent optimization job. |
| 644 // In the latter case, return the InOptimizationQueue builtin. On failure, | 643 // In the latter case, return the InOptimizationQueue builtin. On failure, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 unsigned info_zone_start_allocation_size_; | 678 unsigned info_zone_start_allocation_size_; |
| 680 ElapsedTimer timer_; | 679 ElapsedTimer timer_; |
| 681 | 680 |
| 682 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); | 681 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); |
| 683 }; | 682 }; |
| 684 | 683 |
| 685 | 684 |
| 686 } } // namespace v8::internal | 685 } } // namespace v8::internal |
| 687 | 686 |
| 688 #endif // V8_COMPILER_H_ | 687 #endif // V8_COMPILER_H_ |
| OLD | NEW |