[stubs] Introduce TF_STUB macro.

... which is a TF_BUILTIN-like wrapper for defining code stubs.

BUG=v8:6116

Change-Id: Iad599dfc71a50c5082d9e3fba2a7b553b9912207
Reviewed-on: https://chromium-review.googlesource.com/458476
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44022}
This commit is contained in:
Igor Sheludko 2017-03-22 13:00:50 +01:00 committed by Commit Bot
parent 2656c221ed
commit e046b80a55
6 changed files with 412 additions and 482 deletions

View File

@ -1142,6 +1142,7 @@ v8_source_set("v8_base") {
"src/code-stub-assembler.cc", "src/code-stub-assembler.cc",
"src/code-stub-assembler.h", "src/code-stub-assembler.h",
"src/code-stubs-hydrogen.cc", "src/code-stubs-hydrogen.cc",
"src/code-stubs-utils.h",
"src/code-stubs.cc", "src/code-stubs.cc",
"src/code-stubs.h", "src/code-stubs.h",
"src/codegen.cc", "src/codegen.cc",

49
src/code-stubs-utils.h Normal file
View File

@ -0,0 +1,49 @@
// Copyright 2017 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.
#ifndef V8_CODE_STUBS_UTILS_H_
#define V8_CODE_STUBS_UTILS_H_
namespace v8 {
namespace internal {
namespace compiler {
class CodeAssemblerState;
} // namespace compiler
// ----------------------------------------------------------------------------
// Support macro for defining code stubs with Turbofan.
// ----------------------------------------------------------------------------
//
// A code stub generator is defined by writing:
//
// TF_STUB(name, code_assember_base_class) {
// ...
// }
//
// In the body of the generator function the arguments can be accessed
// as "Parameter(n)".
#define TF_STUB(StubName, AssemblerBase) \
class StubName##Assembler : public AssemblerBase { \
public: \
typedef StubName::Descriptor Descriptor; \
\
explicit StubName##Assembler(compiler::CodeAssemblerState* state) \
: AssemblerBase(state) {} \
void Generate##StubName##Impl(const StubName* stub); \
\
Node* Parameter(Descriptor::ParameterIndices index) { \
return CodeAssembler::Parameter(static_cast<int>(index)); \
} \
}; \
void StubName::GenerateAssembly(compiler::CodeAssemblerState* state) const { \
StubName##Assembler assembler(state); \
assembler.Generate##StubName##Impl(this); \
} \
void StubName##Assembler::Generate##StubName##Impl(const StubName* stub)
} // namespace internal
} // namespace v8
#endif // V8_CODE_STUBS_UTILS_H_

File diff suppressed because it is too large Load Diff

View File

@ -844,10 +844,6 @@ class CallICStub : public TurboFanCodeStub {
TailCallModeBits::encode(tail_call_mode); TailCallModeBits::encode(tail_call_mode);
} }
protected:
typedef BitField<ConvertReceiverMode, 0, 2> ConvertModeBits;
typedef BitField<TailCallMode, ConvertModeBits::kNext, 1> TailCallModeBits;
ConvertReceiverMode convert_mode() const { ConvertReceiverMode convert_mode() const {
return ConvertModeBits::decode(minor_key_); return ConvertModeBits::decode(minor_key_);
} }
@ -855,6 +851,10 @@ class CallICStub : public TurboFanCodeStub {
return TailCallModeBits::decode(minor_key_); return TailCallModeBits::decode(minor_key_);
} }
protected:
typedef BitField<ConvertReceiverMode, 0, 2> ConvertModeBits;
typedef BitField<TailCallMode, ConvertModeBits::kNext, 1> TailCallModeBits;
private: private:
void PrintState(std::ostream& os) const final; // NOLINT void PrintState(std::ostream& os) const final; // NOLINT
@ -1301,31 +1301,14 @@ class StringCharCodeAtGenerator {
DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator); DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator);
}; };
class CallICTrampolineStub : public TurboFanCodeStub { class CallICTrampolineStub : public CallICStub {
public: public:
CallICTrampolineStub(Isolate* isolate, ConvertReceiverMode convert_mode, CallICTrampolineStub(Isolate* isolate, ConvertReceiverMode convert_mode,
TailCallMode tail_call_mode) TailCallMode tail_call_mode)
: TurboFanCodeStub(isolate) { : CallICStub(isolate, convert_mode, tail_call_mode) {}
minor_key_ = ConvertModeBits::encode(convert_mode) |
TailCallModeBits::encode(tail_call_mode);
}
protected:
typedef BitField<ConvertReceiverMode, 0, 2> ConvertModeBits;
typedef BitField<TailCallMode, ConvertModeBits::kNext, 1> TailCallModeBits;
ConvertReceiverMode convert_mode() const {
return ConvertModeBits::decode(minor_key_);
}
TailCallMode tail_call_mode() const {
return TailCallModeBits::decode(minor_key_);
}
private:
void PrintState(std::ostream& os) const override; // NOLINT
DEFINE_CALL_INTERFACE_DESCRIPTOR(CallICTrampoline); DEFINE_CALL_INTERFACE_DESCRIPTOR(CallICTrampoline);
DEFINE_TURBOFAN_CODE_STUB(CallICTrampoline, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(CallICTrampoline, CallICStub);
}; };
class DoubleToIStub : public PlatformCodeStub { class DoubleToIStub : public PlatformCodeStub {
@ -1780,10 +1763,6 @@ class SubStringStub : public TurboFanCodeStub {
public: public:
explicit SubStringStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} explicit SubStringStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
static compiler::Node* Generate(CodeStubAssembler* assembler,
compiler::Node* string, compiler::Node* from,
compiler::Node* to, compiler::Node* context);
DEFINE_CALL_INTERFACE_DESCRIPTOR(SubString); DEFINE_CALL_INTERFACE_DESCRIPTOR(SubString);
DEFINE_TURBOFAN_CODE_STUB(SubString, TurboFanCodeStub); DEFINE_TURBOFAN_CODE_STUB(SubString, TurboFanCodeStub);
}; };

View File

@ -703,6 +703,7 @@ class TransitionElementsKindDescriptor : public CallInterfaceDescriptor {
class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor { class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor {
public: public:
DEFINE_EMPTY_PARAMETERS()
DECLARE_DESCRIPTOR(AllocateHeapNumberDescriptor, CallInterfaceDescriptor) DECLARE_DESCRIPTOR(AllocateHeapNumberDescriptor, CallInterfaceDescriptor)
}; };

View File

@ -553,6 +553,7 @@
'code-stubs.cc', 'code-stubs.cc',
'code-stubs.h', 'code-stubs.h',
'code-stubs-hydrogen.cc', 'code-stubs-hydrogen.cc',
'code-stubs-utils.h',
'codegen.cc', 'codegen.cc',
'codegen.h', 'codegen.h',
'collector.h', 'collector.h',