Reviewers: danno, Toon Verwaest, Jakob,
Message:
Hi guys,
Could you have a quick look at this structure for declaring a register
specification in the IC? Thanks!
--Michael
ps - Jakob, I know I'm not solving the issue of (proliferating) static
initializers yet, but I will think about how to do that.
Description:
Create a RegisterSpec class inside of the IC that provides:
1) symbolic names for the register (like, edx == receiver)
2) can return an array of registers
3) defines ordering when passed on the stack
Code that implements or uses the IC should use this RegisterSpec instead of
"knowing" what the registers are. Or at least have the RegisterSpec to
validate
it's assumptions.
Please review this at https://codereview.chromium.org/340363002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+63, -11 lines):
M src/ia32/code-stubs-ia32.cc
M src/ia32/ic-ia32.cc
M src/ia32/stub-cache-ia32.cc
M src/ic.h
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index
e61d22138f18d6bda780ec9bc66e0c1ad6d5926a..845acaa1336e933d55b649c35ba7a38578771486
100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -95,9 +95,9 @@ void
CreateAllocationSiteStub::InitializeInterfaceDescriptor(
void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
- static Register registers[] = { edx, ecx };
- descriptor->register_param_count_ = 2;
- descriptor->register_params_ = registers;
+ const KeyedLoadIC::RegisterSpec& spec = KeyedLoadIC::GetRegisterSpec();
+ descriptor->register_param_count_ = spec.count();
+ descriptor->register_params_ = spec.registers();
descriptor->deoptimization_handler_ =
FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure);
}
@@ -105,9 +105,9 @@ void
KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
- static Register registers[] = { edx, ecx };
- descriptor->register_param_count_ = 2;
- descriptor->register_params_ = registers;
+ const KeyedLoadIC::RegisterSpec& spec = KeyedLoadIC::GetRegisterSpec();
+ descriptor->register_param_count_ = spec.count();
+ descriptor->register_params_ = spec.registers();
descriptor->deoptimization_handler_ =
FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure);
}
@@ -125,9 +125,9 @@ void
RegExpConstructResultStub::InitializeInterfaceDescriptor(
void KeyedLoadGenericElementStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
- static Register registers[] = { edx, ecx };
- descriptor->register_param_count_ = 2;
- descriptor->register_params_ = registers;
+ const KeyedLoadIC::RegisterSpec& spec = KeyedLoadIC::GetRegisterSpec();
+ descriptor->register_param_count_ = spec.count();
+ descriptor->register_params_ = spec.registers();
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry;
}
Index: src/ia32/ic-ia32.cc
diff --git a/src/ia32/ic-ia32.cc b/src/ia32/ic-ia32.cc
index
b0e4ca0c60c2675899383b5a0fd95fe16546115d..821af599cf6e8f4250feda294fedff28eb59378b
100644
--- a/src/ia32/ic-ia32.cc
+++ b/src/ia32/ic-ia32.cc
@@ -1024,6 +1024,8 @@ void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) {
__ TailCallExternalReference(ref, 2, 1);
}
+DEFINE_REGISTER_SPEC_REGS2(LoadIC, edx, ecx)
+DEFINE_REGISTER_SPEC_REGS2(KeyedLoadIC, edx, ecx)
void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
// ----------- S t a t e -------------
Index: src/ia32/stub-cache-ia32.cc
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
index
49270196f2c40dc7bdc603d170e59407d46f6e46..bd17dbdf02bc5bd8486f2a8fb2910172e7214da0
100644
--- a/src/ia32/stub-cache-ia32.cc
+++ b/src/ia32/stub-cache-ia32.cc
@@ -1283,14 +1283,18 @@ Handle<Code>
LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
Register* LoadStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3, scratch4.
- static Register registers[] = { edx, ecx, ebx, eax, edi, no_reg };
+ const LoadIC::RegisterSpec& spec = LoadIC::GetRegisterSpec();
+ static Register registers[] = { spec.receiver(), spec.name(), ebx, eax,
edi,
+ no_reg };
return registers;
}
Register* KeyedLoadStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3, scratch4.
- static Register registers[] = { edx, ecx, ebx, eax, edi, no_reg };
+ const LoadIC::RegisterSpec& spec = LoadIC::GetRegisterSpec();
+ static Register registers[] = { spec.receiver(), spec.name(), ebx, eax,
edi,
+ no_reg };
return registers;
}
Index: src/ic.h
diff --git a/src/ic.h b/src/ic.h
index
3f550438a487849c8931dc6d87f7b51d8b125405..6d56ef56643c46f42f4b1ab40ff34fa6cbbdf760
100644
--- a/src/ic.h
+++ b/src/ic.h
@@ -392,12 +392,56 @@ class CallIC: public IC {
};
+class ICRegisterSpec {
+ public:
+ ICRegisterSpec(Register* regs, int count) :
+ regs_(regs), count_(count) { }
+ ICRegisterSpec() : regs_(NULL), count_(-1) { }
+
+ Register* registers() const { return regs_; }
+ Register reg(int index) const {
+ ASSERT(index >=0 && index < count());
+ return regs_[index];
+ }
+ int count() const { return count_; }
+
+ protected:
+ Register* regs_;
+ int count_;
+};
+
+#define DECLARE_IC_ARGUMENT(name, index) \
+ int name##_index() const { return (index); } \
+ Register name() const { return reg(name##_index()); }
+
+#define REGISTER_SPEC_ARG2(arg0, arg1) \
+ class RegisterSpec : public ICRegisterSpec { \
+ public: \
+ RegisterSpec(Register arg0, Register arg1) { \
+ static Register regs[] = { arg0, arg1 }; \
+ regs_ = regs; count_ = 2; \
+ } \
+ DECLARE_IC_ARGUMENT(arg0, 0) \
+ DECLARE_IC_ARGUMENT(arg1, 1) \
+ }; \
+ static const RegisterSpec& GetRegisterSpec()
+
+
+#define DEFINE_REGISTER_SPEC_REGS2(ic_name, reg0, reg1)
\
+ const ic_name::RegisterSpec& ic_name::GetRegisterSpec() {
\
+ static const ic_name::RegisterSpec spec(reg0, reg1);
\
+ return spec;
\
+ }
+
+
class LoadIC: public IC {
public:
// ExtraICState bits
class ContextualModeBits: public BitField<ContextualMode, 0, 1> {};
STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0);
+ REGISTER_SPEC_ARG2(receiver, name);
+
static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) {
return ContextualModeBits::encode(contextual_mode);
}
@@ -498,6 +542,8 @@ class KeyedLoadIC: public LoadIC {
ASSERT(target()->is_keyed_load_stub());
}
+ REGISTER_SPEC_ARG2(receiver, index);
+
MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
Handle<Object> key);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.