Commit 5913deec authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[cleanup][ic] Introduce bottleneck for Code handlers

This CL also removes code handler related logic from CodeFactory
and removes unused CodeFactory::BinaryOperation().

Bug: v8:11879, v8:11880
Change-Id: I4ea3074b7143975bea3f9367bcab84cdfcd86827
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2960948
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75137}
parent 6ae810b8
......@@ -107,104 +107,6 @@ Callable CodeFactory::StoreOwnICInOptimizedCode(Isolate* isolate) {
return Builtins::CallableFor(isolate, Builtin::kStoreIC);
}
Callable CodeFactory::KeyedStoreIC_SloppyArguments(Isolate* isolate,
KeyedAccessStoreMode mode) {
Builtin builtin;
switch (mode) {
case STANDARD_STORE:
builtin = Builtin::kKeyedStoreIC_SloppyArguments_Standard;
break;
case STORE_AND_GROW_HANDLE_COW:
builtin =
Builtin::kKeyedStoreIC_SloppyArguments_GrowNoTransitionHandleCOW;
break;
case STORE_IGNORE_OUT_OF_BOUNDS:
builtin = Builtin::kKeyedStoreIC_SloppyArguments_NoTransitionIgnoreOOB;
break;
case STORE_HANDLE_COW:
builtin = Builtin::kKeyedStoreIC_SloppyArguments_NoTransitionHandleCOW;
break;
default:
UNREACHABLE();
}
return isolate->builtins()->CallableFor(isolate, builtin);
}
Callable CodeFactory::ElementsTransitionAndStore(Isolate* isolate,
KeyedAccessStoreMode mode) {
Builtin builtin;
switch (mode) {
case STANDARD_STORE:
builtin = Builtin::kElementsTransitionAndStore_Standard;
break;
case STORE_AND_GROW_HANDLE_COW:
builtin = Builtin::kElementsTransitionAndStore_GrowNoTransitionHandleCOW;
break;
case STORE_IGNORE_OUT_OF_BOUNDS:
builtin = Builtin::kElementsTransitionAndStore_NoTransitionIgnoreOOB;
break;
case STORE_HANDLE_COW:
builtin = Builtin::kElementsTransitionAndStore_NoTransitionHandleCOW;
break;
default:
UNREACHABLE();
}
return isolate->builtins()->CallableFor(isolate, builtin);
}
Callable CodeFactory::StoreFastElementIC(Isolate* isolate,
KeyedAccessStoreMode mode) {
Builtin builtin;
switch (mode) {
case STANDARD_STORE:
builtin = Builtin::kStoreFastElementIC_Standard;
break;
case STORE_AND_GROW_HANDLE_COW:
builtin = Builtin::kStoreFastElementIC_GrowNoTransitionHandleCOW;
break;
case STORE_IGNORE_OUT_OF_BOUNDS:
builtin = Builtin::kStoreFastElementIC_NoTransitionIgnoreOOB;
break;
case STORE_HANDLE_COW:
builtin = Builtin::kStoreFastElementIC_NoTransitionHandleCOW;
break;
default:
UNREACHABLE();
}
return isolate->builtins()->CallableFor(isolate, builtin);
}
// static
Callable CodeFactory::BinaryOperation(Isolate* isolate, Operation op) {
switch (op) {
case Operation::kShiftRight:
return Builtins::CallableFor(isolate, Builtin::kShiftRight);
case Operation::kShiftLeft:
return Builtins::CallableFor(isolate, Builtin::kShiftLeft);
case Operation::kShiftRightLogical:
return Builtins::CallableFor(isolate, Builtin::kShiftRightLogical);
case Operation::kAdd:
return Builtins::CallableFor(isolate, Builtin::kAdd);
case Operation::kSubtract:
return Builtins::CallableFor(isolate, Builtin::kSubtract);
case Operation::kMultiply:
return Builtins::CallableFor(isolate, Builtin::kMultiply);
case Operation::kDivide:
return Builtins::CallableFor(isolate, Builtin::kDivide);
case Operation::kModulus:
return Builtins::CallableFor(isolate, Builtin::kModulus);
case Operation::kBitwiseOr:
return Builtins::CallableFor(isolate, Builtin::kBitwiseOr);
case Operation::kBitwiseAnd:
return Builtins::CallableFor(isolate, Builtin::kBitwiseAnd);
case Operation::kBitwiseXor:
return Builtins::CallableFor(isolate, Builtin::kBitwiseXor);
default:
break;
}
UNREACHABLE();
}
// static
Callable CodeFactory::NonPrimitiveToPrimitive(Isolate* isolate,
ToPrimitiveHint hint) {
......
......@@ -40,17 +40,8 @@ class V8_EXPORT_PRIVATE CodeFactory final {
static Callable StoreOwnIC(Isolate* isolate);
static Callable StoreOwnICInOptimizedCode(Isolate* isolate);
static Callable KeyedStoreIC_SloppyArguments(Isolate* isolate,
KeyedAccessStoreMode mode);
static Callable ElementsTransitionAndStore(Isolate* isolate,
KeyedAccessStoreMode mode);
static Callable StoreFastElementIC(Isolate* isolate,
KeyedAccessStoreMode mode);
static Callable ResumeGenerator(Isolate* isolate);
static Callable BinaryOperation(Isolate* isolate, Operation op);
static Callable ApiGetter(Isolate* isolate);
static Callable CallApiCallback(Isolate* isolate);
......
......@@ -5,9 +5,10 @@
#ifndef V8_IC_HANDLER_CONFIGURATION_INL_H_
#define V8_IC_HANDLER_CONFIGURATION_INL_H_
#include "src/ic/handler-configuration.h"
#include "src/builtins/builtins.h"
#include "src/execution/isolate.h"
#include "src/handles/handles-inl.h"
#include "src/ic/handler-configuration.h"
#include "src/objects/data-handler-inl.h"
#include "src/objects/field-index-inl.h"
#include "src/objects/objects-inl.h"
......@@ -19,6 +20,10 @@
namespace v8 {
namespace internal {
inline Handle<Object> MakeCodeHandler(Isolate* isolate, Builtin builtin) {
return isolate->builtins()->code_handle(builtin);
}
OBJECT_CONSTRUCTORS_IMPL(LoadHandler, DataHandler)
CAST_ACCESSOR(LoadHandler)
......@@ -152,6 +157,52 @@ Handle<Smi> StoreHandler::StoreInterceptor(Isolate* isolate) {
return handle(Smi::FromInt(config), isolate);
}
Builtin StoreHandler::StoreSloppyArgumentsBuiltin(KeyedAccessStoreMode mode) {
switch (mode) {
case STANDARD_STORE:
return Builtin::kKeyedStoreIC_SloppyArguments_Standard;
case STORE_AND_GROW_HANDLE_COW:
return Builtin::kKeyedStoreIC_SloppyArguments_GrowNoTransitionHandleCOW;
case STORE_IGNORE_OUT_OF_BOUNDS:
return Builtin::kKeyedStoreIC_SloppyArguments_NoTransitionIgnoreOOB;
case STORE_HANDLE_COW:
return Builtin::kKeyedStoreIC_SloppyArguments_NoTransitionHandleCOW;
default:
UNREACHABLE();
}
}
Builtin StoreHandler::StoreFastElementBuiltin(KeyedAccessStoreMode mode) {
switch (mode) {
case STANDARD_STORE:
return Builtin::kStoreFastElementIC_Standard;
case STORE_AND_GROW_HANDLE_COW:
return Builtin::kStoreFastElementIC_GrowNoTransitionHandleCOW;
case STORE_IGNORE_OUT_OF_BOUNDS:
return Builtin::kStoreFastElementIC_NoTransitionIgnoreOOB;
case STORE_HANDLE_COW:
return Builtin::kStoreFastElementIC_NoTransitionHandleCOW;
default:
UNREACHABLE();
}
}
Builtin StoreHandler::ElementsTransitionAndStoreBuiltin(
KeyedAccessStoreMode mode) {
switch (mode) {
case STANDARD_STORE:
return Builtin::kElementsTransitionAndStore_Standard;
case STORE_AND_GROW_HANDLE_COW:
return Builtin::kElementsTransitionAndStore_GrowNoTransitionHandleCOW;
case STORE_IGNORE_OUT_OF_BOUNDS:
return Builtin::kElementsTransitionAndStore_NoTransitionIgnoreOOB;
case STORE_HANDLE_COW:
return Builtin::kElementsTransitionAndStore_NoTransitionHandleCOW;
default:
UNREACHABLE();
}
}
Handle<Smi> StoreHandler::StoreSlow(Isolate* isolate,
KeyedAccessStoreMode store_mode) {
int config =
......
......@@ -205,15 +205,15 @@ KeyedAccessStoreMode StoreHandler::GetKeyedAccessStoreMode(
Handle<Object> StoreHandler::StoreElementTransition(
Isolate* isolate, Handle<Map> receiver_map, Handle<Map> transition,
KeyedAccessStoreMode store_mode, MaybeHandle<Object> prev_validity_cell) {
Handle<Code> stub =
CodeFactory::ElementsTransitionAndStore(isolate, store_mode).code();
Handle<Object> code =
MakeCodeHandler(isolate, ElementsTransitionAndStoreBuiltin(store_mode));
Handle<Object> validity_cell;
if (!prev_validity_cell.ToHandle(&validity_cell)) {
validity_cell =
Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate);
}
Handle<StoreHandler> handler = isolate->factory()->NewStoreHandler(1);
handler->set_smi_handler(*stub);
handler->set_smi_handler(*code);
handler->set_validity_cell(*validity_cell);
handler->set_data1(HeapObjectReference::Weak(*transition));
return handler;
......
......@@ -343,6 +343,11 @@ class StoreHandler final : public DataHandler {
// Creates a Smi-handler for storing a property to an interceptor.
static inline Handle<Smi> StoreInterceptor(Isolate* isolate);
static inline Builtin StoreSloppyArgumentsBuiltin(KeyedAccessStoreMode mode);
static inline Builtin StoreFastElementBuiltin(KeyedAccessStoreMode mode);
static inline Builtin ElementsTransitionAndStoreBuiltin(
KeyedAccessStoreMode mode);
// Creates a Smi-handler for storing a property.
static inline Handle<Smi> StoreSlow(
Isolate* isolate, KeyedAccessStoreMode store_mode = STANDARD_STORE);
......
......@@ -10,7 +10,6 @@
#include "src/base/bits.h"
#include "src/base/logging.h"
#include "src/builtins/accessors.h"
#include "src/codegen/code-factory.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/execution/arguments-inl.h"
......@@ -899,6 +898,10 @@ Handle<Smi> MakeLoadWasmStructFieldHandler(Isolate* isolate,
} // namespace
Handle<Object> IC::CodeHandler(Builtin builtin) {
return MakeCodeHandler(isolate(), builtin);
}
Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
Handle<Object> receiver = lookup->GetReceiver();
ReadOnlyRoots roots(isolate());
......@@ -911,13 +914,13 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
if (lookup_start_object->IsString() &&
*lookup->name() == roots.length_string()) {
TRACE_HANDLER_STATS(isolate(), LoadIC_StringLength);
return BUILTIN_CODE(isolate(), LoadIC_StringLength);
return CodeHandler(Builtin::kLoadIC_StringLength);
}
if (lookup_start_object->IsStringWrapper() &&
*lookup->name() == roots.length_string()) {
TRACE_HANDLER_STATS(isolate(), LoadIC_StringWrapperLength);
return BUILTIN_CODE(isolate(), LoadIC_StringWrapperLength);
return CodeHandler(Builtin::kLoadIC_StringWrapperLength);
}
// Use specialized code for getting prototype of functions.
......@@ -926,7 +929,7 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
!JSFunction::cast(*lookup_start_object)
.PrototypeRequiresRuntimeLookup()) {
TRACE_HANDLER_STATS(isolate(), LoadIC_FunctionPrototypeStub);
return BUILTIN_CODE(isolate(), LoadIC_FunctionPrototype);
return CodeHandler(Builtin::kLoadIC_FunctionPrototype);
}
}
......@@ -1316,8 +1319,8 @@ Handle<Object> KeyedLoadIC::LoadElementHandler(Handle<Map> receiver_map,
!receiver_map->GetIndexedInterceptor().non_masking()) {
// TODO(jgruber): Update counter name.
TRACE_HANDLER_STATS(isolate(), KeyedLoadIC_LoadIndexedInterceptorStub);
return IsAnyHas() ? BUILTIN_CODE(isolate(), HasIndexedInterceptorIC)
: BUILTIN_CODE(isolate(), LoadIndexedInterceptorIC);
return IsAnyHas() ? CodeHandler(Builtin::kHasIndexedInterceptorIC)
: CodeHandler(Builtin::kLoadIndexedInterceptorIC);
}
InstanceType instance_type = receiver_map->instance_type();
......@@ -1345,8 +1348,8 @@ Handle<Object> KeyedLoadIC::LoadElementHandler(Handle<Map> receiver_map,
if (IsSloppyArgumentsElementsKind(elements_kind)) {
// TODO(jgruber): Update counter name.
TRACE_HANDLER_STATS(isolate(), KeyedLoadIC_KeyedLoadSloppyArgumentsStub);
return IsAnyHas() ? BUILTIN_CODE(isolate(), KeyedHasIC_SloppyArguments)
: BUILTIN_CODE(isolate(), KeyedLoadIC_SloppyArguments);
return IsAnyHas() ? CodeHandler(Builtin::kKeyedHasIC_SloppyArguments)
: CodeHandler(Builtin::kKeyedLoadIC_SloppyArguments);
}
bool is_js_array = instance_type == JS_ARRAY_TYPE;
if (elements_kind == DICTIONARY_ELEMENTS) {
......@@ -2168,14 +2171,13 @@ Handle<Object> KeyedStoreIC::StoreElementHandler(
if (receiver_map->has_sloppy_arguments_elements()) {
// TODO(jgruber): Update counter name.
TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_KeyedStoreSloppyArgumentsStub);
code =
CodeFactory::KeyedStoreIC_SloppyArguments(isolate(), store_mode).code();
code = CodeHandler(StoreHandler::StoreSloppyArgumentsBuiltin(store_mode));
} else if (receiver_map->has_fast_elements() ||
receiver_map->has_sealed_elements() ||
receiver_map->has_nonextensible_elements() ||
receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) {
TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreFastElementStub);
code = CodeFactory::StoreFastElementIC(isolate(), store_mode).code();
code = CodeHandler(StoreHandler::StoreFastElementBuiltin(store_mode));
if (receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) {
return code;
}
......
......@@ -75,6 +75,8 @@ class IC {
bool is_vector_set() { return vector_set_; }
inline bool vector_needs_update();
inline Handle<Object> CodeHandler(Builtin builtin);
// Configure for most states.
bool ConfigureVectorState(IC::State new_state, Handle<Object> key);
// Configure the vector for MONOMORPHIC.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment