Commit 507c11a0 authored by svenpanne's avatar svenpanne Committed by Commit bot

Converted Crankshaft to have its own list of known intrinsics.

We can remove a few of them now (those which unconditionally bailout),
but this will be done in a separate CL to see any impact separately.

BUG=v8:3947
LOG=n

Review URL: https://codereview.chromium.org/993963002

Cr-Commit-Position: refs/heads/master@{#27102}
parent 1bdef1ca
...@@ -9524,38 +9524,6 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) { ...@@ -9524,38 +9524,6 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
} }
// Support for generating inlined runtime functions.
// Lookup table for generators for runtime calls that are generated inline.
// Elements of the table are member pointers to functions of
// HOptimizedGraphBuilder.
#define INLINE_FUNCTION_GENERATOR_ADDRESS(Name, argc, ressize) \
&HOptimizedGraphBuilder::Generate##Name,
const HOptimizedGraphBuilder::InlineFunctionGenerator
HOptimizedGraphBuilder::kInlineFunctionGenerators[] = {
INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS)
INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS)
};
#undef INLINE_FUNCTION_GENERATOR_ADDRESS
HOptimizedGraphBuilder::InlineFunctionGenerator
HOptimizedGraphBuilder::FindInlineFunctionGenerator(CallRuntime* expr) {
const Runtime::Function* function = expr->function();
if (function == nullptr || function->intrinsic_type != Runtime::INLINE) {
return nullptr;
}
Runtime::FunctionId id = function->function_id;
if (id < Runtime::kFirstInlineFunction) return nullptr;
int lookup_index =
static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction);
DCHECK(static_cast<size_t>(lookup_index) <
arraysize(kInlineFunctionGenerators));
return kInlineFunctionGenerators[lookup_index];
}
template <class ViewClass> template <class ViewClass>
void HGraphBuilder::BuildArrayBufferViewInitialization( void HGraphBuilder::BuildArrayBufferViewInitialization(
HValue* obj, HValue* obj,
...@@ -9934,22 +9902,22 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { ...@@ -9934,22 +9902,22 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
const Runtime::Function* function = expr->function(); const Runtime::Function* function = expr->function();
DCHECK(function != NULL); DCHECK(function != NULL);
switch (function->function_id) {
InlineFunctionGenerator generator = FindInlineFunctionGenerator(expr); #define CALL_INTRINSIC_GENERATOR(Name) \
if (generator != nullptr) { case Runtime::kInline##Name: \
DCHECK(expr->name()->length() > 0); return Generate##Name(expr);
DCHECK(expr->name()->Get(0) == '_');
// Call the inline code generator using the pointer-to-member. FOR_EACH_HYDROGEN_INTRINSIC(CALL_INTRINSIC_GENERATOR)
(this->*generator)(expr); #undef CALL_INTRINSIC_GENERATOR
} else { default: {
Handle<String> name = expr->name(); Handle<String> name = expr->name();
int argument_count = expr->arguments()->length(); int argument_count = expr->arguments()->length();
CHECK_ALIVE(VisitExpressions(expr->arguments())); CHECK_ALIVE(VisitExpressions(expr->arguments()));
PushArgumentsFromEnvironment(argument_count); PushArgumentsFromEnvironment(argument_count);
HCallRuntime* call = New<HCallRuntime>(name, function, HCallRuntime* call = New<HCallRuntime>(name, function, argument_count);
argument_count);
return ast_context()->ReturnInstruction(call, expr->id()); return ast_context()->ReturnInstruction(call, expr->id());
} }
}
} }
......
...@@ -2118,17 +2118,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2118,17 +2118,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
protected: protected:
// Type of a member function that generates inline code for a native function.
typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator)
(CallRuntime* call);
InlineFunctionGenerator FindInlineFunctionGenerator(CallRuntime* expr);
// Forward declarations for inner scope classes. // Forward declarations for inner scope classes.
class SubgraphScope; class SubgraphScope;
static const InlineFunctionGenerator kInlineFunctionGenerators[];
static const int kMaxCallPolymorphism = 4; static const int kMaxCallPolymorphism = 4;
static const int kMaxLoadPolymorphism = 4; static const int kMaxLoadPolymorphism = 4;
static const int kMaxStorePolymorphism = 4; static const int kMaxStorePolymorphism = 4;
...@@ -2170,13 +2162,86 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2170,13 +2162,86 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
return function_state()->compilation_info()->language_mode(); return function_state()->compilation_info()->language_mode();
} }
// Generators for inline runtime functions. #define FOR_EACH_HYDROGEN_INTRINSIC(F) \
#define INLINE_FUNCTION_GENERATOR_DECLARATION(Name, argc, ressize) \ F(IsSmi) \
void Generate##Name(CallRuntime* call); F(IsNonNegativeSmi) \
F(IsArray) \
INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION) F(IsRegExp) \
INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION) F(IsJSProxy) \
#undef INLINE_FUNCTION_GENERATOR_DECLARATION F(IsConstructCall) \
F(CallFunction) \
F(DefaultConstructorCallSuper) \
F(ArgumentsLength) \
F(Arguments) \
F(ValueOf) \
F(SetValueOf) \
F(DateField) \
F(StringCharFromCode) \
F(StringCharAt) \
F(OneByteSeqStringSetChar) \
F(TwoByteSeqStringSetChar) \
F(ObjectEquals) \
F(IsObject) \
F(IsFunction) \
F(IsUndetectableObject) \
F(IsSpecObject) \
F(IsStringWrapperSafeForDefaultValueOf) \
F(MathPow) \
F(IsMinusZero) \
F(HasCachedArrayIndex) \
F(GetCachedArrayIndex) \
F(FastOneByteArrayJoin) \
F(GeneratorNext) \
F(GeneratorThrow) \
F(DebugBreakInOptimizedCode) \
F(ClassOf) \
F(StringCharCodeAt) \
F(StringAdd) \
F(SubString) \
F(StringCompare) \
F(RegExpExec) \
F(RegExpConstructResult) \
F(GetFromCache) \
F(NumberToString) \
F(DebugIsActive) \
/* Typed Arrays */ \
F(TypedArrayInitialize) \
F(DataViewInitialize) \
F(MaxSmi) \
F(TypedArrayMaxSizeInHeap) \
F(ArrayBufferViewGetByteLength) \
F(ArrayBufferViewGetByteOffset) \
F(TypedArrayGetLength) \
/* ArrayBuffer */ \
F(ArrayBufferGetByteLength) \
/* Maths */ \
F(ConstructDouble) \
F(DoubleHi) \
F(DoubleLo) \
F(MathFloor) \
F(MathSqrtRT) \
F(MathLogRT) \
/* ES6 Collections */ \
F(MapClear) \
F(MapDelete) \
F(MapGet) \
F(MapGetSize) \
F(MapHas) \
F(MapInitialize) \
F(MapSet) \
F(SetAdd) \
F(SetClear) \
F(SetDelete) \
F(SetGetSize) \
F(SetHas) \
F(SetInitialize) \
/* Arrays */ \
F(HasFastPackedElements) \
F(GetPrototype)
#define GENERATOR_DECLARATION(Name) void Generate##Name(CallRuntime* call);
FOR_EACH_HYDROGEN_INTRINSIC(GENERATOR_DECLARATION)
#undef GENERATOR_DECLARATION
void VisitDelete(UnaryOperation* expr); void VisitDelete(UnaryOperation* expr);
void VisitVoid(UnaryOperation* expr); void VisitVoid(UnaryOperation* expr);
......
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