V8 Project
v8::internal::CompilationCacheScript Class Reference

#include <compilation-cache.h>

+ Inheritance diagram for v8::internal::CompilationCacheScript:
+ Collaboration diagram for v8::internal::CompilationCacheScript:

Public Member Functions

 CompilationCacheScript (Isolate *isolate, int generations)
 
Handle< SharedFunctionInfoLookup (Handle< String > source, Handle< Object > name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle< Context > context)
 
void Put (Handle< String > source, Handle< Context > context, Handle< SharedFunctionInfo > function_info)
 
- Public Member Functions inherited from v8::internal::CompilationSubCache
 CompilationSubCache (Isolate *isolate, int generations)
 
 ~CompilationSubCache ()
 
Handle< CompilationCacheTableGetTable (int generation)
 
Handle< CompilationCacheTableGetFirstTable ()
 
void SetFirstTable (Handle< CompilationCacheTable > value)
 
void Age ()
 
void Iterate (ObjectVisitor *v)
 
void IterateFunctions (ObjectVisitor *v)
 
void Clear ()
 
void Remove (Handle< SharedFunctionInfo > function_info)
 
int generations ()
 

Private Member Functions

bool HasOrigin (Handle< SharedFunctionInfo > function_info, Handle< Object > name, int line_offset, int column_offset, bool is_shared_cross_origin)
 
 DISALLOW_IMPLICIT_CONSTRUCTORS (CompilationCacheScript)
 

Private Attributes

void * script_histogram_
 
bool script_histogram_initialized_
 

Additional Inherited Members

- Static Public Attributes inherited from v8::internal::CompilationSubCache
static const int kFirstGeneration = 0
 
- Protected Member Functions inherited from v8::internal::CompilationSubCache
Isolateisolate ()
 

Detailed Description

Definition at line 71 of file compilation-cache.h.

Constructor & Destructor Documentation

◆ CompilationCacheScript()

v8::internal::CompilationCacheScript::CompilationCacheScript ( Isolate isolate,
int  generations 
)

Definition at line 103 of file compilation-cache.cc.

CompilationSubCache(Isolate *isolate, int generations)
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 NULL

Member Function Documentation

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

v8::internal::CompilationCacheScript::DISALLOW_IMPLICIT_CONSTRUCTORS ( CompilationCacheScript  )
private

◆ HasOrigin()

bool v8::internal::CompilationCacheScript::HasOrigin ( Handle< SharedFunctionInfo function_info,
Handle< Object name,
int  line_offset,
int  column_offset,
bool  is_shared_cross_origin 
)
private

Definition at line 113 of file compilation-cache.cc.

118  {
119  Handle<Script> script =
120  Handle<Script>(Script::cast(function_info->script()), isolate());
121  // If the script name isn't set, the boilerplate script should have
122  // an undefined name to have the same origin.
123  if (name.is_null()) {
124  return script->name()->IsUndefined();
125  }
126  // Do the fast bailout checks first.
127  if (line_offset != script->line_offset()->value()) return false;
128  if (column_offset != script->column_offset()->value()) return false;
129  // Check that both names are strings. If not, no match.
130  if (!name->IsString() || !script->name()->IsString()) return false;
131  // Were both scripts tagged by the embedder as being shared cross-origin?
132  if (is_shared_cross_origin != script->is_shared_cross_origin()) return false;
133  // Compare the two name strings for equality.
135  Handle<String>(String::cast(script->name())));
136 }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
bool Equals(String *other)
Definition: objects-inl.h:3336
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

References v8::internal::String::Equals(), v8::internal::CompilationSubCache::isolate(), and name.

Referenced by Lookup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Lookup()

Handle< SharedFunctionInfo > v8::internal::CompilationCacheScript::Lookup ( Handle< String source,
Handle< Object name,
int  line_offset,
int  column_offset,
bool  is_shared_cross_origin,
Handle< Context context 
)

Definition at line 143 of file compilation-cache.cc.

149  {
150  Object* result = NULL;
151  int generation;
152 
153  // Probe the script generation tables. Make sure not to leak handles
154  // into the caller's handle scope.
155  { HandleScope scope(isolate());
156  for (generation = 0; generation < generations(); generation++) {
157  Handle<CompilationCacheTable> table = GetTable(generation);
158  Handle<Object> probe = table->Lookup(source, context);
159  if (probe->IsSharedFunctionInfo()) {
160  Handle<SharedFunctionInfo> function_info =
162  // Break when we've found a suitable shared function info that
163  // matches the origin.
164  if (HasOrigin(function_info,
165  name,
166  line_offset,
167  column_offset,
168  is_shared_cross_origin)) {
169  result = *function_info;
170  break;
171  }
172  }
173  }
174  }
175 
178  "V8.ScriptCache",
179  0,
181  kScriptGenerations + 1);
183  }
184 
185  if (script_histogram_ != NULL) {
186  // The level NUMBER_OF_SCRIPT_GENERATIONS is equivalent to a cache miss.
188  }
189 
190  // Once outside the manacles of the handle scope, we need to recheck
191  // to see if we actually found a cached script. If so, we return a
192  // handle created in the caller's handle scope.
193  if (result != NULL) {
194  Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result),
195  isolate());
196  DCHECK(HasOrigin(shared,
197  name,
198  line_offset,
199  column_offset,
200  is_shared_cross_origin));
201  // If the script was found in a later generation, we promote it to
202  // the first generation to let it survive longer in the cache.
203  if (generation != 0) Put(source, context, shared);
204  isolate()->counters()->compilation_cache_hits()->Increment();
205  return shared;
206  } else {
207  isolate()->counters()->compilation_cache_misses()->Increment();
209  }
210 }
void Put(Handle< String > source, Handle< Context > context, Handle< SharedFunctionInfo > function_info)
bool HasOrigin(Handle< SharedFunctionInfo > function_info, Handle< Object > name, int line_offset, int column_offset, bool is_shared_cross_origin)
Handle< CompilationCacheTable > GetTable(int generation)
static Handle< T > null()
Definition: handles.h:123
Counters * counters()
Definition: isolate.h:857
StatsTable * stats_table()
Definition: isolate.cc:2039
void * CreateHistogram(const char *name, int min, int max, size_t buckets)
Definition: counters.h:61
void AddHistogramSample(void *histogram, int sample)
Definition: counters.h:71
#define DCHECK(condition)
Definition: logging.h:205
kSerializedDataOffset Object
Definition: objects-inl.h:5322
static const int kScriptGenerations

References v8::internal::StatsTable::AddHistogramSample(), v8::internal::Handle< T >::cast(), v8::internal::Isolate::counters(), v8::internal::StatsTable::CreateHistogram(), DCHECK, v8::internal::CompilationSubCache::generations(), v8::internal::CompilationSubCache::GetTable(), HasOrigin(), v8::internal::CompilationSubCache::isolate(), v8::internal::kScriptGenerations, name, NULL, v8::internal::Handle< T >::null(), Put(), script_histogram_, script_histogram_initialized_, and v8::internal::Isolate::stats_table().

Referenced by v8::internal::CompilationCache::LookupScript().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Put()

void v8::internal::CompilationCacheScript::Put ( Handle< String source,
Handle< Context context,
Handle< SharedFunctionInfo function_info 
)

Definition at line 213 of file compilation-cache.cc.

215  {
216  HandleScope scope(isolate());
217  Handle<CompilationCacheTable> table = GetFirstTable();
219  CompilationCacheTable::Put(table, source, context, function_info));
220 }
static Handle< CompilationCacheTable > Put(Handle< CompilationCacheTable > cache, Handle< String > src, Handle< Context > context, Handle< Object > value)
Definition: objects.cc:14777
Handle< CompilationCacheTable > GetFirstTable()
void SetFirstTable(Handle< CompilationCacheTable > value)

References v8::internal::CompilationSubCache::GetFirstTable(), v8::internal::CompilationSubCache::isolate(), v8::internal::CompilationCacheTable::Put(), and v8::internal::CompilationSubCache::SetFirstTable().

Referenced by Lookup(), and v8::internal::CompilationCache::PutScript().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ script_histogram_

void* v8::internal::CompilationCacheScript::script_histogram_
private

Definition at line 92 of file compilation-cache.h.

Referenced by Lookup().

◆ script_histogram_initialized_

bool v8::internal::CompilationCacheScript::script_histogram_initialized_
private

Definition at line 93 of file compilation-cache.h.

Referenced by Lookup().


The documentation for this class was generated from the following files: