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 2114313 : UnoptimizedCompilationInfo::UnoptimizedCompilationInfo(Zone* zone,
19 2114364 : ParseInfo* parse_info,
20 : FunctionLiteral* literal)
21 2114313 : : 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 2114364 : literal_ = literal;
30 2114364 : source_range_map_ = parse_info->source_range_map();
31 :
32 2114364 : if (parse_info->is_eval()) MarkAsEval();
33 2114364 : if (parse_info->is_native()) MarkAsNative();
34 2114364 : if (parse_info->collect_type_profile()) MarkAsCollectTypeProfile();
35 2114364 : if (parse_info->might_always_opt()) MarkAsMightAlwaysOpt();
36 2114364 : }
37 :
38 8418701 : DeclarationScope* UnoptimizedCompilationInfo::scope() const {
39 : DCHECK_NOT_NULL(literal_);
40 10528510 : return literal_->scope();
41 : }
42 :
43 0 : int UnoptimizedCompilationInfo::num_parameters() const {
44 0 : return scope()->num_parameters();
45 : }
46 :
47 2109809 : int UnoptimizedCompilationInfo::num_parameters_including_this() const {
48 2109809 : return scope()->num_parameters() + 1;
49 : }
50 :
51 : SourcePositionTableBuilder::RecordingMode
52 2109787 : UnoptimizedCompilationInfo::SourcePositionRecordingMode() const {
53 : return is_native() ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS
54 2109787 : : SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
55 : }
56 :
57 : } // namespace internal
58 183867 : } // namespace v8
|