Line data Source code
1 : // Copyright 2018 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/unoptimized-compilation-info.h"
6 :
7 : #include "src/ast/ast.h"
8 : #include "src/ast/scopes.h"
9 : #include "src/debug/debug.h"
10 : #include "src/isolate.h"
11 : #include "src/objects-inl.h"
12 : #include "src/parsing/parse-info.h"
13 : #include "src/source-position.h"
14 :
15 : namespace v8 {
16 : namespace internal {
17 :
18 2120718 : UnoptimizedCompilationInfo::UnoptimizedCompilationInfo(Zone* zone,
19 : ParseInfo* parse_info,
20 : FunctionLiteral* literal)
21 2120718 : : flags_(0), zone_(zone), feedback_vector_spec_(zone) {
22 : // NOTE: The parse_info passed here represents the global information gathered
23 : // during parsing, but does not represent specific details of the actual
24 : // function literal being compiled for this OptimizedCompilationInfo. As such,
25 : // parse_info->literal() might be different from literal, and only global
26 : // details of the script being parsed are relevant to this
27 : // OptimizedCompilationInfo.
28 : DCHECK_NOT_NULL(literal);
29 2120752 : literal_ = literal;
30 2120752 : source_range_map_ = parse_info->source_range_map();
31 :
32 2120752 : if (parse_info->is_eval()) MarkAsEval();
33 2120752 : if (parse_info->collect_type_profile()) MarkAsCollectTypeProfile();
34 2120752 : if (parse_info->might_always_opt()) MarkAsMightAlwaysOpt();
35 2120752 : if (parse_info->collect_source_positions()) {
36 : MarkAsForceCollectSourcePositions();
37 : }
38 2120752 : }
39 :
40 8446056 : DeclarationScope* UnoptimizedCompilationInfo::scope() const {
41 : DCHECK_NOT_NULL(literal_);
42 10563033 : return literal_->scope();
43 : }
44 :
45 0 : int UnoptimizedCompilationInfo::num_parameters() const {
46 0 : return scope()->num_parameters();
47 : }
48 :
49 2116977 : int UnoptimizedCompilationInfo::num_parameters_including_this() const {
50 2116977 : return scope()->num_parameters() + 1;
51 : }
52 :
53 : SourcePositionTableBuilder::RecordingMode
54 2116962 : UnoptimizedCompilationInfo::SourcePositionRecordingMode() const {
55 2116962 : if (collect_source_positions()) {
56 : return SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
57 : }
58 :
59 : // Always collect source positions for functions that cannot be lazily
60 : // compiled, e.g. class member initializer functions.
61 45 : return !literal_->AllowsLazyCompilation()
62 : ? SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS
63 45 : : SourcePositionTableBuilder::LAZY_SOURCE_POSITIONS;
64 : }
65 :
66 : } // namespace internal
67 122004 : } // namespace v8
|