HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Nougat 7.0
|
7.0.0_r31
下载
查看原文件
收藏
根目录
external
v8
src
compilation-cache.cc
// Copyright 2011 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/compilation-cache.h" #include "src/assembler.h" #include "src/counters.h" #include "src/factory.h" #include "src/objects-inl.h" namespace v8 { namespace internal { // The number of generations for each sub cache. static const int kRegExpGenerations = 2; // Initial size of each compilation cache table allocated. static const int kInitialCacheSize = 64; CompilationCache::CompilationCache(Isolate* isolate) : isolate_(isolate), script_(isolate, 1), eval_global_(isolate, 1), eval_contextual_(isolate, 1), reg_exp_(isolate, kRegExpGenerations), enabled_(true) { CompilationSubCache* subcaches[kSubCacheCount] = {&script_, &eval_global_, &eval_contextual_, ®_exp_}; for (int i = 0; i < kSubCacheCount; ++i) { subcaches_[i] = subcaches[i]; } } CompilationCache::~CompilationCache() {} Handle
CompilationSubCache::GetTable(int generation) { DCHECK(generation < generations_); Handle
result; if (tables_[generation]->IsUndefined()) { result = CompilationCacheTable::New(isolate(), kInitialCacheSize); tables_[generation] = *result; } else { CompilationCacheTable* table = CompilationCacheTable::cast(tables_[generation]); result = Handle
(table, isolate()); } return result; } void CompilationSubCache::Age() { // Don't directly age single-generation caches. if (generations_ == 1) { if (tables_[0] != isolate()->heap()->undefined_value()) { CompilationCacheTable::cast(tables_[0])->Age(); } return; } // Age the generations implicitly killing off the oldest. for (int i = generations_ - 1; i > 0; i--) { tables_[i] = tables_[i - 1]; } // Set the first generation as unborn. tables_[0] = isolate()->heap()->undefined_value(); } void CompilationSubCache::IterateFunctions(ObjectVisitor* v) { Object* undefined = isolate()->heap()->undefined_value(); for (int i = 0; i < generations_; i++) { if (tables_[i] != undefined) { reinterpret_cast
(tables_[i])->IterateElements(v); } } } void CompilationSubCache::Iterate(ObjectVisitor* v) { v->VisitPointers(&tables_[0], &tables_[generations_]); } void CompilationSubCache::Clear() { MemsetPointer(tables_, isolate()->heap()->undefined_value(), generations_); } void CompilationSubCache::Remove(Handle
function_info) { // Probe the script generation tables. Make sure not to leak handles // into the caller's handle scope. { HandleScope scope(isolate()); for (int generation = 0; generation < generations(); generation++) { Handle
table = GetTable(generation); table->Remove(*function_info); } } } CompilationCacheScript::CompilationCacheScript(Isolate* isolate, int generations) : CompilationSubCache(isolate, generations) {} // We only re-use a cached function for some script source code if the // script originates from the same place. This is to avoid issues // when reporting errors, etc. bool CompilationCacheScript::HasOrigin(Handle
function_info, Handle
name, int line_offset, int column_offset, ScriptOriginOptions resource_options) { Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册