Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(954)

Unified Diff: src/ic/handler-compiler.cc

Issue 2182103002: [KeyedLoadIC] Support Smi "handlers" for simple field loads (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic/handler-compiler.h ('k') | src/ic/ic.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic/handler-compiler.cc
diff --git a/src/ic/handler-compiler.cc b/src/ic/handler-compiler.cc
index 6993c753662d04fc6fe2a95eaba1ed4717952327..a1d1467ab1f3600d1994d7d62c4380db4408ccf2 100644
--- a/src/ic/handler-compiler.cc
+++ b/src/ic/handler-compiler.cc
@@ -576,44 +576,50 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
#undef __
+// static
+Handle<Code> ElementHandlerCompiler::GetKeyedLoadHandler(
+ Handle<Map> receiver_map, Isolate* isolate) {
+ if (receiver_map->has_indexed_interceptor() &&
+ !receiver_map->GetIndexedInterceptor()->getter()->IsUndefined(isolate) &&
+ !receiver_map->GetIndexedInterceptor()->non_masking()) {
+ TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadIndexedInterceptorStub);
+ return LoadIndexedInterceptorStub(isolate).GetCode();
+ }
+ if (receiver_map->IsStringMap()) {
+ TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadIndexedStringStub);
+ return LoadIndexedStringStub(isolate).GetCode();
+ }
+ InstanceType instance_type = receiver_map->instance_type();
+ if (instance_type < FIRST_JS_RECEIVER_TYPE) {
+ TRACE_HANDLER_STATS(isolate, KeyedLoadIC_SlowStub);
+ return isolate->builtins()->KeyedLoadIC_Slow();
+ }
+
+ ElementsKind elements_kind = receiver_map->elements_kind();
+ if (IsSloppyArgumentsElements(elements_kind)) {
+ TRACE_HANDLER_STATS(isolate, KeyedLoadIC_KeyedLoadSloppyArgumentsStub);
+ return KeyedLoadSloppyArgumentsStub(isolate).GetCode();
+ }
+ if (elements_kind == DICTIONARY_ELEMENTS) {
+ TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadDictionaryElementStub);
+ return LoadDictionaryElementStub(isolate).GetCode();
+ }
+ DCHECK(IsFastElementsKind(elements_kind) ||
+ IsFixedTypedArrayElementsKind(elements_kind));
+ bool is_js_array = instance_type == JS_ARRAY_TYPE;
+ bool convert_hole_to_undefined =
+ is_js_array && elements_kind == FAST_HOLEY_ELEMENTS &&
+ *receiver_map == isolate->get_initial_js_array_map(elements_kind);
+ TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadFastElementStub);
+ return LoadFastElementStub(isolate, is_js_array, elements_kind,
+ convert_hole_to_undefined)
+ .GetCode();
+}
+
void ElementHandlerCompiler::CompileElementHandlers(
MapHandleList* receiver_maps, List<Handle<Object>>* handlers) {
for (int i = 0; i < receiver_maps->length(); ++i) {
- Handle<Map> receiver_map = receiver_maps->at(i);
- Handle<Code> cached_stub;
-
- if (receiver_map->IsStringMap()) {
- cached_stub = LoadIndexedStringStub(isolate()).GetCode();
- } else if (receiver_map->instance_type() < FIRST_JS_RECEIVER_TYPE) {
- cached_stub = isolate()->builtins()->KeyedLoadIC_Slow();
- } else {
- bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
- ElementsKind elements_kind = receiver_map->elements_kind();
-
- // No need to check for an elements-free prototype chain here, the
- // generated stub code needs to check that dynamically anyway.
- bool convert_hole_to_undefined =
- (is_js_array && elements_kind == FAST_HOLEY_ELEMENTS &&
- *receiver_map == isolate()->get_initial_js_array_map(elements_kind));
-
- if (receiver_map->has_indexed_interceptor() &&
- !receiver_map->GetIndexedInterceptor()->getter()->IsUndefined(
- isolate()) &&
- !receiver_map->GetIndexedInterceptor()->non_masking()) {
- cached_stub = LoadIndexedInterceptorStub(isolate()).GetCode();
- } else if (IsSloppyArgumentsElements(elements_kind)) {
- cached_stub = KeyedLoadSloppyArgumentsStub(isolate()).GetCode();
- } else if (IsFastElementsKind(elements_kind) ||
- IsFixedTypedArrayElementsKind(elements_kind)) {
- cached_stub = LoadFastElementStub(isolate(), is_js_array, elements_kind,
- convert_hole_to_undefined).GetCode();
- } else {
- DCHECK(elements_kind == DICTIONARY_ELEMENTS);
- cached_stub = LoadDictionaryElementStub(isolate()).GetCode();
- }
- }
-
- handlers->Add(cached_stub);
+ handlers->Add(GetKeyedLoadHandler(receiver_maps->at(i), isolate()));
}
}
} // namespace internal
« no previous file with comments | « src/ic/handler-compiler.h ('k') | src/ic/ic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698