[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:
parent
2656c221ed
commit
e046b80a55
1
BUILD.gn
1
BUILD.gn
@ -1142,6 +1142,7 @@ v8_source_set("v8_base") {
|
||||
"src/code-stub-assembler.cc",
|
||||
"src/code-stub-assembler.h",
|
||||
"src/code-stubs-hydrogen.cc",
|
||||
"src/code-stubs-utils.h",
|
||||
"src/code-stubs.cc",
|
||||
"src/code-stubs.h",
|
||||
"src/codegen.cc",
|
||||
|
49
src/code-stubs-utils.h
Normal file
49
src/code-stubs-utils.h
Normal 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
@ -844,10 +844,6 @@ class CallICStub : public TurboFanCodeStub {
|
||||
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_);
|
||||
}
|
||||
@ -855,6 +851,10 @@ class CallICStub : public TurboFanCodeStub {
|
||||
return TailCallModeBits::decode(minor_key_);
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef BitField<ConvertReceiverMode, 0, 2> ConvertModeBits;
|
||||
typedef BitField<TailCallMode, ConvertModeBits::kNext, 1> TailCallModeBits;
|
||||
|
||||
private:
|
||||
void PrintState(std::ostream& os) const final; // NOLINT
|
||||
|
||||
@ -1301,31 +1301,14 @@ class StringCharCodeAtGenerator {
|
||||
DISALLOW_COPY_AND_ASSIGN(StringCharCodeAtGenerator);
|
||||
};
|
||||
|
||||
class CallICTrampolineStub : public TurboFanCodeStub {
|
||||
class CallICTrampolineStub : public CallICStub {
|
||||
public:
|
||||
CallICTrampolineStub(Isolate* isolate, ConvertReceiverMode convert_mode,
|
||||
TailCallMode tail_call_mode)
|
||||
: TurboFanCodeStub(isolate) {
|
||||
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
|
||||
: CallICStub(isolate, convert_mode, tail_call_mode) {}
|
||||
|
||||
DEFINE_CALL_INTERFACE_DESCRIPTOR(CallICTrampoline);
|
||||
DEFINE_TURBOFAN_CODE_STUB(CallICTrampoline, TurboFanCodeStub);
|
||||
DEFINE_TURBOFAN_CODE_STUB(CallICTrampoline, CallICStub);
|
||||
};
|
||||
|
||||
class DoubleToIStub : public PlatformCodeStub {
|
||||
@ -1780,10 +1763,6 @@ class SubStringStub : public TurboFanCodeStub {
|
||||
public:
|
||||
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_TURBOFAN_CODE_STUB(SubString, TurboFanCodeStub);
|
||||
};
|
||||
|
@ -703,6 +703,7 @@ class TransitionElementsKindDescriptor : public CallInterfaceDescriptor {
|
||||
|
||||
class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor {
|
||||
public:
|
||||
DEFINE_EMPTY_PARAMETERS()
|
||||
DECLARE_DESCRIPTOR(AllocateHeapNumberDescriptor, CallInterfaceDescriptor)
|
||||
};
|
||||
|
||||
|
@ -553,6 +553,7 @@
|
||||
'code-stubs.cc',
|
||||
'code-stubs.h',
|
||||
'code-stubs-hydrogen.cc',
|
||||
'code-stubs-utils.h',
|
||||
'codegen.cc',
|
||||
'codegen.h',
|
||||
'collector.h',
|
||||
|
Loading…
Reference in New Issue
Block a user