V8 Project
func-name-inferrer.cc
Go to the documentation of this file.
1 // Copyright 2011 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/v8.h"
6 
7 #include "src/ast.h"
10 #include "src/list-inl.h"
11 
12 namespace v8 {
13 namespace internal {
14 
16  Zone* zone)
17  : ast_value_factory_(ast_value_factory),
18  entries_stack_(10, zone),
19  names_stack_(5, zone),
20  funcs_to_infer_(4, zone),
21  zone_(zone) {
22 }
23 
24 
26  // Enclosing name is a name of a constructor function. To check
27  // that it is really a constructor, we check that it is not empty
28  // and starts with a capital letter.
29  if (!name->IsEmpty() && unibrow::Uppercase::Is(name->FirstCharacter())) {
31  }
32 }
33 
34 
36  if (IsOpen() && name != ast_value_factory_->prototype_string()) {
38  }
39 }
40 
41 
43  if (IsOpen() && name != ast_value_factory_->dot_result_string()) {
45  }
46 }
47 
48 
50  return MakeNameFromStackHelper(0, ast_value_factory_->empty_string());
51 }
52 
54  int pos, const AstString* prev) {
55  if (pos >= names_stack_.length()) return prev;
56  if (pos < names_stack_.length() - 1 &&
57  names_stack_.at(pos).type == kVariableName &&
58  names_stack_.at(pos + 1).type == kVariableName) {
59  // Skip consecutive variable declarations.
60  return MakeNameFromStackHelper(pos + 1, prev);
61  } else {
62  if (prev->length() > 0) {
63  const AstRawString* name = names_stack_.at(pos).name;
64  if (prev->length() + name->length() + 1 > String::kMaxLength) return prev;
66  ast_value_factory_->dot_string(), name);
67  curr = ast_value_factory_->NewConsString(prev, curr);
68  return MakeNameFromStackHelper(pos + 1, curr);
69  } else {
70  return MakeNameFromStackHelper(pos + 1, names_stack_.at(pos).name);
71  }
72  }
73 }
74 
75 
77  const AstString* func_name = MakeNameFromStack();
78  for (int i = 0; i < funcs_to_infer_.length(); ++i) {
79  funcs_to_infer_[i]->set_raw_inferred_name(func_name);
80  }
81  funcs_to_infer_.Rewind(0);
82 }
83 
84 
85 } } // namespace v8::internal
virtual int length() const =0
const AstConsString * NewConsString(const AstString *left, const AstString *right)
const AstString * MakeNameFromStackHelper(int pos, const AstString *prev)
void PushVariableName(const AstRawString *name)
void PushEnclosingName(const AstRawString *name)
ZoneList< FunctionLiteral * > funcs_to_infer_
void PushLiteralName(const AstRawString *name)
FuncNameInferrer(AstValueFactory *ast_value_factory, Zone *zone)
const AstString * MakeNameFromStack()
static const int kMaxLength
Definition: objects.h:8820
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
static bool Is(uchar c)
Definition: unicode.cc:421