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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "scopeinfo.h" | 49 #include "scopeinfo.h" |
50 #include "scopes.h" | 50 #include "scopes.h" |
51 #include "vm-state-inl.h" | 51 #include "vm-state-inl.h" |
52 | 52 |
53 namespace v8 { | 53 namespace v8 { |
54 namespace internal { | 54 namespace internal { |
55 | 55 |
56 | 56 |
57 CompilationInfo::CompilationInfo(Handle<Script> script, | 57 CompilationInfo::CompilationInfo(Handle<Script> script, |
58 Zone* zone) | 58 Zone* zone) |
59 : flags_(LanguageModeField::encode(SLOPPY_MODE)), | 59 : flags_(StrictModeField::encode(SLOPPY)), |
60 script_(script), | 60 script_(script), |
61 osr_ast_id_(BailoutId::None()), | 61 osr_ast_id_(BailoutId::None()), |
62 parameter_count_(0), | 62 parameter_count_(0), |
63 this_has_uses_(true), | 63 this_has_uses_(true), |
64 optimization_id_(-1) { | 64 optimization_id_(-1) { |
65 Initialize(script->GetIsolate(), BASE, zone); | 65 Initialize(script->GetIsolate(), BASE, zone); |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, | 69 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
70 Zone* zone) | 70 Zone* zone) |
71 : flags_(LanguageModeField::encode(SLOPPY_MODE) | IsLazy::encode(true)), | 71 : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)), |
72 shared_info_(shared_info), | 72 shared_info_(shared_info), |
73 script_(Handle<Script>(Script::cast(shared_info->script()))), | 73 script_(Handle<Script>(Script::cast(shared_info->script()))), |
74 osr_ast_id_(BailoutId::None()), | 74 osr_ast_id_(BailoutId::None()), |
75 parameter_count_(0), | 75 parameter_count_(0), |
76 this_has_uses_(true), | 76 this_has_uses_(true), |
77 optimization_id_(-1) { | 77 optimization_id_(-1) { |
78 Initialize(script_->GetIsolate(), BASE, zone); | 78 Initialize(script_->GetIsolate(), BASE, zone); |
79 } | 79 } |
80 | 80 |
81 | 81 |
82 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, | 82 CompilationInfo::CompilationInfo(Handle<JSFunction> closure, |
83 Zone* zone) | 83 Zone* zone) |
84 : flags_(LanguageModeField::encode(SLOPPY_MODE) | IsLazy::encode(true)), | 84 : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)), |
85 closure_(closure), | 85 closure_(closure), |
86 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), | 86 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
87 script_(Handle<Script>(Script::cast(shared_info_->script()))), | 87 script_(Handle<Script>(Script::cast(shared_info_->script()))), |
88 context_(closure->context()), | 88 context_(closure->context()), |
89 osr_ast_id_(BailoutId::None()), | 89 osr_ast_id_(BailoutId::None()), |
90 parameter_count_(0), | 90 parameter_count_(0), |
91 this_has_uses_(true), | 91 this_has_uses_(true), |
92 optimization_id_(-1) { | 92 optimization_id_(-1) { |
93 Initialize(script_->GetIsolate(), BASE, zone); | 93 Initialize(script_->GetIsolate(), BASE, zone); |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, | 97 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, |
98 Isolate* isolate, | 98 Isolate* isolate, |
99 Zone* zone) | 99 Zone* zone) |
100 : flags_(LanguageModeField::encode(SLOPPY_MODE) | | 100 : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)), |
101 IsLazy::encode(true)), | |
102 osr_ast_id_(BailoutId::None()), | 101 osr_ast_id_(BailoutId::None()), |
103 parameter_count_(0), | 102 parameter_count_(0), |
104 this_has_uses_(true), | 103 this_has_uses_(true), |
105 optimization_id_(-1) { | 104 optimization_id_(-1) { |
106 Initialize(isolate, STUB, zone); | 105 Initialize(isolate, STUB, zone); |
107 code_stub_ = stub; | 106 code_stub_ = stub; |
108 } | 107 } |
109 | 108 |
110 | 109 |
111 void CompilationInfo::Initialize(Isolate* isolate, | 110 void CompilationInfo::Initialize(Isolate* isolate, |
(...skipping 18 matching lines...) Expand all Loading... |
130 if (mode == STUB) { | 129 if (mode == STUB) { |
131 mode_ = STUB; | 130 mode_ = STUB; |
132 return; | 131 return; |
133 } | 132 } |
134 mode_ = mode; | 133 mode_ = mode; |
135 abort_due_to_dependency_ = false; | 134 abort_due_to_dependency_ = false; |
136 if (script_->type()->value() == Script::TYPE_NATIVE) { | 135 if (script_->type()->value() == Script::TYPE_NATIVE) { |
137 MarkAsNative(); | 136 MarkAsNative(); |
138 } | 137 } |
139 if (!shared_info_.is_null()) { | 138 if (!shared_info_.is_null()) { |
140 ASSERT(language_mode() == SLOPPY_MODE); | 139 ASSERT(strict_mode() == SLOPPY); |
141 SetLanguageMode(shared_info_->language_mode()); | 140 SetStrictMode(shared_info_->strict_mode()); |
142 } | 141 } |
143 set_bailout_reason(kUnknown); | 142 set_bailout_reason(kUnknown); |
144 } | 143 } |
145 | 144 |
146 | 145 |
147 CompilationInfo::~CompilationInfo() { | 146 CompilationInfo::~CompilationInfo() { |
148 delete deferred_handles_; | 147 delete deferred_handles_; |
149 delete no_frame_ranges_; | 148 delete no_frame_ranges_; |
150 #ifdef DEBUG | 149 #ifdef DEBUG |
151 // Check that no dependent maps have been added or added dependent maps have | 150 // Check that no dependent maps have been added or added dependent maps have |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 // Set the expected number of properties for instances. | 573 // Set the expected number of properties for instances. |
575 FunctionLiteral* lit = info->function(); | 574 FunctionLiteral* lit = info->function(); |
576 int expected = lit->expected_property_count(); | 575 int expected = lit->expected_property_count(); |
577 SetExpectedNofPropertiesFromEstimate(shared, expected); | 576 SetExpectedNofPropertiesFromEstimate(shared, expected); |
578 | 577 |
579 // Check the function has compiled code. | 578 // Check the function has compiled code. |
580 ASSERT(shared->is_compiled()); | 579 ASSERT(shared->is_compiled()); |
581 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); | 580 shared->set_dont_optimize_reason(lit->dont_optimize_reason()); |
582 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); | 581 shared->set_dont_inline(lit->flags()->Contains(kDontInline)); |
583 shared->set_ast_node_count(lit->ast_node_count()); | 582 shared->set_ast_node_count(lit->ast_node_count()); |
584 shared->set_language_mode(lit->language_mode()); | 583 shared->set_strict_mode(lit->strict_mode()); |
585 } | 584 } |
586 | 585 |
587 | 586 |
588 // Sets the function info on a function. | 587 // Sets the function info on a function. |
589 // The start_position points to the first '(' character after the function name | 588 // The start_position points to the first '(' character after the function name |
590 // in the full script source. When counting characters in the script source the | 589 // in the full script source. When counting characters in the script source the |
591 // the first character is number 0 (not 1). | 590 // the first character is number 0 (not 1). |
592 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | 591 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
593 FunctionLiteral* lit, | 592 FunctionLiteral* lit, |
594 bool is_toplevel, | 593 bool is_toplevel, |
595 Handle<Script> script) { | 594 Handle<Script> script) { |
596 function_info->set_length(lit->parameter_count()); | 595 function_info->set_length(lit->parameter_count()); |
597 function_info->set_formal_parameter_count(lit->parameter_count()); | 596 function_info->set_formal_parameter_count(lit->parameter_count()); |
598 function_info->set_script(*script); | 597 function_info->set_script(*script); |
599 function_info->set_function_token_position(lit->function_token_position()); | 598 function_info->set_function_token_position(lit->function_token_position()); |
600 function_info->set_start_position(lit->start_position()); | 599 function_info->set_start_position(lit->start_position()); |
601 function_info->set_end_position(lit->end_position()); | 600 function_info->set_end_position(lit->end_position()); |
602 function_info->set_is_expression(lit->is_expression()); | 601 function_info->set_is_expression(lit->is_expression()); |
603 function_info->set_is_anonymous(lit->is_anonymous()); | 602 function_info->set_is_anonymous(lit->is_anonymous()); |
604 function_info->set_is_toplevel(is_toplevel); | 603 function_info->set_is_toplevel(is_toplevel); |
605 function_info->set_inferred_name(*lit->inferred_name()); | 604 function_info->set_inferred_name(*lit->inferred_name()); |
606 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); | 605 function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); |
607 function_info->set_allows_lazy_compilation_without_context( | 606 function_info->set_allows_lazy_compilation_without_context( |
608 lit->AllowsLazyCompilationWithoutContext()); | 607 lit->AllowsLazyCompilationWithoutContext()); |
609 function_info->set_language_mode(lit->language_mode()); | 608 function_info->set_strict_mode(lit->strict_mode()); |
610 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); | 609 function_info->set_uses_arguments(lit->scope()->arguments() != NULL); |
611 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); | 610 function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); |
612 function_info->set_ast_node_count(lit->ast_node_count()); | 611 function_info->set_ast_node_count(lit->ast_node_count()); |
613 function_info->set_is_function(lit->is_function()); | 612 function_info->set_is_function(lit->is_function()); |
614 function_info->set_dont_optimize_reason(lit->dont_optimize_reason()); | 613 function_info->set_dont_optimize_reason(lit->dont_optimize_reason()); |
615 function_info->set_dont_inline(lit->flags()->Contains(kDontInline)); | 614 function_info->set_dont_inline(lit->flags()->Contains(kDontInline)); |
616 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); | 615 function_info->set_dont_cache(lit->flags()->Contains(kDontCache)); |
617 function_info->set_is_generator(lit->is_generator()); | 616 function_info->set_is_generator(lit->is_generator()); |
618 } | 617 } |
619 | 618 |
(...skipping 10 matching lines...) Expand all Loading... |
630 return false; | 629 return false; |
631 } | 630 } |
632 return true; | 631 return true; |
633 } | 632 } |
634 | 633 |
635 | 634 |
636 static Handle<Code> GetUnoptimizedCodeCommon(CompilationInfo* info) { | 635 static Handle<Code> GetUnoptimizedCodeCommon(CompilationInfo* info) { |
637 VMState<COMPILER> state(info->isolate()); | 636 VMState<COMPILER> state(info->isolate()); |
638 PostponeInterruptsScope postpone(info->isolate()); | 637 PostponeInterruptsScope postpone(info->isolate()); |
639 if (!Parser::Parse(info)) return Handle<Code>::null(); | 638 if (!Parser::Parse(info)) return Handle<Code>::null(); |
640 LanguageMode language_mode = info->function()->language_mode(); | 639 info->SetStrictMode(info->function()->strict_mode()); |
641 info->SetLanguageMode(language_mode); | |
642 | 640 |
643 if (!CompileUnoptimizedCode(info)) return Handle<Code>::null(); | 641 if (!CompileUnoptimizedCode(info)) return Handle<Code>::null(); |
644 Compiler::RecordFunctionCompilation( | 642 Compiler::RecordFunctionCompilation( |
645 Logger::LAZY_COMPILE_TAG, info, info->shared_info()); | 643 Logger::LAZY_COMPILE_TAG, info, info->shared_info()); |
646 UpdateSharedFunctionInfo(info); | 644 UpdateSharedFunctionInfo(info); |
647 ASSERT_EQ(Code::FUNCTION, info->code()->kind()); | 645 ASSERT_EQ(Code::FUNCTION, info->code()->kind()); |
648 return info->code(); | 646 return info->code(); |
649 } | 647 } |
650 | 648 |
651 | 649 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 | 737 |
740 #ifdef ENABLE_DEBUGGER_SUPPORT | 738 #ifdef ENABLE_DEBUGGER_SUPPORT |
741 void Compiler::CompileForLiveEdit(Handle<Script> script) { | 739 void Compiler::CompileForLiveEdit(Handle<Script> script) { |
742 // TODO(635): support extensions. | 740 // TODO(635): support extensions. |
743 CompilationInfoWithZone info(script); | 741 CompilationInfoWithZone info(script); |
744 PostponeInterruptsScope postpone(info.isolate()); | 742 PostponeInterruptsScope postpone(info.isolate()); |
745 VMState<COMPILER> state(info.isolate()); | 743 VMState<COMPILER> state(info.isolate()); |
746 | 744 |
747 info.MarkAsGlobal(); | 745 info.MarkAsGlobal(); |
748 if (!Parser::Parse(&info)) return; | 746 if (!Parser::Parse(&info)) return; |
749 LanguageMode language_mode = info.function()->language_mode(); | 747 info.SetStrictMode(info.function()->strict_mode()); |
750 info.SetLanguageMode(language_mode); | |
751 | 748 |
752 LiveEditFunctionTracker tracker(info.isolate(), info.function()); | 749 LiveEditFunctionTracker tracker(info.isolate(), info.function()); |
753 if (!CompileUnoptimizedCode(&info)) return; | 750 if (!CompileUnoptimizedCode(&info)) return; |
754 if (!info.shared_info().is_null()) { | 751 if (!info.shared_info().is_null()) { |
755 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), | 752 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), |
756 info.zone()); | 753 info.zone()); |
757 info.shared_info()->set_scope_info(*scope_info); | 754 info.shared_info()->set_scope_info(*scope_info); |
758 } | 755 } |
759 tracker.RecordRootFunctionInfo(info.code()); | 756 tracker.RecordRootFunctionInfo(info.code()); |
760 } | 757 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 #ifdef ENABLE_DEBUGGER_SUPPORT | 846 #ifdef ENABLE_DEBUGGER_SUPPORT |
850 isolate->debugger()->OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS); | 847 isolate->debugger()->OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS); |
851 #endif | 848 #endif |
852 | 849 |
853 return result; | 850 return result; |
854 } | 851 } |
855 | 852 |
856 | 853 |
857 Handle<JSFunction> Compiler::GetFunctionFromEval(Handle<String> source, | 854 Handle<JSFunction> Compiler::GetFunctionFromEval(Handle<String> source, |
858 Handle<Context> context, | 855 Handle<Context> context, |
859 LanguageMode language_mode, | 856 StrictMode strict_mode, |
860 ParseRestriction restriction, | 857 ParseRestriction restriction, |
861 int scope_position) { | 858 int scope_position) { |
862 Isolate* isolate = source->GetIsolate(); | 859 Isolate* isolate = source->GetIsolate(); |
863 int source_length = source->length(); | 860 int source_length = source->length(); |
864 isolate->counters()->total_eval_size()->Increment(source_length); | 861 isolate->counters()->total_eval_size()->Increment(source_length); |
865 isolate->counters()->total_compile_size()->Increment(source_length); | 862 isolate->counters()->total_compile_size()->Increment(source_length); |
866 | 863 |
867 CompilationCache* compilation_cache = isolate->compilation_cache(); | 864 CompilationCache* compilation_cache = isolate->compilation_cache(); |
868 Handle<SharedFunctionInfo> shared_info = compilation_cache->LookupEval( | 865 Handle<SharedFunctionInfo> shared_info = compilation_cache->LookupEval( |
869 source, context, language_mode, scope_position); | 866 source, context, strict_mode, scope_position); |
870 | 867 |
871 if (shared_info.is_null()) { | 868 if (shared_info.is_null()) { |
872 Handle<Script> script = isolate->factory()->NewScript(source); | 869 Handle<Script> script = isolate->factory()->NewScript(source); |
873 CompilationInfoWithZone info(script); | 870 CompilationInfoWithZone info(script); |
874 info.MarkAsEval(); | 871 info.MarkAsEval(); |
875 if (context->IsNativeContext()) info.MarkAsGlobal(); | 872 if (context->IsNativeContext()) info.MarkAsGlobal(); |
876 info.SetLanguageMode(language_mode); | 873 info.SetStrictMode(strict_mode); |
877 info.SetParseRestriction(restriction); | 874 info.SetParseRestriction(restriction); |
878 info.SetContext(context); | 875 info.SetContext(context); |
879 | 876 |
880 #if ENABLE_DEBUGGER_SUPPORT | 877 #if ENABLE_DEBUGGER_SUPPORT |
881 Debug::RecordEvalCaller(script); | 878 Debug::RecordEvalCaller(script); |
882 #endif // ENABLE_DEBUGGER_SUPPORT | 879 #endif // ENABLE_DEBUGGER_SUPPORT |
883 | 880 |
884 shared_info = CompileToplevel(&info); | 881 shared_info = CompileToplevel(&info); |
885 | 882 |
886 if (shared_info.is_null()) { | 883 if (shared_info.is_null()) { |
887 return Handle<JSFunction>::null(); | 884 return Handle<JSFunction>::null(); |
888 } else { | 885 } else { |
889 // Explicitly disable optimization for eval code. We're not yet prepared | 886 // Explicitly disable optimization for eval code. We're not yet prepared |
890 // to handle eval-code in the optimizing compiler. | 887 // to handle eval-code in the optimizing compiler. |
891 shared_info->DisableOptimization(kEval); | 888 shared_info->DisableOptimization(kEval); |
892 | 889 |
893 // If caller is strict mode, the result must be in strict mode or | 890 // If caller is strict mode, the result must be in strict mode as well. |
894 // extended mode as well, but not the other way around. Consider: | 891 ASSERT(strict_mode == SLOPPY || shared_info->strict_mode() == STRICT); |
895 // eval("'use strict'; ..."); | |
896 ASSERT(language_mode != STRICT_MODE || !shared_info->is_sloppy_mode()); | |
897 // If caller is in extended mode, the result must also be in | |
898 // extended mode. | |
899 ASSERT(language_mode != EXTENDED_MODE || | |
900 shared_info->is_extended_mode()); | |
901 if (!shared_info->dont_cache()) { | 892 if (!shared_info->dont_cache()) { |
902 compilation_cache->PutEval( | 893 compilation_cache->PutEval( |
903 source, context, shared_info, scope_position); | 894 source, context, shared_info, scope_position); |
904 } | 895 } |
905 } | 896 } |
906 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { | 897 } else if (shared_info->ic_age() != isolate->heap()->global_ic_age()) { |
907 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); | 898 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); |
908 } | 899 } |
909 | 900 |
910 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 901 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 | 955 |
965 script->set_data(script_data.is_null() ? isolate->heap()->undefined_value() | 956 script->set_data(script_data.is_null() ? isolate->heap()->undefined_value() |
966 : *script_data); | 957 : *script_data); |
967 | 958 |
968 // Compile the function and add it to the cache. | 959 // Compile the function and add it to the cache. |
969 CompilationInfoWithZone info(script); | 960 CompilationInfoWithZone info(script); |
970 info.MarkAsGlobal(); | 961 info.MarkAsGlobal(); |
971 info.SetExtension(extension); | 962 info.SetExtension(extension); |
972 info.SetPreParseData(pre_data); | 963 info.SetPreParseData(pre_data); |
973 info.SetContext(context); | 964 info.SetContext(context); |
974 if (FLAG_use_strict) { | 965 if (FLAG_use_strict) info.SetStrictMode(STRICT); |
975 info.SetLanguageMode(FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE); | |
976 } | |
977 result = CompileToplevel(&info); | 966 result = CompileToplevel(&info); |
978 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 967 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
979 compilation_cache->PutScript(source, context, result); | 968 compilation_cache->PutScript(source, context, result); |
980 } | 969 } |
981 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { | 970 } else if (result->ic_age() != isolate->heap()->global_ic_age()) { |
982 result->ResetForNewContext(isolate->heap()->global_ic_age()); | 971 result->ResetForNewContext(isolate->heap()->global_ic_age()); |
983 } | 972 } |
984 | 973 |
985 if (result.is_null()) isolate->ReportPendingMessages(); | 974 if (result.is_null()) isolate->ReportPendingMessages(); |
986 return result; | 975 return result; |
987 } | 976 } |
988 | 977 |
989 | 978 |
990 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 979 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
991 Handle<Script> script) { | 980 Handle<Script> script) { |
992 // Precondition: code has been parsed and scopes have been analyzed. | 981 // Precondition: code has been parsed and scopes have been analyzed. |
993 CompilationInfoWithZone info(script); | 982 CompilationInfoWithZone info(script); |
994 info.SetFunction(literal); | 983 info.SetFunction(literal); |
995 info.PrepareForCompilation(literal->scope()); | 984 info.PrepareForCompilation(literal->scope()); |
996 info.SetLanguageMode(literal->scope()->language_mode()); | 985 info.SetStrictMode(literal->scope()->strict_mode()); |
997 | 986 |
998 Isolate* isolate = info.isolate(); | 987 Isolate* isolate = info.isolate(); |
999 Factory* factory = isolate->factory(); | 988 Factory* factory = isolate->factory(); |
1000 LiveEditFunctionTracker live_edit_tracker(isolate, literal); | 989 LiveEditFunctionTracker live_edit_tracker(isolate, literal); |
1001 // Determine if the function can be lazily compiled. This is necessary to | 990 // Determine if the function can be lazily compiled. This is necessary to |
1002 // allow some of our builtin JS files to be lazily compiled. These | 991 // allow some of our builtin JS files to be lazily compiled. These |
1003 // builtins cannot be handled lazily by the parser, since we have to know | 992 // builtins cannot be handled lazily by the parser, since we have to know |
1004 // if a function uses the special natives syntax, which is something the | 993 // if a function uses the special natives syntax, which is something the |
1005 // parser records. | 994 // parser records. |
1006 // If the debugger requests compilation for break points, we cannot be | 995 // If the debugger requests compilation for break points, we cannot be |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 Handle<FixedArray> literals(function->literals()); | 1070 Handle<FixedArray> literals(function->literals()); |
1082 Handle<Context> native_context(function->context()->native_context()); | 1071 Handle<Context> native_context(function->context()->native_context()); |
1083 SharedFunctionInfo::AddToOptimizedCodeMap( | 1072 SharedFunctionInfo::AddToOptimizedCodeMap( |
1084 shared, native_context, code, literals, info->osr_ast_id()); | 1073 shared, native_context, code, literals, info->osr_ast_id()); |
1085 } | 1074 } |
1086 } | 1075 } |
1087 | 1076 |
1088 | 1077 |
1089 static bool CompileOptimizedPrologue(CompilationInfo* info) { | 1078 static bool CompileOptimizedPrologue(CompilationInfo* info) { |
1090 if (!Parser::Parse(info)) return false; | 1079 if (!Parser::Parse(info)) return false; |
1091 LanguageMode language_mode = info->function()->language_mode(); | 1080 info->SetStrictMode(info->function()->strict_mode()); |
1092 info->SetLanguageMode(language_mode); | |
1093 | 1081 |
1094 if (!Rewriter::Rewrite(info)) return false; | 1082 if (!Rewriter::Rewrite(info)) return false; |
1095 if (!Scope::Analyze(info)) return false; | 1083 if (!Scope::Analyze(info)) return false; |
1096 ASSERT(info->scope() != NULL); | 1084 ASSERT(info->scope() != NULL); |
1097 return true; | 1085 return true; |
1098 } | 1086 } |
1099 | 1087 |
1100 | 1088 |
1101 static bool GetOptimizedCodeNow(CompilationInfo* info) { | 1089 static bool GetOptimizedCodeNow(CompilationInfo* info) { |
1102 if (!CompileOptimizedPrologue(info)) return false; | 1090 if (!CompileOptimizedPrologue(info)) return false; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 AllowHandleDereference allow_deref; | 1289 AllowHandleDereference allow_deref; |
1302 bool tracing_on = info()->IsStub() | 1290 bool tracing_on = info()->IsStub() |
1303 ? FLAG_trace_hydrogen_stubs | 1291 ? FLAG_trace_hydrogen_stubs |
1304 : (FLAG_trace_hydrogen && | 1292 : (FLAG_trace_hydrogen && |
1305 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1293 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1306 return (tracing_on && | 1294 return (tracing_on && |
1307 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1295 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1308 } | 1296 } |
1309 | 1297 |
1310 } } // namespace v8::internal | 1298 } } // namespace v8::internal |
OLD | NEW |