OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 !(info->EnsureFeedbackVector(), FullCodeGenerator::MakeCode(info))) { | 790 !(info->EnsureFeedbackVector(), FullCodeGenerator::MakeCode(info))) { |
791 Isolate* isolate = info->isolate(); | 791 Isolate* isolate = info->isolate(); |
792 if (!isolate->has_pending_exception()) isolate->StackOverflow(); | 792 if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
793 return false; | 793 return false; |
794 } | 794 } |
795 return true; | 795 return true; |
796 } | 796 } |
797 | 797 |
798 bool UseIgnition(CompilationInfo* info) { | 798 bool UseIgnition(CompilationInfo* info) { |
799 // TODO(4681): Generator functions are not yet supported. | 799 // TODO(4681): Generator functions are not yet supported. |
800 if ((info->has_shared_info() && info->shared_info()->is_generator()) || | 800 if (info->shared_info()->is_generator()) { |
801 (info->has_literal() && IsGeneratorFunction(info->literal()->kind()))) { | |
802 return false; | 801 return false; |
803 } | 802 } |
804 | 803 |
805 // TODO(4681): Resuming a suspended frame is not supported. | 804 // TODO(4681): Resuming a suspended frame is not supported. |
806 if (info->has_shared_info() && info->shared_info()->HasBuiltinFunctionId() && | 805 if (info->shared_info()->HasBuiltinFunctionId() && |
807 (info->shared_info()->builtin_function_id() == kGeneratorObjectNext || | 806 (info->shared_info()->builtin_function_id() == kGeneratorObjectNext || |
808 info->shared_info()->builtin_function_id() == kGeneratorObjectReturn || | 807 info->shared_info()->builtin_function_id() == kGeneratorObjectReturn || |
809 info->shared_info()->builtin_function_id() == kGeneratorObjectThrow)) { | 808 info->shared_info()->builtin_function_id() == kGeneratorObjectThrow)) { |
810 return false; | 809 return false; |
811 } | 810 } |
812 | 811 |
813 // Checks whether top level functions should be passed by the filter. | 812 // Checks whether top level functions should be passed by the filter. |
814 if (info->closure().is_null()) { | 813 if (info->shared_info()->is_toplevel()) { |
815 Vector<const char> filter = CStrVector(FLAG_ignition_filter); | 814 Vector<const char> filter = CStrVector(FLAG_ignition_filter); |
816 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*'); | 815 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*'); |
817 } | 816 } |
818 | 817 |
819 // Finally respect the filter. | 818 // Finally respect the filter. |
820 return info->closure()->shared()->PassesFilter(FLAG_ignition_filter); | 819 return info->shared_info()->PassesFilter(FLAG_ignition_filter); |
821 } | 820 } |
822 | 821 |
823 int CodeAndMetadataSize(CompilationInfo* info) { | 822 int CodeAndMetadataSize(CompilationInfo* info) { |
824 int size = 0; | 823 int size = 0; |
825 if (info->has_bytecode_array()) { | 824 if (info->has_bytecode_array()) { |
826 Handle<BytecodeArray> bytecode_array = info->bytecode_array(); | 825 Handle<BytecodeArray> bytecode_array = info->bytecode_array(); |
827 size += bytecode_array->BytecodeArraySize(); | 826 size += bytecode_array->BytecodeArraySize(); |
828 size += bytecode_array->constant_pool()->Size(); | 827 size += bytecode_array->constant_pool()->Size(); |
829 size += bytecode_array->handler_table()->Size(); | 828 size += bytecode_array->handler_table()->Size(); |
830 size += bytecode_array->source_position_table()->Size(); | 829 size += bytecode_array->source_position_table()->Size(); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 TRACE_EVENT0("v8", info->is_eval() ? "V8.CompileEval" : "V8.Compile"); | 1308 TRACE_EVENT0("v8", info->is_eval() ? "V8.CompileEval" : "V8.Compile"); |
1310 | 1309 |
1311 // Allocate a shared function info object. | 1310 // Allocate a shared function info object. |
1312 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 1311 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
1313 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); | 1312 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); |
1314 result->set_is_toplevel(true); | 1313 result->set_is_toplevel(true); |
1315 if (info->is_eval()) { | 1314 if (info->is_eval()) { |
1316 // Eval scripts cannot be (re-)compiled without context. | 1315 // Eval scripts cannot be (re-)compiled without context. |
1317 result->set_allows_lazy_compilation_without_context(false); | 1316 result->set_allows_lazy_compilation_without_context(false); |
1318 } | 1317 } |
| 1318 parse_info->set_shared_info(result); |
1319 | 1319 |
1320 // Compile the code. | 1320 // Compile the code. |
1321 if (!CompileBaselineCode(info)) { | 1321 if (!CompileBaselineCode(info)) { |
1322 return Handle<SharedFunctionInfo>::null(); | 1322 return Handle<SharedFunctionInfo>::null(); |
1323 } | 1323 } |
1324 | 1324 |
1325 // Install compilation result on the shared function info | 1325 // Install compilation result on the shared function info |
1326 Handle<ScopeInfo> scope_info = | 1326 Handle<ScopeInfo> scope_info = |
1327 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); | 1327 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); |
1328 InstallBaselineCompilationResult(info, result, scope_info); | 1328 InstallBaselineCompilationResult(info, result, scope_info); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 Handle<SharedFunctionInfo> result; | 1756 Handle<SharedFunctionInfo> result; |
1757 if (!maybe_existing.ToHandle(&result)) { | 1757 if (!maybe_existing.ToHandle(&result)) { |
1758 result = NewSharedFunctionInfoForLiteral(isolate, literal, script); | 1758 result = NewSharedFunctionInfoForLiteral(isolate, literal, script); |
1759 result->set_is_toplevel(false); | 1759 result->set_is_toplevel(false); |
1760 } | 1760 } |
1761 | 1761 |
1762 Zone zone(isolate->allocator()); | 1762 Zone zone(isolate->allocator()); |
1763 ParseInfo parse_info(&zone, script); | 1763 ParseInfo parse_info(&zone, script); |
1764 CompilationInfo info(&parse_info); | 1764 CompilationInfo info(&parse_info); |
1765 parse_info.set_literal(literal); | 1765 parse_info.set_literal(literal); |
| 1766 parse_info.set_shared_info(result); |
1766 parse_info.set_scope(literal->scope()); | 1767 parse_info.set_scope(literal->scope()); |
1767 parse_info.set_language_mode(literal->scope()->language_mode()); | 1768 parse_info.set_language_mode(literal->scope()->language_mode()); |
1768 if (outer_info->will_serialize()) info.PrepareForSerializing(); | 1769 if (outer_info->will_serialize()) info.PrepareForSerializing(); |
1769 if (outer_info->is_first_compile()) info.MarkAsFirstCompile(); | 1770 if (outer_info->is_first_compile()) info.MarkAsFirstCompile(); |
1770 if (outer_info->is_debug()) info.MarkAsDebug(); | 1771 if (outer_info->is_debug()) info.MarkAsDebug(); |
1771 | 1772 |
1772 LiveEditFunctionTracker live_edit_tracker(isolate, literal); | 1773 LiveEditFunctionTracker live_edit_tracker(isolate, literal); |
1773 // Determine if the function can be lazily compiled. This is necessary to | 1774 // Determine if the function can be lazily compiled. This is necessary to |
1774 // allow some of our builtin JS files to be lazily compiled. These | 1775 // allow some of our builtin JS files to be lazily compiled. These |
1775 // builtins cannot be handled lazily by the parser, since we have to know | 1776 // builtins cannot be handled lazily by the parser, since we have to know |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 MaybeHandle<Code> code; | 1958 MaybeHandle<Code> code; |
1958 if (cached.code != nullptr) code = handle(cached.code); | 1959 if (cached.code != nullptr) code = handle(cached.code); |
1959 Handle<Context> native_context(function->context()->native_context()); | 1960 Handle<Context> native_context(function->context()->native_context()); |
1960 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1961 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1961 literals, BailoutId::None()); | 1962 literals, BailoutId::None()); |
1962 } | 1963 } |
1963 } | 1964 } |
1964 | 1965 |
1965 } // namespace internal | 1966 } // namespace internal |
1966 } // namespace v8 | 1967 } // namespace v8 |
OLD | NEW |