Chromium Code Reviews| Index: src/ic.h |
| diff --git a/src/ic.h b/src/ic.h |
| index 7d3547134fccfa1372f32c4096b9cb6ff899de1e..10098300df9847547e0ea47e410a52ee14f012d3 100644 |
| --- a/src/ic.h |
| +++ b/src/ic.h |
| @@ -42,6 +42,7 @@ const int kMaxKeyedPolymorphism = 4; |
| #define IC_UTIL_LIST(ICU) \ |
| ICU(LoadIC_Miss) \ |
| ICU(KeyedLoadIC_Miss) \ |
| + ICU(CallIC_Miss) \ |
| ICU(StoreIC_Miss) \ |
| ICU(StoreIC_ArrayLength) \ |
| ICU(StoreIC_Slow) \ |
| @@ -113,6 +114,10 @@ class IC { |
| bool IsStoreStub() const { |
| return target()->is_store_stub() || target()->is_keyed_store_stub(); |
| } |
| + |
| + bool IsCallStub() const { |
| + return target()->is_call_stub(); |
| + } |
| #endif |
| // Determines which map must be used for keeping the code stub. |
| @@ -301,6 +306,129 @@ class IC_Utility { |
| }; |
| +class CallIC: public IC { |
| + public: |
| + enum CallType { METHOD, FUNCTION }; |
| + enum StubType { DEFAULT, MONOMORPHIC }; |
| + enum ArgumentCheck { ARGUMENTS_MUST_MATCH, ARGUMENTS_COUNT_UNKNOWN }; |
| + enum FunctionAttributes { SLOPPY_OR_NONNATIVE, STRICT_OR_NATIVE }; |
|
Toon Verwaest
2014/03/27 16:02:25
SLOPPY_NONNATIVE
mvstanton
2014/04/01 13:01:49
Done.
|
| + |
| + class State V8_FINAL BASE_EMBEDDED { |
| + public: |
| + explicit State(ExtraICState extra_ic_state); |
| + |
| + static State MonomorphicCallState(int argc, CallType call_type, |
| + ArgumentCheck argument_check, |
| + FunctionAttributes attributes) { |
| + return State(argc, call_type, MONOMORPHIC, argument_check, attributes); |
| + } |
| + |
| + static State SlowCallState(int argc, CallType call_type) { |
| + return State(argc, call_type, DEFAULT, ARGUMENTS_COUNT_UNKNOWN, |
| + SLOPPY_OR_NONNATIVE); |
| + } |
| + |
| + static State DefaultCallState(int argc, CallType call_type) { |
| + return State(argc, call_type, DEFAULT, ARGUMENTS_MUST_MATCH, |
| + SLOPPY_OR_NONNATIVE); |
| + } |
| + |
| + // Transition from the current state to another. |
| + State ToGenericState(); |
| + State ToMonomorphicState(Handle<JSFunction> function); |
| + |
| + InlineCacheState GetICState() const { |
| + return stub_type_ == CallIC::MONOMORPHIC |
| + ? ::v8::internal::MONOMORPHIC |
| + : ::v8::internal::GENERIC; |
| + } |
| + |
| + ExtraICState GetExtraICState() const; |
| + |
| + static void GenerateAheadOfTime( |
| + Isolate*, void (*Generate)(Isolate*, const State&)); |
| + |
| + int arg_count() const { return argc_; } |
| + CallType call_type() const { return call_type_; } |
| + StubType stub_type() const { return stub_type_; } |
| + ArgumentCheck argument_check() const { return argument_check_; } |
| + FunctionAttributes function_attributes() const { |
| + return function_attributes_; |
| + } |
| + |
| + bool ArgumentsMustMatch() const { |
| + return argument_check_ == ARGUMENTS_MUST_MATCH; |
| + } |
| + bool IsGeneric() const { return stub_type_ == DEFAULT; } |
| + bool CallAsMethod() const { return call_type_ == METHOD; } |
| + bool IsSloppyOrNonNative() const { |
| + return function_attributes_ == SLOPPY_OR_NONNATIVE; |
| + } |
| + |
| + void Print(StringStream* stream) const; |
| + |
| + bool operator==(const State& other_state) const { |
| + return (argc_ == other_state.argc_ && |
| + call_type_ == other_state.call_type_ && |
| + stub_type_ == other_state.stub_type_ && |
| + argument_check_ == other_state.argument_check_ && |
| + function_attributes_ == other_state.function_attributes_); |
| + } |
| + |
| + bool operator!=(const State& other_state) const { |
| + return !(*this == other_state); |
| + } |
| + |
| + private: |
| + State(int argc, |
| + CallType call_type, |
| + StubType stub_type, |
| + ArgumentCheck argument_check, |
| + FunctionAttributes attributes) |
| + : argc_(argc), |
| + call_type_(call_type), |
| + stub_type_(stub_type), |
| + argument_check_(argument_check), |
| + function_attributes_(attributes) { |
| + } |
| + |
| + class ArgBits: public BitField<int, 0, Code::kArgumentsBits> {}; |
|
Toon Verwaest
2014/03/27 16:02:25
Arg or ArgcBits? Just make sure it's consistent ev
mvstanton
2014/04/01 13:01:49
Done, I went with ArgcBits.
|
| + class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {}; |
| + class StubTypeBits: |
| + public BitField<StubType, Code::kArgumentsBits + 1, 1> {}; // NOLINT |
| + class ArgumentCheckBits: |
| + public BitField<ArgumentCheck, |
| + Code::kArgumentsBits + 2, 1> {}; // NOLINT |
| + class FunctionAttributeBits: |
| + public BitField<FunctionAttributes, |
| + Code::kArgumentsBits + 3, 1> {}; // NOLINT |
| + |
| + const int argc_; |
| + const CallType call_type_; |
| + const StubType stub_type_; |
| + const ArgumentCheck argument_check_; |
| + const FunctionAttributes function_attributes_; |
| + }; |
| + |
| + explicit CallIC(Isolate* isolate) |
| + : IC(EXTRA_CALL_FRAME, isolate) { |
| + } |
| + |
| + void HandleMiss(Handle<Object> receiver, |
| + Handle<Object> function, |
| + Handle<FixedArray> vector, |
| + Handle<Smi> slot); |
| + |
| + // Code generator routines. |
| + static Handle<Code> initialize_stub(Isolate* isolate, |
| + int argc, |
| + CallType call_type); |
| + |
| + static void Clear(Isolate* isolate, Address address, Code* target, |
| + ConstantPoolArray* constant_pool); |
| +}; |
| + |
| + |
| class LoadIC: public IC { |
| public: |
| // ExtraICState bits |