Home | History | Annotate | Download | only in src
      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 UnoptimizedCompilationInfo::UnoptimizedCompilationInfo(Zone* zone,
     19                                                        ParseInfo* parse_info,
     20                                                        FunctionLiteral* literal)
     21     : flags_(FLAG_untrusted_code_mitigations ? kUntrustedCodeMitigations : 0),
     22       zone_(zone),
     23       feedback_vector_spec_(zone) {
     24   // NOTE: The parse_info passed here represents the global information gathered
     25   // during parsing, but does not represent specific details of the actual
     26   // function literal being compiled for this OptimizedCompilationInfo. As such,
     27   // parse_info->literal() might be different from literal, and only global
     28   // details of the script being parsed are relevant to this
     29   // OptimizedCompilationInfo.
     30   DCHECK_NOT_NULL(literal);
     31   literal_ = literal;
     32   source_range_map_ = parse_info->source_range_map();
     33 
     34   if (parse_info->is_eval()) MarkAsEval();
     35   if (parse_info->is_native()) MarkAsNative();
     36   if (parse_info->collect_type_profile()) MarkAsCollectTypeProfile();
     37 }
     38 
     39 DeclarationScope* UnoptimizedCompilationInfo::scope() const {
     40   DCHECK_NOT_NULL(literal_);
     41   return literal_->scope();
     42 }
     43 
     44 int UnoptimizedCompilationInfo::num_parameters() const {
     45   return scope()->num_parameters();
     46 }
     47 
     48 int UnoptimizedCompilationInfo::num_parameters_including_this() const {
     49   return scope()->num_parameters() + 1;
     50 }
     51 
     52 SourcePositionTableBuilder::RecordingMode
     53 UnoptimizedCompilationInfo::SourcePositionRecordingMode() const {
     54   return is_native() ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS
     55                      : SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
     56 }
     57 
     58 }  // namespace internal
     59 }  // namespace v8
     60