Commit 8f06e08a authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

Replace Code::HANDLER by Code::BUILTIN or Code::STUB

Bug: 
Change-Id: I644c9f8b9ab3bd4250809ee557ec34ee738f5244
Reviewed-on: https://chromium-review.googlesource.com/691654
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48219}
parent b6e1c4e2
......@@ -19,7 +19,7 @@ namespace internal {
// TFC: Builtin in Turbofan, with CodeStub linkage and custom descriptor.
// Args: name, interface descriptor, return_size
// TFH: Handlers in Turbofan, with CodeStub linkage.
// Args: name, code kind, interface descriptor
// Args: name, interface descriptor
// ASM: Builtin in platform-dependent assembly.
// Args: name
......@@ -197,26 +197,26 @@ namespace internal {
TFC(ToBooleanLazyDeoptContinuation, TypeConversionStackParameter, 1) \
\
/* Handlers */ \
TFH(LoadICProtoArray, BUILTIN, LoadICProtoArray) \
TFH(LoadICProtoArrayThrowIfNonexistent, BUILTIN, LoadICProtoArray) \
TFH(KeyedLoadIC_Megamorphic, BUILTIN, LoadWithVector) \
TFH(KeyedLoadIC_Miss, BUILTIN, LoadWithVector) \
TFH(KeyedLoadIC_Slow, HANDLER, LoadWithVector) \
TFH(KeyedLoadIC_IndexedString, HANDLER, LoadWithVector) \
TFH(KeyedStoreIC_Megamorphic, BUILTIN, StoreWithVector) \
TFH(KeyedStoreIC_Miss, BUILTIN, StoreWithVector) \
TFH(KeyedStoreIC_Slow, HANDLER, StoreWithVector) \
TFH(LoadGlobalIC_Miss, BUILTIN, LoadGlobalWithVector) \
TFH(LoadGlobalIC_Slow, HANDLER, LoadGlobalWithVector) \
TFH(LoadField, BUILTIN, LoadField) \
TFH(LoadIC_FunctionPrototype, HANDLER, LoadWithVector) \
TFH(LoadICProtoArray, LoadICProtoArray) \
TFH(LoadICProtoArrayThrowIfNonexistent, LoadICProtoArray) \
TFH(KeyedLoadIC_Megamorphic, LoadWithVector) \
TFH(KeyedLoadIC_Miss, LoadWithVector) \
TFH(KeyedLoadIC_Slow, LoadWithVector) \
TFH(KeyedLoadIC_IndexedString, LoadWithVector) \
TFH(KeyedStoreIC_Megamorphic, StoreWithVector) \
TFH(KeyedStoreIC_Miss, StoreWithVector) \
TFH(KeyedStoreIC_Slow, StoreWithVector) \
TFH(LoadGlobalIC_Miss, LoadGlobalWithVector) \
TFH(LoadGlobalIC_Slow, LoadGlobalWithVector) \
TFH(LoadField, LoadField) \
TFH(LoadIC_FunctionPrototype, LoadWithVector) \
ASM(LoadIC_Getter_ForDeopt) \
TFH(LoadIC_Miss, BUILTIN, LoadWithVector) \
TFH(LoadIC_Slow, HANDLER, LoadWithVector) \
TFH(LoadIC_Uninitialized, BUILTIN, LoadWithVector) \
TFH(StoreIC_Miss, BUILTIN, StoreWithVector) \
TFH(LoadIC_Miss, LoadWithVector) \
TFH(LoadIC_Slow, LoadWithVector) \
TFH(LoadIC_Uninitialized, LoadWithVector) \
TFH(StoreIC_Miss, StoreWithVector) \
ASM(StoreIC_Setter_ForDeopt) \
TFH(StoreIC_Uninitialized, BUILTIN, StoreWithVector) \
TFH(StoreIC_Uninitialized, StoreWithVector) \
\
/* Promise helpers */ \
TFS(ResolveNativePromise, kPromise, kValue) \
......@@ -539,19 +539,19 @@ namespace internal {
CPP(JsonStringify) \
\
/* ICs */ \
TFH(LoadIC, STUB, LoadWithVector) \
TFH(LoadIC_Noninlined, BUILTIN, LoadWithVector) \
TFH(LoadICTrampoline, STUB, Load) \
TFH(KeyedLoadIC, STUB, LoadWithVector) \
TFH(KeyedLoadICTrampoline, STUB, Load) \
TFH(StoreIC, STUB, StoreWithVector) \
TFH(StoreICTrampoline, STUB, Store) \
TFH(KeyedStoreIC, STUB, StoreWithVector) \
TFH(KeyedStoreICTrampoline, STUB, Store) \
TFH(LoadGlobalIC, STUB, LoadGlobalWithVector) \
TFH(LoadGlobalICInsideTypeof, STUB, LoadGlobalWithVector) \
TFH(LoadGlobalICTrampoline, STUB, LoadGlobal) \
TFH(LoadGlobalICInsideTypeofTrampoline, STUB, LoadGlobal) \
TFH(LoadIC, LoadWithVector) \
TFH(LoadIC_Noninlined, LoadWithVector) \
TFH(LoadICTrampoline, Load) \
TFH(KeyedLoadIC, LoadWithVector) \
TFH(KeyedLoadICTrampoline, Load) \
TFH(StoreIC, StoreWithVector) \
TFH(StoreICTrampoline, Store) \
TFH(KeyedStoreIC, StoreWithVector) \
TFH(KeyedStoreICTrampoline, Store) \
TFH(LoadGlobalIC, LoadGlobalWithVector) \
TFH(LoadGlobalICInsideTypeof, LoadGlobalWithVector) \
TFH(LoadGlobalICTrampoline, LoadGlobal) \
TFH(LoadGlobalICInsideTypeofTrampoline, LoadGlobal) \
\
/* Map */ \
TFS(MapLookupHashIndex, kTable, kKey) \
......
......@@ -33,7 +33,7 @@ namespace internal {
typedef Name##Descriptor Builtin_##Name##_InterfaceDescriptor;
// Define interface descriptors for IC handlers/dispatchers.
#define DEFINE_TFH_INTERFACE_DESCRIPTOR(Name, Kind, InterfaceDescriptor) \
#define DEFINE_TFH_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
typedef InterfaceDescriptor##Descriptor Builtin_##Name##_InterfaceDescriptor;
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, DEFINE_TFJ_INTERFACE_DESCRIPTOR,
......
......@@ -239,13 +239,12 @@ void SetupIsolateDelegate::SetupBuiltinsInternal(Isolate* isolate) {
CallDescriptors::Name, kBuiltinFlags, \
#Name, 1); \
AddBuiltin(builtins, index++, code);
#define BUILD_TFH(Name, Kind, InterfaceDescriptor) \
{ InterfaceDescriptor##Descriptor descriptor(isolate); } \
/* Return size for IC builtins/handlers is always 1. */ \
code = \
BuildWithCodeStubAssemblerCS(isolate, &Builtins::Generate_##Name, \
CallDescriptors::InterfaceDescriptor, \
Code::ComputeFlags(Code::Kind), #Name, 1); \
#define BUILD_TFH(Name, InterfaceDescriptor) \
{ InterfaceDescriptor##Descriptor descriptor(isolate); } \
/* Return size for IC builtins/handlers is always 1. */ \
code = BuildWithCodeStubAssemblerCS(isolate, &Builtins::Generate_##Name, \
CallDescriptors::InterfaceDescriptor, \
kBuiltinFlags, #Name, 1); \
AddBuiltin(builtins, index++, code);
#define BUILD_ASM(Name) \
code = BuildWithMacroAssembler(isolate, Builtins::Generate_##Name, \
......
......@@ -95,15 +95,6 @@ void CodeStub::RecordCodeGeneration(Handle<Code> code) {
}
Code::Kind CodeStub::GetCodeKind() const {
return Code::STUB;
}
Code::Flags CodeStub::GetCodeFlags() const {
return Code::ComputeFlags(GetCodeKind());
}
void CodeStub::DeleteStubFromCacheForTesting() {
Heap* heap = isolate_->heap();
Handle<UnseededNumberDictionary> dict(heap->code_stubs());
......@@ -134,7 +125,7 @@ Handle<Code> PlatformCodeStub::GenerateCode() {
CodeDesc desc;
masm.GetCode(isolate(), &desc);
// Copy the generated code into a heap object.
Code::Flags flags = Code::ComputeFlags(GetCodeKind());
Code::Flags flags = Code::ComputeFlags(Code::STUB);
Handle<Code> new_object = factory->NewCode(
desc, flags, masm.CodeObject(), NeedsImmovableCode());
return new_object;
......@@ -144,10 +135,9 @@ Handle<Code> PlatformCodeStub::GenerateCode() {
Handle<Code> CodeStub::GetCode() {
Heap* heap = isolate()->heap();
Code* code;
if (UseSpecialCache() ? FindCodeInSpecialCache(&code)
: FindCodeInCache(&code)) {
DCHECK(GetCodeKind() == code->kind());
return Handle<Code>(code);
if (FindCodeInCache(&code)) {
DCHECK(code->is_stub());
return handle(code);
}
{
......@@ -172,14 +162,10 @@ Handle<Code> CodeStub::GetCode() {
}
#endif
if (UseSpecialCache()) {
AddToSpecialCache(new_object);
} else {
// Update the dictionary and the root in Heap.
Handle<UnseededNumberDictionary> dict = UnseededNumberDictionary::Set(
handle(heap->code_stubs()), GetKey(), new_object);
heap->SetRootCodeStubs(*dict);
}
// Update the dictionary and the root in Heap.
Handle<UnseededNumberDictionary> dict = UnseededNumberDictionary::Set(
handle(heap->code_stubs()), GetKey(), new_object);
heap->SetRootCodeStubs(*dict);
code = *new_object;
}
......@@ -256,8 +242,7 @@ void CodeStub::InitializeDescriptor(Isolate* isolate, uint32_t key,
void CodeStub::GetCodeDispatchCall(CodeStub* stub, void** value_out) {
Handle<Code>* code_out = reinterpret_cast<Handle<Code>*>(value_out);
// Code stubs with special cache cannot be recreated from stub key.
*code_out = stub->UseSpecialCache() ? Handle<Code>() : stub->GetCode();
*code_out = stub->GetCode();
}
......@@ -312,7 +297,7 @@ Handle<Code> TurboFanCodeStub::GenerateCode() {
Zone zone(isolate()->allocator(), ZONE_NAME);
CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor());
compiler::CodeAssemblerState state(isolate(), &zone, descriptor,
GetCodeFlags(), name);
Code::ComputeFlags(Code::STUB), name);
GenerateAssembly(&state);
return compiler::CodeAssembler::GenerateCode(&state);
}
......
......@@ -189,11 +189,6 @@ class CodeStub : public ZoneObject {
virtual Major MajorKey() const = 0;
uint32_t MinorKey() const { return minor_key_; }
// BinaryOpStub needs to override this.
virtual Code::Kind GetCodeKind() const;
Code::Flags GetCodeFlags() const;
friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) {
s.PrintName(os);
return os;
......@@ -243,19 +238,6 @@ class CodeStub : public ZoneObject {
// registering stub in the stub cache.
virtual void Activate(Code* code) { }
// Add the code to a specialized cache, specific to an individual
// stub type. Please note, this method must add the code object to a
// roots object, otherwise we will remove the code during GC.
virtual void AddToSpecialCache(Handle<Code> new_object) { }
// Find code in a specialized cache, work is delegated to the specific stub.
virtual bool FindCodeInSpecialCache(Code** code_out) {
return false;
}
// If a stub uses a special cache override this.
virtual bool UseSpecialCache() { return false; }
// We use this dispatch to statically instantiate the correct code stub for
// the given stub key and call the passed function with that code stub.
typedef void (*DispatchedCall)(CodeStub* stub, void** value_out);
......@@ -484,8 +466,6 @@ class StringLengthStub : public TurboFanCodeStub {
public:
explicit StringLengthStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_TURBOFAN_CODE_STUB(StringLength, TurboFanCodeStub);
};
......@@ -494,8 +474,6 @@ class StoreInterceptorStub : public TurboFanCodeStub {
public:
explicit StoreInterceptorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_TURBOFAN_CODE_STUB(StoreInterceptor, TurboFanCodeStub);
};
......@@ -536,8 +514,6 @@ class LoadIndexedInterceptorStub : public TurboFanCodeStub {
explicit LoadIndexedInterceptorStub(Isolate* isolate)
: TurboFanCodeStub(isolate) {}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_TURBOFAN_CODE_STUB(LoadIndexedInterceptor, TurboFanCodeStub);
};
......@@ -645,8 +621,6 @@ class KeyedLoadSloppyArgumentsStub : public TurboFanCodeStub {
explicit KeyedLoadSloppyArgumentsStub(Isolate* isolate)
: TurboFanCodeStub(isolate) {}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
protected:
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_TURBOFAN_CODE_STUB(KeyedLoadSloppyArguments, TurboFanCodeStub);
......@@ -663,8 +637,6 @@ class KeyedStoreSloppyArgumentsStub : public TurboFanCodeStub {
minor_key_ = CommonStoreModeBits::encode(mode);
}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
protected:
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_TURBOFAN_CODE_STUB(KeyedStoreSloppyArguments, TurboFanCodeStub);
......@@ -881,8 +853,6 @@ class ScriptContextFieldStub : public TurboFanCodeStub {
SlotIndexBits::encode(lookup_result->slot_index);
}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
int context_index() const { return ContextIndexBits::decode(minor_key_); }
int slot_index() const { return SlotIndexBits::decode(minor_key_); }
......@@ -948,8 +918,6 @@ class StoreFastElementStub : public TurboFanCodeStub {
return CommonStoreModeBits::decode(minor_key_);
}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
private:
class ElementsKindBits
: public BitField<ElementsKind, CommonStoreModeBits::kNext, 8> {};
......@@ -1079,8 +1047,6 @@ class StoreSlowElementStub : public TurboFanCodeStub {
minor_key_ = CommonStoreModeBits::encode(mode);
}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
private:
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_TURBOFAN_CODE_STUB(StoreSlowElement, TurboFanCodeStub);
......@@ -1104,8 +1070,6 @@ class ElementsTransitionAndStoreStub : public TurboFanCodeStub {
return CommonStoreModeBits::decode(minor_key_);
}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
private:
class FromBits
: public BitField<ElementsKind, CommonStoreModeBits::kNext, 8> {};
......
......@@ -155,7 +155,6 @@ StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
switch (output_code_kind()) {
case Code::STUB:
case Code::BYTECODE_HANDLER:
case Code::HANDLER:
case Code::BUILTIN:
return StackFrame::STUB;
case Code::WASM_FUNCTION:
......
......@@ -117,7 +117,7 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
out->AddFormatted(" ;; code:");
Code* code = Code::GetCodeFromTargetAddress(relocinfo->target_address());
Code::Kind kind = code->kind();
if (kind == Code::STUB || kind == Code::HANDLER) {
if (kind == Code::STUB) {
// Get the STUB key and extract major and minor key.
uint32_t key = code->stub_key();
uint32_t minor_key = CodeStub::MinorKeyFromKey(key);
......
......@@ -871,6 +871,7 @@ KeyedAccessStoreMode KeyedStoreICNexus::GetKeyedAccessStoreMode() const {
} else {
// Element store without prototype chain check.
handler = Handle<Code>::cast(maybe_code_handler);
if (handler->is_builtin()) continue;
}
CodeStub::Major major_key = CodeStub::MajorKeyFromKey(handler->stub_key());
uint32_t minor_key = CodeStub::MinorKeyFromKey(handler->stub_key());
......
......@@ -16,13 +16,14 @@ namespace v8 {
namespace internal {
Handle<Code> PropertyHandlerCompiler::GetCode(Handle<Name> name) {
Code::Flags flags = Code::ComputeFlags(Code::HANDLER);
Code::Flags flags = Code::ComputeFlags(Code::STUB);
// Create code object in the heap.
CodeDesc desc;
masm()->GetCode(isolate(), &desc);
Handle<Code> code = factory()->NewCode(desc, flags, masm()->CodeObject());
if (code->IsCodeStubOrIC()) code->set_stub_key(CodeStub::NoCacheKey());
DCHECK(code->is_stub());
code->set_stub_key(CodeStub::NoCacheKey());
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code_stubs) {
char* raw_name = !name.is_null() && name->IsString()
......
......@@ -43,7 +43,7 @@ Address IC::raw_constant_pool() const {
bool IC::IsHandler(Object* object) {
return (object->IsSmi() && (object != nullptr)) || object->IsTuple2() ||
object->IsTuple3() || object->IsFixedArray() || object->IsWeakCell() ||
(object->IsCode() && Code::cast(object)->is_handler());
object->IsCode();
}
bool IC::AddressIsDeoptimizedCode() const {
......
......@@ -1584,10 +1584,6 @@ void Logger::LogCodeObject(Object* object) {
isolate_->builtins()->name(code_object->GetCode()->builtin_index());
tag = CodeEventListener::BUILTIN_TAG;
break;
case AbstractCode::HANDLER:
description = "An IC handler from the snapshot";
tag = CodeEventListener::HANDLER_TAG;
break;
case AbstractCode::WASM_FUNCTION:
description = "A Wasm function";
tag = CodeEventListener::STUB_TAG;
......
......@@ -847,7 +847,7 @@ void Code::CodeVerify() {
}
}
CHECK(raw_type_feedback_info() == Smi::kZero ||
raw_type_feedback_info()->IsSmi() == IsCodeStubOrIC());
raw_type_feedback_info()->IsSmi() == is_stub());
}
......
......@@ -3694,17 +3694,6 @@ void Code::set_flags(Code::Flags flags) {
Code::Kind Code::kind() const { return ExtractKindFromFlags(flags()); }
bool Code::IsCodeStubOrIC() const {
switch (kind()) {
case STUB:
case HANDLER:
return true;
default:
return false;
}
}
// For initialization.
void Code::set_raw_kind_specific_flags1(int value) {
WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value);
......@@ -3902,7 +3891,6 @@ void Code::set_deopt_already_counted(bool flag) {
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
}
bool Code::is_handler() const { return kind() == HANDLER; }
bool Code::is_stub() const { return kind() == STUB; }
bool Code::is_optimized_code() const { return kind() == OPTIMIZED_FUNCTION; }
bool Code::is_wasm_code() const { return kind() == WASM_FUNCTION; }
......@@ -4869,14 +4857,14 @@ ByteArray* Code::SourcePositionTable() const {
}
uint32_t Code::stub_key() const {
DCHECK(IsCodeStubOrIC());
DCHECK(is_stub());
Smi* smi_key = Smi::cast(raw_type_feedback_info());
return static_cast<uint32_t>(smi_key->value());
}
void Code::set_stub_key(uint32_t key) {
DCHECK(IsCodeStubOrIC());
DCHECK(is_stub());
set_raw_type_feedback_info(Smi::FromInt(key));
}
......
......@@ -14271,7 +14271,7 @@ void HandlerTable::HandlerTableReturnPrint(std::ostream& os) {
void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT
os << "kind = " << Kind2String(kind()) << "\n";
if (IsCodeStubOrIC()) {
if (is_stub()) {
const char* n = CodeStub::MajorName(CodeStub::GetMajorKey(this));
os << "major_key = " << (n == NULL ? "null" : n) << "\n";
}
......
......@@ -3646,7 +3646,6 @@ class Code: public HeapObject {
V(OPTIMIZED_FUNCTION) \
V(BYTECODE_HANDLER) \
V(STUB) \
V(HANDLER) \
V(BUILTIN) \
V(REGEXP) \
V(WASM_FUNCTION) \
......@@ -3728,14 +3727,10 @@ class Code: public HeapObject {
// [flags]: Access to specific code flags.
inline Kind kind() const;
// Testers for IC stub kinds.
inline bool is_handler() const;
inline bool is_stub() const;
inline bool is_optimized_code() const;
inline bool is_wasm_code() const;
inline bool IsCodeStubOrIC() const;
inline void set_raw_kind_specific_flags1(int value);
inline void set_raw_kind_specific_flags2(int value);
......
......@@ -78,7 +78,6 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
Code* code_object = Code::cast(obj);
switch (code_object->kind()) {
case Code::OPTIMIZED_FUNCTION: // No optimized code compiled yet.
case Code::HANDLER: // No handlers patched in yet.
case Code::REGEXP: // No regexp literals initialized yet.
case Code::NUMBER_OF_KINDS: // Pseudo enum value.
case Code::BYTECODE_HANDLER: // No direct references to handlers.
......
......@@ -25,7 +25,7 @@ class StubTester {
StubTester(Isolate* isolate, Zone* zone, CodeStub* stub)
: zone_(zone),
info_(ArrayVector("test"), isolate, zone,
Code::ComputeFlags(Code::HANDLER)),
Code::ComputeFlags(Code::STUB)),
interface_descriptor_(stub->GetCallInterfaceDescriptor()),
descriptor_(Linkage::GetStubCallDescriptor(
isolate, zone, interface_descriptor_,
......@@ -39,7 +39,7 @@ class StubTester {
StubTester(Isolate* isolate, Zone* zone, Builtins::Name name)
: zone_(zone),
info_(ArrayVector("test"), isolate, zone,
Code::ComputeFlags(Code::HANDLER)),
Code::ComputeFlags(Code::STUB)),
interface_descriptor_(
Builtins::CallableFor(isolate, name).descriptor()),
descriptor_(Linkage::GetStubCallDescriptor(
......
......@@ -203,7 +203,7 @@ TEST(TryProbeStubCache) {
// Generate some number of handlers.
for (int i = 0; i < 30; i++) {
Code::Flags flags = Code::ComputeFlags(Code::HANDLER);
Code::Flags flags = Code::ComputeFlags(Code::STUB);
handlers.push_back(CreateCodeWithFlags(flags));
}
......
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