⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stub-cache.cc.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
  Object* code = receiver->map()->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    KeyedLoadStubCompiler compiler;    code = compiler.CompileLoadFunctionPrototype(name);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("KeyedLoadIC", Code::cast(code), name));    Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return code;}Object* StubCache::ComputeStoreField(String* name,                                     JSObject* receiver,                                     int field_index,                                     Map* transition) {  PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION;  Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type);  Object* code = receiver->map()->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    StoreStubCompiler compiler;    code = compiler.CompileStoreField(receiver, field_index, transition, name);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("StoreIC", Code::cast(code), name));    Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return Set(name, receiver->map(), Code::cast(code));}Object* StubCache::ComputeStoreCallback(String* name,                                        JSObject* receiver,                                        AccessorInfo* callback) {  ASSERT(v8::ToCData<Address>(callback->setter()) != 0);  Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS);  Object* code = receiver->map()->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    StoreStubCompiler compiler;    code = compiler.CompileStoreCallback(receiver, callback, name);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("StoreIC", Code::cast(code), name));    Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return Set(name, receiver->map(), Code::cast(code));}Object* StubCache::ComputeStoreInterceptor(String* name,                                           JSObject* receiver) {  Code::Flags flags =      Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR);  Object* code = receiver->map()->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    StoreStubCompiler compiler;    code = compiler.CompileStoreInterceptor(receiver, name);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("StoreIC", Code::cast(code), name));    Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return Set(name, receiver->map(), Code::cast(code));}Object* StubCache::ComputeKeyedStoreField(String* name, JSObject* receiver,                                          int field_index, Map* transition) {  PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION;  Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type);  Object* code = receiver->map()->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    KeyedStoreStubCompiler compiler;    code = compiler.CompileStoreField(receiver, field_index, transition, name);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("KeyedStoreIC", Code::cast(code), name));    Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return code;}Object* StubCache::ComputeCallConstant(int argc,                                       String* name,                                       Object* object,                                       JSObject* holder,                                       JSFunction* function) {  // Compute the check type and the map.  Map* map = IC::GetCodeCacheMapForObject(object);  // Compute check type based on receiver/holder.  StubCompiler::CheckType check = StubCompiler::RECEIVER_MAP_CHECK;  if (object->IsString()) {    check = StubCompiler::STRING_CHECK;  } else if (object->IsNumber()) {    check = StubCompiler::NUMBER_CHECK;  } else if (object->IsBoolean()) {    check = StubCompiler::BOOLEAN_CHECK;  }  Code::Flags flags =      Code::ComputeMonomorphicFlags(Code::CALL_IC, CONSTANT_FUNCTION, argc);  Object* code = map->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    if (object->IsJSObject()) {      Object* opt =          Top::LookupSpecialFunction(JSObject::cast(object), holder, function);      if (opt->IsJSFunction()) {        check = StubCompiler::JSARRAY_HAS_FAST_ELEMENTS_CHECK;        function = JSFunction::cast(opt);      }    }    // If the function hasn't been compiled yet, we cannot do it now    // because it may cause GC. To avoid this issue, we return an    // internal error which will make sure we do not update any    // caches.    if (!function->is_compiled()) return Failure::InternalError();    // Compile the stub - only create stubs for fully compiled functions.    CallStubCompiler compiler(argc);    code = compiler.CompileCallConstant(object, holder, function, check);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("CallIC", Code::cast(code), name));    Object* result = map->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return Set(name, map, Code::cast(code));}Object* StubCache::ComputeCallField(int argc,                                    String* name,                                    Object* object,                                    JSObject* holder,                                    int index) {  // Compute the check type and the map.  Map* map = IC::GetCodeCacheMapForObject(object);  // TODO(1233596): We cannot do receiver map check for non-JS objects  // because they may be represented as immediates without a  // map. Instead, we check against the map in the holder.  if (object->IsNumber() || object->IsBoolean() || object->IsString()) {    object = holder;  }  Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, FIELD, argc);  Object* code = map->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    CallStubCompiler compiler(argc);    code = compiler.CompileCallField(object, holder, index);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("CallIC", Code::cast(code), name));    Object* result = map->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return Set(name, map, Code::cast(code));}Object* StubCache::ComputeCallInterceptor(int argc,                                          String* name,                                          Object* object,                                          JSObject* holder) {  // Compute the check type and the map.  // If the object is a value, we use the prototype map for the cache.  Map* map = IC::GetCodeCacheMapForObject(object);  // TODO(1233596): We cannot do receiver map check for non-JS objects  // because they may be represented as immediates without a  // map. Instead, we check against the map in the holder.  if (object->IsNumber() || object->IsBoolean() || object->IsString()) {    object = holder;  }  Code::Flags flags =      Code::ComputeMonomorphicFlags(Code::CALL_IC, INTERCEPTOR, argc);  Object* code = map->FindInCodeCache(name, flags);  if (code->IsUndefined()) {    CallStubCompiler compiler(argc);    code = compiler.CompileCallInterceptor(object, holder, name);    if (code->IsFailure()) return code;    LOG(CodeCreateEvent("CallIC", Code::cast(code), name));    Object* result = map->UpdateCodeCache(name, Code::cast(code));    if (result->IsFailure()) return result;  }  return Set(name, map, Code::cast(code));}Object* StubCache::ComputeCallNormal(int argc,                                     String* name,                                     JSObject* receiver) {  Object* code = ComputeCallNormal(argc);  if (code->IsFailure()) return code;  return Set(name, receiver->map(), Code::cast(code));}static Object* GetProbeValue(Code::Flags flags) {  Dictionary* dictionary = Heap::non_monomorphic_cache();  int entry = dictionary->FindNumberEntry(flags);  if (entry != -1) return dictionary->ValueAt(entry);  return Heap::undefined_value();}static Object* ProbeCache(Code::Flags flags) {  Object* probe = GetProbeValue(flags);  if (probe != Heap::undefined_value()) return probe;  // Seed the cache with an undefined value to make sure that any  // generated code object can always be inserted into the cache  // without causing  allocation failures.  Object* result =      Heap::non_monomorphic_cache()->AtNumberPut(flags,                                                 Heap::undefined_value());  if (result->IsFailure()) return result;  Heap::set_non_monomorphic_cache(Dictionary::cast(result));  return probe;}static Object* FillCache(Object* code) {  if (code->IsCode()) {    int entry =        Heap::non_monomorphic_cache()->FindNumberEntry(            Code::cast(code)->flags());    // The entry must be present see comment in ProbeCache.    ASSERT(entry != -1);    ASSERT(Heap::non_monomorphic_cache()->ValueAt(entry) ==           Heap::undefined_value());    Heap::non_monomorphic_cache()->ValueAtPut(entry, code);    CHECK(GetProbeValue(Code::cast(code)->flags()) == code);  }  return code;}Code* StubCache::FindCallInitialize(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::CALL_IC, UNINITIALIZED, NORMAL, argc);  Object* result = ProbeCache(flags);  ASSERT(!result->IsUndefined());  // This might be called during the marking phase of the collector  // hence the unchecked cast.  return reinterpret_cast<Code*>(result);}Object* StubCache::ComputeCallInitialize(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::CALL_IC, UNINITIALIZED, NORMAL, argc);  Object* probe = ProbeCache(flags);  if (!probe->IsUndefined()) return probe;  StubCompiler compiler;  return FillCache(compiler.CompileCallInitialize(flags));}Object* StubCache::ComputeCallPreMonomorphic(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::CALL_IC, PREMONOMORPHIC, NORMAL, argc);  Object* probe = ProbeCache(flags);  if (!probe->IsUndefined()) return probe;  StubCompiler compiler;  return FillCache(compiler.CompileCallPreMonomorphic(flags));}Object* StubCache::ComputeCallNormal(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::CALL_IC, MONOMORPHIC, NORMAL, argc);  Object* probe = ProbeCache(flags);  if (!probe->IsUndefined()) return probe;  StubCompiler compiler;  return FillCache(compiler.CompileCallNormal(flags));}Object* StubCache::ComputeCallMegamorphic(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::CALL_IC, MEGAMORPHIC, NORMAL, argc);  Object* probe = ProbeCache(flags);  if (!probe->IsUndefined()) return probe;  StubCompiler compiler;  return FillCache(compiler.CompileCallMegamorphic(flags));}Object* StubCache::ComputeCallMiss(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::STUB, MEGAMORPHIC, NORMAL, argc);  Object* probe = ProbeCache(flags);  if (!probe->IsUndefined()) return probe;  StubCompiler compiler;  return FillCache(compiler.CompileCallMiss(flags));}Object* StubCache::ComputeCallDebugBreak(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::CALL_IC, DEBUG_BREAK, NORMAL, argc);  Object* probe = ProbeCache(flags);  if (!probe->IsUndefined()) return probe;  StubCompiler compiler;  return FillCache(compiler.CompileCallDebugBreak(flags));}Object* StubCache::ComputeCallDebugPrepareStepIn(int argc) {  Code::Flags flags =      Code::ComputeFlags(Code::CALL_IC, DEBUG_PREPARE_STEP_IN, NORMAL, argc);  Object* probe = ProbeCache(flags);  if (!probe->IsUndefined()) return probe;  StubCompiler compiler;  return FillCache(compiler.CompileCallDebugPrepareStepIn(flags));}Object* StubCache::ComputeLazyCompile(int argc) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -