Commit 2e80f582 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Introduce code stub constructors for stub keys.

R=mvstanton@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23716 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 547589e2
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef V8_ARM_CODE_STUBS_ARM_H_ #ifndef V8_ARM_CODE_STUBS_ARM_H_
#define V8_ARM_CODE_STUBS_ARM_H_ #define V8_ARM_CODE_STUBS_ARM_H_
#include "src/code-stubs.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -73,8 +71,6 @@ class WriteInt32ToHeapNumberStub : public PlatformCodeStub { ...@@ -73,8 +71,6 @@ class WriteInt32ToHeapNumberStub : public PlatformCodeStub {
static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate); static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate);
private: private:
virtual inline Major MajorKey() const FINAL OVERRIDE;
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
Register the_int() const { Register the_int() const {
...@@ -94,7 +90,7 @@ class WriteInt32ToHeapNumberStub : public PlatformCodeStub { ...@@ -94,7 +90,7 @@ class WriteInt32ToHeapNumberStub : public PlatformCodeStub {
class HeapNumberRegisterBits: public BitField<int, 4, 4> {}; class HeapNumberRegisterBits: public BitField<int, 4, 4> {};
class ScratchRegisterBits: public BitField<int, 8, 4> {}; class ScratchRegisterBits: public BitField<int, 8, 4> {};
DISALLOW_COPY_AND_ASSIGN(WriteInt32ToHeapNumberStub); DEFINE_CODE_STUB(WriteInt32ToHeapNumber, PlatformCodeStub);
}; };
...@@ -117,6 +113,9 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -117,6 +113,9 @@ class RecordWriteStub: public PlatformCodeStub {
SaveFPRegsModeBits::encode(fp_mode); SaveFPRegsModeBits::encode(fp_mode);
} }
RecordWriteStub(uint32_t key, Isolate* isolate)
: PlatformCodeStub(key, isolate), regs_(object(), address(), value()) {}
enum Mode { enum Mode {
STORE_BUFFER_ONLY, STORE_BUFFER_ONLY,
INCREMENTAL, INCREMENTAL,
...@@ -244,7 +243,7 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -244,7 +243,7 @@ class RecordWriteStub: public PlatformCodeStub {
kUpdateRememberedSetOnNoNeedToInformIncrementalMarker kUpdateRememberedSetOnNoNeedToInformIncrementalMarker
}; };
virtual inline Major MajorKey() const FINAL OVERRIDE; virtual inline Major MajorKey() const FINAL OVERRIDE { return RecordWrite; }
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
void GenerateIncremental(MacroAssembler* masm, Mode mode); void GenerateIncremental(MacroAssembler* masm, Mode mode);
...@@ -303,11 +302,9 @@ class DirectCEntryStub: public PlatformCodeStub { ...@@ -303,11 +302,9 @@ class DirectCEntryStub: public PlatformCodeStub {
void GenerateCall(MacroAssembler* masm, Register target); void GenerateCall(MacroAssembler* masm, Register target);
private: private:
virtual inline Major MajorKey() const FINAL OVERRIDE;
bool NeedsImmovableCode() { return true; } bool NeedsImmovableCode() { return true; }
DISALLOW_COPY_AND_ASSIGN(DirectCEntryStub); DEFINE_CODE_STUB(DirectCEntry, PlatformCodeStub);
}; };
...@@ -352,13 +349,11 @@ class NameDictionaryLookupStub: public PlatformCodeStub { ...@@ -352,13 +349,11 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
NameDictionary::kHeaderSize + NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize; NameDictionary::kElementsStartIndex * kPointerSize;
virtual inline Major MajorKey() const FINAL OVERRIDE;
LookupMode mode() const { return LookupModeBits::decode(minor_key_); } LookupMode mode() const { return LookupModeBits::decode(minor_key_); }
class LookupModeBits: public BitField<LookupMode, 0, 1> {}; class LookupModeBits: public BitField<LookupMode, 0, 1> {};
DISALLOW_COPY_AND_ASSIGN(NameDictionaryLookupStub); DEFINE_CODE_STUB(NameDictionaryLookup, PlatformCodeStub);
}; };
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef V8_ARM64_CODE_STUBS_ARM64_H_ #ifndef V8_ARM64_CODE_STUBS_ARM64_H_
#define V8_ARM64_CODE_STUBS_ARM64_H_ #define V8_ARM64_CODE_STUBS_ARM64_H_
#include "src/code-stubs.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -48,11 +46,9 @@ class StoreRegistersStateStub: public PlatformCodeStub { ...@@ -48,11 +46,9 @@ class StoreRegistersStateStub: public PlatformCodeStub {
static void GenerateAheadOfTime(Isolate* isolate); static void GenerateAheadOfTime(Isolate* isolate);
private: private:
virtual inline Major MajorKey() const FINAL OVERRIDE;
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
DISALLOW_COPY_AND_ASSIGN(StoreRegistersStateStub); DEFINE_CODE_STUB(StoreRegistersState, PlatformCodeStub);
}; };
...@@ -64,11 +60,9 @@ class RestoreRegistersStateStub: public PlatformCodeStub { ...@@ -64,11 +60,9 @@ class RestoreRegistersStateStub: public PlatformCodeStub {
static void GenerateAheadOfTime(Isolate* isolate); static void GenerateAheadOfTime(Isolate* isolate);
private: private:
virtual inline Major MajorKey() const FINAL OVERRIDE;
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
DISALLOW_COPY_AND_ASSIGN(RestoreRegistersStateStub); DEFINE_CODE_STUB(RestoreRegistersState, PlatformCodeStub);
}; };
...@@ -97,6 +91,9 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -97,6 +91,9 @@ class RecordWriteStub: public PlatformCodeStub {
SaveFPRegsModeBits::encode(fp_mode); SaveFPRegsModeBits::encode(fp_mode);
} }
RecordWriteStub(uint32_t key, Isolate* isolate)
: PlatformCodeStub(key, isolate), regs_(object(), address(), value()) {}
enum Mode { enum Mode {
STORE_BUFFER_ONLY, STORE_BUFFER_ONLY,
INCREMENTAL, INCREMENTAL,
...@@ -279,7 +276,7 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -279,7 +276,7 @@ class RecordWriteStub: public PlatformCodeStub {
kUpdateRememberedSetOnNoNeedToInformIncrementalMarker kUpdateRememberedSetOnNoNeedToInformIncrementalMarker
}; };
virtual inline Major MajorKey() const FINAL OVERRIDE; virtual inline Major MajorKey() const FINAL OVERRIDE { return RecordWrite; }
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
void GenerateIncremental(MacroAssembler* masm, Mode mode); void GenerateIncremental(MacroAssembler* masm, Mode mode);
...@@ -333,11 +330,9 @@ class DirectCEntryStub: public PlatformCodeStub { ...@@ -333,11 +330,9 @@ class DirectCEntryStub: public PlatformCodeStub {
void GenerateCall(MacroAssembler* masm, Register target); void GenerateCall(MacroAssembler* masm, Register target);
private: private:
virtual inline Major MajorKey() const FINAL OVERRIDE;
bool NeedsImmovableCode() { return true; } bool NeedsImmovableCode() { return true; }
DISALLOW_COPY_AND_ASSIGN(DirectCEntryStub); DEFINE_CODE_STUB(DirectCEntry, PlatformCodeStub);
}; };
...@@ -382,13 +377,11 @@ class NameDictionaryLookupStub: public PlatformCodeStub { ...@@ -382,13 +377,11 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
NameDictionary::kHeaderSize + NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize; NameDictionary::kElementsStartIndex * kPointerSize;
virtual inline Major MajorKey() const FINAL OVERRIDE;
LookupMode mode() const { return LookupModeBits::decode(minor_key_); } LookupMode mode() const { return LookupModeBits::decode(minor_key_); }
class LookupModeBits: public BitField<LookupMode, 0, 1> {}; class LookupModeBits: public BitField<LookupMode, 0, 1> {};
DISALLOW_COPY_AND_ASSIGN(NameDictionaryLookupStub); DEFINE_CODE_STUB(NameDictionaryLookup, PlatformCodeStub);
}; };
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -317,7 +317,7 @@ bool CompareICStub::FindCodeInSpecialCache(Code** code_out) { ...@@ -317,7 +317,7 @@ bool CompareICStub::FindCodeInSpecialCache(Code** code_out) {
if (probe->IsCode()) { if (probe->IsCode()) {
*code_out = Code::cast(*probe); *code_out = Code::cast(*probe);
#ifdef DEBUG #ifdef DEBUG
CompareICStub decode((*code_out)->stub_key()); CompareICStub decode((*code_out)->stub_key(), isolate());
DCHECK(op() == decode.op()); DCHECK(op() == decode.op());
DCHECK(left() == decode.left()); DCHECK(left() == decode.left());
DCHECK(right() == decode.right()); DCHECK(right() == decode.right());
......
This diff is collapsed.
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef V8_IA32_CODE_STUBS_IA32_H_ #ifndef V8_IA32_CODE_STUBS_IA32_H_
#define V8_IA32_CODE_STUBS_IA32_H_ #define V8_IA32_CODE_STUBS_IA32_H_
#include "src/code-stubs.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -99,8 +97,6 @@ class NameDictionaryLookupStub: public PlatformCodeStub { ...@@ -99,8 +97,6 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
NameDictionary::kHeaderSize + NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize; NameDictionary::kElementsStartIndex * kPointerSize;
virtual inline Major MajorKey() const FINAL OVERRIDE;
Register dictionary() const { Register dictionary() const {
return Register::from_code(DictionaryBits::decode(minor_key_)); return Register::from_code(DictionaryBits::decode(minor_key_));
} }
...@@ -120,7 +116,7 @@ class NameDictionaryLookupStub: public PlatformCodeStub { ...@@ -120,7 +116,7 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
class IndexBits: public BitField<int, 6, 3> {}; class IndexBits: public BitField<int, 6, 3> {};
class LookupModeBits: public BitField<LookupMode, 9, 1> {}; class LookupModeBits: public BitField<LookupMode, 9, 1> {};
DISALLOW_COPY_AND_ASSIGN(NameDictionaryLookupStub); DEFINE_CODE_STUB(NameDictionaryLookup, PlatformCodeStub);
}; };
...@@ -143,6 +139,9 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -143,6 +139,9 @@ class RecordWriteStub: public PlatformCodeStub {
SaveFPRegsModeBits::encode(fp_mode); SaveFPRegsModeBits::encode(fp_mode);
} }
RecordWriteStub(uint32_t key, Isolate* isolate)
: PlatformCodeStub(key, isolate), regs_(object(), address(), value()) {}
enum Mode { enum Mode {
STORE_BUFFER_ONLY, STORE_BUFFER_ONLY,
INCREMENTAL, INCREMENTAL,
...@@ -344,7 +343,7 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -344,7 +343,7 @@ class RecordWriteStub: public PlatformCodeStub {
kUpdateRememberedSetOnNoNeedToInformIncrementalMarker kUpdateRememberedSetOnNoNeedToInformIncrementalMarker
}; };
virtual inline Major MajorKey() const FINAL OVERRIDE; virtual inline Major MajorKey() const FINAL OVERRIDE { return RecordWrite; }
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
void GenerateIncremental(MacroAssembler* masm, Mode mode); void GenerateIncremental(MacroAssembler* masm, Mode mode);
......
...@@ -550,7 +550,7 @@ void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target, ...@@ -550,7 +550,7 @@ void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target,
void CompareIC::Clear(Isolate* isolate, Address address, Code* target, void CompareIC::Clear(Isolate* isolate, Address address, Code* target,
ConstantPoolArray* constant_pool) { ConstantPoolArray* constant_pool) {
DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC); DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC);
CompareICStub stub(target->stub_key()); CompareICStub stub(target->stub_key(), isolate);
// Only clear CompareICs that can retain objects. // Only clear CompareICs that can retain objects.
if (stub.state() != KNOWN_OBJECT) return; if (stub.state() != KNOWN_OBJECT) return;
SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()), SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()),
...@@ -2762,7 +2762,7 @@ Type* CompareIC::StateToType(Zone* zone, CompareIC::State state, ...@@ -2762,7 +2762,7 @@ Type* CompareIC::StateToType(Zone* zone, CompareIC::State state,
void CompareIC::StubInfoToType(uint32_t stub_key, Type** left_type, void CompareIC::StubInfoToType(uint32_t stub_key, Type** left_type,
Type** right_type, Type** overall_type, Type** right_type, Type** overall_type,
Handle<Map> map, Zone* zone) { Handle<Map> map, Zone* zone) {
CompareICStub stub(stub_key); CompareICStub stub(stub_key, map->GetIsolate());
*left_type = StateToType(zone, stub.left()); *left_type = StateToType(zone, stub.left());
*right_type = StateToType(zone, stub.right()); *right_type = StateToType(zone, stub.right());
*overall_type = StateToType(zone, stub.state(), map); *overall_type = StateToType(zone, stub.state(), map);
...@@ -2875,7 +2875,7 @@ CompareIC::State CompareIC::TargetState(State old_state, State old_left, ...@@ -2875,7 +2875,7 @@ CompareIC::State CompareIC::TargetState(State old_state, State old_left,
Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) {
HandleScope scope(isolate()); HandleScope scope(isolate());
CompareICStub old_stub(target()->stub_key()); CompareICStub old_stub(target()->stub_key(), isolate());
State new_left = NewInputState(old_stub.left(), x); State new_left = NewInputState(old_stub.left(), x);
State new_right = NewInputState(old_stub.right(), y); State new_right = NewInputState(old_stub.right(), y);
State state = TargetState(old_stub.state(), old_stub.left(), old_stub.right(), State state = TargetState(old_stub.state(), old_stub.left(), old_stub.right(),
......
...@@ -10893,7 +10893,7 @@ void Code::Disassemble(const char* name, OStream& os) { // NOLINT ...@@ -10893,7 +10893,7 @@ void Code::Disassemble(const char* name, OStream& os) { // NOLINT
} }
if (is_compare_ic_stub()) { if (is_compare_ic_stub()) {
DCHECK(CodeStub::GetMajorKey(this) == CodeStub::CompareIC); DCHECK(CodeStub::GetMajorKey(this) == CodeStub::CompareIC);
CompareICStub stub(stub_key()); CompareICStub stub(stub_key(), GetIsolate());
os << "compare_state = " << CompareIC::GetStateName(stub.left()) << "*" os << "compare_state = " << CompareIC::GetStateName(stub.left()) << "*"
<< CompareIC::GetStateName(stub.right()) << " -> " << CompareIC::GetStateName(stub.right()) << " -> "
<< CompareIC::GetStateName(stub.state()) << "\n"; << CompareIC::GetStateName(stub.state()) << "\n";
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef V8_X64_CODE_STUBS_X64_H_ #ifndef V8_X64_CODE_STUBS_X64_H_
#define V8_X64_CODE_STUBS_X64_H_ #define V8_X64_CODE_STUBS_X64_H_
#include "src/code-stubs.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -94,8 +92,6 @@ class NameDictionaryLookupStub: public PlatformCodeStub { ...@@ -94,8 +92,6 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
NameDictionary::kHeaderSize + NameDictionary::kHeaderSize +
NameDictionary::kElementsStartIndex * kPointerSize; NameDictionary::kElementsStartIndex * kPointerSize;
virtual inline Major MajorKey() const FINAL OVERRIDE;
Register dictionary() const { Register dictionary() const {
return Register::from_code(DictionaryBits::decode(minor_key_)); return Register::from_code(DictionaryBits::decode(minor_key_));
} }
...@@ -115,7 +111,7 @@ class NameDictionaryLookupStub: public PlatformCodeStub { ...@@ -115,7 +111,7 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
class IndexBits: public BitField<int, 8, 4> {}; class IndexBits: public BitField<int, 8, 4> {};
class LookupModeBits: public BitField<LookupMode, 12, 1> {}; class LookupModeBits: public BitField<LookupMode, 12, 1> {};
DISALLOW_COPY_AND_ASSIGN(NameDictionaryLookupStub); DEFINE_CODE_STUB(NameDictionaryLookup, PlatformCodeStub);
}; };
...@@ -135,6 +131,9 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -135,6 +131,9 @@ class RecordWriteStub: public PlatformCodeStub {
SaveFPRegsModeBits::encode(fp_mode); SaveFPRegsModeBits::encode(fp_mode);
} }
RecordWriteStub(uint32_t key, Isolate* isolate)
: PlatformCodeStub(key, isolate), regs_(object(), address(), value()) {}
enum Mode { enum Mode {
STORE_BUFFER_ONLY, STORE_BUFFER_ONLY,
INCREMENTAL, INCREMENTAL,
...@@ -318,7 +317,7 @@ class RecordWriteStub: public PlatformCodeStub { ...@@ -318,7 +317,7 @@ class RecordWriteStub: public PlatformCodeStub {
kUpdateRememberedSetOnNoNeedToInformIncrementalMarker kUpdateRememberedSetOnNoNeedToInformIncrementalMarker
}; };
virtual inline Major MajorKey() const FINAL OVERRIDE; virtual Major MajorKey() const FINAL OVERRIDE { return RecordWrite; }
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
void GenerateIncremental(MacroAssembler* masm, Mode mode); void GenerateIncremental(MacroAssembler* masm, Mode mode);
......
...@@ -172,3 +172,19 @@ void RunAllTruncationTests(ConvertDToICallWrapper callWrapper, ...@@ -172,3 +172,19 @@ void RunAllTruncationTests(ConvertDToICallWrapper callWrapper,
#undef NaN #undef NaN
#undef Infinity #undef Infinity
#undef RunOneTruncationTest #undef RunOneTruncationTest
TEST(CodeStubMajorKeys) {
CcTest::InitializeVM();
LocalContext context;
Isolate* isolate = CcTest::i_isolate();
#define CHECK_STUB(NAME) \
{ \
HandleScope scope(isolate); \
NAME##Stub stub_impl(0xabcd, isolate); \
CodeStub* stub = &stub_impl; \
CHECK_EQ(stub->MajorKey(), CodeStub::NAME); \
}
CODE_STUB_LIST(CHECK_STUB);
}
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