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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 if (info->has_bytecode_array()) { | 533 if (info->has_bytecode_array()) { |
534 DCHECK(!shared->HasBytecodeArray()); // Only compiled once. | 534 DCHECK(!shared->HasBytecodeArray()); // Only compiled once. |
535 shared->set_bytecode_array(*info->bytecode_array()); | 535 shared->set_bytecode_array(*info->bytecode_array()); |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) { | 539 MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) { |
540 VMState<COMPILER> state(info->isolate()); | 540 VMState<COMPILER> state(info->isolate()); |
541 PostponeInterruptsScope postpone(info->isolate()); | 541 PostponeInterruptsScope postpone(info->isolate()); |
542 | 542 |
| 543 // Create a canonical handle scope if compiling ignition bytecode. This is |
| 544 // required by the constant array builder to de-duplicate common objects |
| 545 // without dereferencing handles. |
| 546 std::unique_ptr<CanonicalHandleScope> canonical; |
| 547 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(info->isolate())); |
| 548 |
543 // Parse and update CompilationInfo with the results. | 549 // Parse and update CompilationInfo with the results. |
544 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); | 550 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); |
545 Handle<SharedFunctionInfo> shared = info->shared_info(); | 551 Handle<SharedFunctionInfo> shared = info->shared_info(); |
546 DCHECK_EQ(shared->language_mode(), info->literal()->language_mode()); | 552 DCHECK_EQ(shared->language_mode(), info->literal()->language_mode()); |
547 | 553 |
548 // Compile either unoptimized code or bytecode for the interpreter. | 554 // Compile either unoptimized code or bytecode for the interpreter. |
549 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); | 555 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); |
550 | 556 |
551 // Update the shared function info with the scope info. | 557 // Update the shared function info with the scope info. |
552 InstallSharedScopeInfo(info, shared); | 558 InstallSharedScopeInfo(info, shared); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { | 1061 Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { |
1056 Isolate* isolate = info->isolate(); | 1062 Isolate* isolate = info->isolate(); |
1057 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1063 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1058 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); | 1064 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); |
1059 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); | 1065 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); |
1060 PostponeInterruptsScope postpone(isolate); | 1066 PostponeInterruptsScope postpone(isolate); |
1061 DCHECK(!isolate->native_context().is_null()); | 1067 DCHECK(!isolate->native_context().is_null()); |
1062 ParseInfo* parse_info = info->parse_info(); | 1068 ParseInfo* parse_info = info->parse_info(); |
1063 Handle<Script> script = parse_info->script(); | 1069 Handle<Script> script = parse_info->script(); |
1064 | 1070 |
| 1071 // Create a canonical handle scope if compiling ignition bytecode. This is |
| 1072 // required by the constant array builder to de-duplicate common objects |
| 1073 // without dereferencing handles. |
| 1074 std::unique_ptr<CanonicalHandleScope> canonical; |
| 1075 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate)); |
| 1076 |
1065 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? | 1077 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? |
1066 FixedArray* array = isolate->native_context()->embedder_data(); | 1078 FixedArray* array = isolate->native_context()->embedder_data(); |
1067 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); | 1079 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); |
1068 | 1080 |
1069 isolate->debug()->OnBeforeCompile(script); | 1081 isolate->debug()->OnBeforeCompile(script); |
1070 | 1082 |
1071 DCHECK(parse_info->is_eval() || parse_info->is_global() || | 1083 DCHECK(parse_info->is_eval() || parse_info->is_global() || |
1072 parse_info->is_module()); | 1084 parse_info->is_module()); |
1073 | 1085 |
1074 parse_info->set_toplevel(); | 1086 parse_info->set_toplevel(); |
(...skipping 22 matching lines...) Expand all Loading... |
1097 if (!parse_allow_lazy && | 1109 if (!parse_allow_lazy && |
1098 (options == ScriptCompiler::kProduceParserCache || | 1110 (options == ScriptCompiler::kProduceParserCache || |
1099 options == ScriptCompiler::kConsumeParserCache)) { | 1111 options == ScriptCompiler::kConsumeParserCache)) { |
1100 // We are going to parse eagerly, but we either 1) have cached data | 1112 // We are going to parse eagerly, but we either 1) have cached data |
1101 // produced by lazy parsing or 2) are asked to generate cached data. | 1113 // produced by lazy parsing or 2) are asked to generate cached data. |
1102 // Eager parsing cannot benefit from cached data, and producing cached | 1114 // Eager parsing cannot benefit from cached data, and producing cached |
1103 // data while parsing eagerly is not implemented. | 1115 // data while parsing eagerly is not implemented. |
1104 parse_info->set_cached_data(nullptr); | 1116 parse_info->set_cached_data(nullptr); |
1105 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); | 1117 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); |
1106 } | 1118 } |
| 1119 |
1107 if (!Parser::ParseStatic(parse_info)) { | 1120 if (!Parser::ParseStatic(parse_info)) { |
1108 return Handle<SharedFunctionInfo>::null(); | 1121 return Handle<SharedFunctionInfo>::null(); |
1109 } | 1122 } |
1110 } | 1123 } |
1111 | 1124 |
1112 DCHECK(!info->is_debug() || !parse_info->allow_lazy_parsing()); | 1125 DCHECK(!info->is_debug() || !parse_info->allow_lazy_parsing()); |
1113 | 1126 |
1114 FunctionLiteral* lit = parse_info->literal(); | 1127 FunctionLiteral* lit = parse_info->literal(); |
1115 | 1128 |
1116 // Measure how long it takes to do the compilation; only take the | 1129 // Measure how long it takes to do the compilation; only take the |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 DCHECK(shared->is_compiled()); | 1939 DCHECK(shared->is_compiled()); |
1927 function->set_literals(cached.literals); | 1940 function->set_literals(cached.literals); |
1928 } else if (shared->is_compiled()) { | 1941 } else if (shared->is_compiled()) { |
1929 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1942 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1930 JSFunction::EnsureLiterals(function); | 1943 JSFunction::EnsureLiterals(function); |
1931 } | 1944 } |
1932 } | 1945 } |
1933 | 1946 |
1934 } // namespace internal | 1947 } // namespace internal |
1935 } // namespace v8 | 1948 } // namespace v8 |
OLD | NEW |