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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 // Compile the code. | 875 // Compile the code. |
876 if (!MakeCode(info)) { | 876 if (!MakeCode(info)) { |
877 if (!isolate->has_pending_exception()) { | 877 if (!isolate->has_pending_exception()) { |
878 isolate->StackOverflow(); | 878 isolate->StackOverflow(); |
879 } | 879 } |
880 } else { | 880 } else { |
881 InstallCodeCommon(info); | 881 InstallCodeCommon(info); |
882 | 882 |
883 if (info->IsOptimizing()) { | 883 if (info->IsOptimizing()) { |
884 Handle<Code> code = info->code(); | 884 Handle<Code> code = info->code(); |
885 ASSERT(shared->scope_info() != ScopeInfo::Empty()); | 885 ASSERT(shared->scope_info() != ScopeInfo::Empty(isolate)); |
886 info->closure()->ReplaceCode(*code); | 886 info->closure()->ReplaceCode(*code); |
887 InsertCodeIntoOptimizedCodeMap(info); | 887 InsertCodeIntoOptimizedCodeMap(info); |
888 return true; | 888 return true; |
889 } else { | 889 } else { |
890 return InstallFullCode(info); | 890 return InstallFullCode(info); |
891 } | 891 } |
892 } | 892 } |
893 } | 893 } |
894 | 894 |
895 ASSERT(info->code().is_null()); | 895 ASSERT(info->code().is_null()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 status = optimizing_compiler->AbortOptimization(); | 976 status = optimizing_compiler->AbortOptimization(); |
977 } else { | 977 } else { |
978 status = optimizing_compiler->GenerateAndInstallCode(); | 978 status = optimizing_compiler->GenerateAndInstallCode(); |
979 ASSERT(status == OptimizingCompiler::SUCCEEDED || | 979 ASSERT(status == OptimizingCompiler::SUCCEEDED || |
980 status == OptimizingCompiler::BAILED_OUT); | 980 status == OptimizingCompiler::BAILED_OUT); |
981 } | 981 } |
982 | 982 |
983 InstallCodeCommon(*info); | 983 InstallCodeCommon(*info); |
984 if (status == OptimizingCompiler::SUCCEEDED) { | 984 if (status == OptimizingCompiler::SUCCEEDED) { |
985 Handle<Code> code = info->code(); | 985 Handle<Code> code = info->code(); |
986 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty()); | 986 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty(isolate)); |
987 info->closure()->ReplaceCode(*code); | 987 info->closure()->ReplaceCode(*code); |
988 if (info->shared_info()->SearchOptimizedCodeMap( | 988 if (info->shared_info()->SearchOptimizedCodeMap( |
989 info->closure()->context()->native_context()) == -1) { | 989 info->closure()->context()->native_context()) == -1) { |
990 InsertCodeIntoOptimizedCodeMap(*info); | 990 InsertCodeIntoOptimizedCodeMap(*info); |
991 } | 991 } |
992 } else { | 992 } else { |
993 info->SetCode(Handle<Code>(info->shared_info()->code())); | 993 info->SetCode(Handle<Code>(info->shared_info()->code())); |
994 InstallFullCode(*info); | 994 InstallFullCode(*info); |
995 } | 995 } |
996 } | 996 } |
997 | 997 |
998 | 998 |
999 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 999 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
1000 Handle<Script> script) { | 1000 Handle<Script> script) { |
1001 // Precondition: code has been parsed and scopes have been analyzed. | 1001 // Precondition: code has been parsed and scopes have been analyzed. |
1002 CompilationInfoWithZone info(script); | 1002 CompilationInfoWithZone info(script); |
1003 info.SetFunction(literal); | 1003 info.SetFunction(literal); |
1004 info.SetScope(literal->scope()); | 1004 info.SetScope(literal->scope()); |
1005 info.SetLanguageMode(literal->scope()->language_mode()); | 1005 info.SetLanguageMode(literal->scope()->language_mode()); |
1006 | 1006 |
1007 LiveEditFunctionTracker live_edit_tracker(info.isolate(), literal); | 1007 Isolate* isolate = info.isolate(); |
| 1008 LiveEditFunctionTracker live_edit_tracker(isolate, literal); |
1008 // Determine if the function can be lazily compiled. This is necessary to | 1009 // Determine if the function can be lazily compiled. This is necessary to |
1009 // allow some of our builtin JS files to be lazily compiled. These | 1010 // allow some of our builtin JS files to be lazily compiled. These |
1010 // builtins cannot be handled lazily by the parser, since we have to know | 1011 // builtins cannot be handled lazily by the parser, since we have to know |
1011 // if a function uses the special natives syntax, which is something the | 1012 // if a function uses the special natives syntax, which is something the |
1012 // parser records. | 1013 // parser records. |
1013 // If the debugger requests compilation for break points, we cannot be | 1014 // If the debugger requests compilation for break points, we cannot be |
1014 // aggressive about lazy compilation, because it might trigger compilation | 1015 // aggressive about lazy compilation, because it might trigger compilation |
1015 // of functions without an outer context when setting a breakpoint through | 1016 // of functions without an outer context when setting a breakpoint through |
1016 // Debug::FindSharedFunctionInfoInScript. | 1017 // Debug::FindSharedFunctionInfoInScript. |
1017 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); | 1018 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); |
1018 bool allow_lazy = literal->AllowsLazyCompilation() && | 1019 bool allow_lazy = literal->AllowsLazyCompilation() && |
1019 !DebuggerWantsEagerCompilation(&info, allow_lazy_without_ctx); | 1020 !DebuggerWantsEagerCompilation(&info, allow_lazy_without_ctx); |
1020 | 1021 |
1021 Handle<ScopeInfo> scope_info(ScopeInfo::Empty()); | 1022 Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate)); |
1022 | 1023 |
1023 // Generate code | 1024 // Generate code |
1024 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) { | 1025 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) { |
1025 Handle<Code> code = info.isolate()->builtins()->LazyCompile(); | 1026 Handle<Code> code = isolate->builtins()->LazyCompile(); |
1026 info.SetCode(code); | 1027 info.SetCode(code); |
1027 } else if (GenerateCode(&info)) { | 1028 } else if (GenerateCode(&info)) { |
1028 ASSERT(!info.code().is_null()); | 1029 ASSERT(!info.code().is_null()); |
1029 scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 1030 scope_info = ScopeInfo::Create(info.scope(), info.zone()); |
1030 } else { | 1031 } else { |
1031 return Handle<SharedFunctionInfo>::null(); | 1032 return Handle<SharedFunctionInfo>::null(); |
1032 } | 1033 } |
1033 | 1034 |
1034 // Create a shared function info object. | 1035 // Create a shared function info object. |
1035 Handle<SharedFunctionInfo> result = | 1036 Handle<SharedFunctionInfo> result = |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 } | 1120 } |
1120 } | 1121 } |
1121 | 1122 |
1122 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1123 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
1123 Handle<Script>(info->script()), | 1124 Handle<Script>(info->script()), |
1124 Handle<Code>(info->code()), | 1125 Handle<Code>(info->code()), |
1125 info)); | 1126 info)); |
1126 } | 1127 } |
1127 | 1128 |
1128 } } // namespace v8::internal | 1129 } } // namespace v8::internal |
OLD | NEW |