| 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 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 PostponeInterruptsScope postpone(isolate); | 1142 PostponeInterruptsScope postpone(isolate); |
| 1143 DCHECK(!isolate->native_context().is_null()); | 1143 DCHECK(!isolate->native_context().is_null()); |
| 1144 ParseInfo* parse_info = info->parse_info(); | 1144 ParseInfo* parse_info = info->parse_info(); |
| 1145 | 1145 |
| 1146 RuntimeCallTimerScope runtimeTimer( | 1146 RuntimeCallTimerScope runtimeTimer( |
| 1147 isolate, parse_info->is_eval() ? &RuntimeCallStats::CompileEval | 1147 isolate, parse_info->is_eval() ? &RuntimeCallStats::CompileEval |
| 1148 : &RuntimeCallStats::CompileScript); | 1148 : &RuntimeCallStats::CompileScript); |
| 1149 | 1149 |
| 1150 Handle<Script> script = parse_info->script(); | 1150 Handle<Script> script = parse_info->script(); |
| 1151 | 1151 |
| 1152 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? | |
| 1153 FixedArray* array = isolate->native_context()->embedder_data(); | |
| 1154 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); | |
| 1155 | |
| 1156 Handle<SharedFunctionInfo> result; | 1152 Handle<SharedFunctionInfo> result; |
| 1157 | 1153 |
| 1158 { VMState<COMPILER> state(info->isolate()); | 1154 { VMState<COMPILER> state(info->isolate()); |
| 1159 if (parse_info->literal() == nullptr) { | 1155 if (parse_info->literal() == nullptr) { |
| 1160 if (!parsing::ParseProgram(parse_info, false)) { | 1156 if (!parsing::ParseProgram(parse_info, false)) { |
| 1161 return Handle<SharedFunctionInfo>::null(); | 1157 return Handle<SharedFunctionInfo>::null(); |
| 1162 } | 1158 } |
| 1163 | 1159 |
| 1164 { | 1160 { |
| 1165 ParseHandleScope parse_handles(parse_info); | 1161 ParseHandleScope parse_handles(parse_info); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 if (FLAG_harmony_function_tostring && | 1498 if (FLAG_harmony_function_tostring && |
| 1503 restriction == ONLY_SINGLE_FUNCTION_LITERAL && | 1499 restriction == ONLY_SINGLE_FUNCTION_LITERAL && |
| 1504 parameters_end_pos != kNoSourcePosition) { | 1500 parameters_end_pos != kNoSourcePosition) { |
| 1505 // use the parameters_end_pos as the eval_scope_position in the eval cache. | 1501 // use the parameters_end_pos as the eval_scope_position in the eval cache. |
| 1506 DCHECK_EQ(eval_scope_position, 0); | 1502 DCHECK_EQ(eval_scope_position, 0); |
| 1507 position = -parameters_end_pos; | 1503 position = -parameters_end_pos; |
| 1508 } | 1504 } |
| 1509 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1505 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 1510 InfoVectorPair eval_result = compilation_cache->LookupEval( | 1506 InfoVectorPair eval_result = compilation_cache->LookupEval( |
| 1511 source, outer_info, context, language_mode, position); | 1507 source, outer_info, context, language_mode, position); |
| 1512 Handle<SharedFunctionInfo> shared_info; | |
| 1513 if (eval_result.has_shared()) { | |
| 1514 shared_info = Handle<SharedFunctionInfo>(eval_result.shared(), isolate); | |
| 1515 } | |
| 1516 Handle<Cell> vector; | 1508 Handle<Cell> vector; |
| 1517 if (eval_result.has_vector()) { | 1509 if (eval_result.has_vector()) { |
| 1518 vector = Handle<Cell>(eval_result.vector(), isolate); | 1510 vector = Handle<Cell>(eval_result.vector(), isolate); |
| 1519 } | 1511 } |
| 1520 | 1512 |
| 1513 Handle<SharedFunctionInfo> shared_info; |
| 1521 Handle<Script> script; | 1514 Handle<Script> script; |
| 1522 if (!eval_result.has_shared()) { | 1515 if (eval_result.has_shared()) { |
| 1516 shared_info = Handle<SharedFunctionInfo>(eval_result.shared(), isolate); |
| 1517 script = Handle<Script>(Script::cast(shared_info->script()), isolate); |
| 1518 } else { |
| 1523 script = isolate->factory()->NewScript(source); | 1519 script = isolate->factory()->NewScript(source); |
| 1524 if (isolate->NeedsSourcePositionsForProfiling()) { | 1520 if (isolate->NeedsSourcePositionsForProfiling()) { |
| 1525 Script::InitLineEnds(script); | 1521 Script::InitLineEnds(script); |
| 1526 } | 1522 } |
| 1527 if (!script_name.is_null()) { | 1523 if (!script_name.is_null()) { |
| 1528 script->set_name(*script_name); | 1524 script->set_name(*script_name); |
| 1529 script->set_line_offset(line_offset); | 1525 script->set_line_offset(line_offset); |
| 1530 script->set_column_offset(column_offset); | 1526 script->set_column_offset(column_offset); |
| 1531 } | 1527 } |
| 1532 script->set_origin_options(options); | 1528 script->set_origin_options(options); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 // Then check cached code provided by embedder. | 1679 // Then check cached code provided by embedder. |
| 1684 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); | 1680 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); |
| 1685 RuntimeCallTimerScope runtimeTimer(isolate, | 1681 RuntimeCallTimerScope runtimeTimer(isolate, |
| 1686 &RuntimeCallStats::CompileDeserialize); | 1682 &RuntimeCallStats::CompileDeserialize); |
| 1687 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), | 1683 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), |
| 1688 "V8.CompileDeserialize"); | 1684 "V8.CompileDeserialize"); |
| 1689 Handle<SharedFunctionInfo> inner_result; | 1685 Handle<SharedFunctionInfo> inner_result; |
| 1690 if (CodeSerializer::Deserialize(isolate, *cached_data, source) | 1686 if (CodeSerializer::Deserialize(isolate, *cached_data, source) |
| 1691 .ToHandle(&inner_result)) { | 1687 .ToHandle(&inner_result)) { |
| 1692 // Promote to per-isolate compilation cache. | 1688 // Promote to per-isolate compilation cache. |
| 1693 // TODO(mvstanton): create a feedback vector array here. | |
| 1694 DCHECK(inner_result->is_compiled()); | 1689 DCHECK(inner_result->is_compiled()); |
| 1695 Handle<FeedbackVector> feedback_vector = | 1690 Handle<FeedbackVector> feedback_vector = |
| 1696 FeedbackVector::New(isolate, inner_result); | 1691 FeedbackVector::New(isolate, inner_result); |
| 1697 vector = isolate->factory()->NewCell(feedback_vector); | 1692 vector = isolate->factory()->NewCell(feedback_vector); |
| 1698 compilation_cache->PutScript(source, context, language_mode, | 1693 compilation_cache->PutScript(source, context, language_mode, |
| 1699 inner_result, vector); | 1694 inner_result, vector); |
| 1695 Handle<Script> script(Script::cast(inner_result->script()), isolate); |
| 1696 isolate->debug()->OnAfterCompile(script); |
| 1700 return inner_result; | 1697 return inner_result; |
| 1701 } | 1698 } |
| 1702 // Deserializer failed. Fall through to compile. | 1699 // Deserializer failed. Fall through to compile. |
| 1703 } else { | 1700 } else { |
| 1704 if (pair.has_shared()) { | 1701 if (pair.has_shared()) { |
| 1705 result = Handle<SharedFunctionInfo>(pair.shared(), isolate); | 1702 result = Handle<SharedFunctionInfo>(pair.shared(), isolate); |
| 1706 } | 1703 } |
| 1707 if (pair.has_vector()) { | 1704 if (pair.has_vector()) { |
| 1708 vector = Handle<Cell>(pair.vector(), isolate); | 1705 vector = Handle<Cell>(pair.vector(), isolate); |
| 1709 } | 1706 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1938 } | 1935 } |
| 1939 | 1936 |
| 1940 if (shared->is_compiled()) { | 1937 if (shared->is_compiled()) { |
| 1941 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1938 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| 1942 JSFunction::EnsureLiterals(function); | 1939 JSFunction::EnsureLiterals(function); |
| 1943 } | 1940 } |
| 1944 } | 1941 } |
| 1945 | 1942 |
| 1946 } // namespace internal | 1943 } // namespace internal |
| 1947 } // namespace v8 | 1944 } // namespace v8 |
| OLD | NEW |