Get rid of ContextualMode for call ICs.

BUG=
R=mvstanton@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18594 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2014-01-14 16:15:05 +00:00
parent cfcb201367
commit 53f46c5214
18 changed files with 41 additions and 73 deletions

View File

@ -2614,8 +2614,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
// Record source position for debugger.
SetSourcePosition(expr->position());
// Call the IC initialization code.
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
TypeFeedbackId ast_id = mode == CONTEXTUAL
? TypeFeedbackId::None()
: expr->CallFeedbackId();
@ -4155,10 +4154,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
if (expr->is_jsruntime()) {
// Call the JS runtime function.
__ mov(r2, Operand(expr->name()));
ContextualMode mode = NOT_CONTEXTUAL;
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
CallIC(ic, mode, expr->CallRuntimeFeedbackId());
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
// Restore context register.
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
} else {

View File

@ -3986,8 +3986,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) {
ASSERT(ToRegister(instr->result()).is(r0));
int arity = instr->arity();
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
__ mov(r2, Operand(instr->name()));
CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
}
@ -4014,8 +4013,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
ASSERT(ToRegister(instr->result()).is(r0));
int arity = instr->arity();
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
__ mov(r2, Operand(instr->name()));
CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
}

View File

@ -696,8 +696,7 @@ Handle<JSObject> Call::GetPrototypeForPrimitiveCheck(
}
void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle,
ContextualMode contextual_mode) {
void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackId());
Property* property = expression()->AsProperty();
if (property == NULL) {
@ -712,7 +711,7 @@ void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle,
receiver_types_.Clear();
if (check_type_ == RECEIVER_MAP_CHECK) {
oracle->CallReceiverTypes(CallFeedbackId(),
name, arguments()->length(), contextual_mode, &receiver_types_);
name, arguments()->length(), &receiver_types_);
is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0;
} else {
holder_ = GetPrototypeForPrimitiveCheck(check_type_, oracle->isolate());

View File

@ -1737,8 +1737,7 @@ class Call V8_FINAL : public Expression {
// Type feedback information.
TypeFeedbackId CallFeedbackId() const { return reuse(id()); }
void RecordTypeFeedback(TypeFeedbackOracle* oracle,
ContextualMode contextual_mode);
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
return &receiver_types_;
}

View File

@ -2569,7 +2569,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
// Record source position of the IC call.
SetSourcePosition(expr->position());
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
isolate()->stub_cache()->ComputeCallInitialize(arg_count);
TypeFeedbackId ast_id = mode == CONTEXTUAL
? TypeFeedbackId::None()
: expr->CallFeedbackId();
@ -4146,10 +4146,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
if (expr->is_jsruntime()) {
// Call the JS runtime function via a call IC.
__ Set(ecx, Immediate(expr->name()));
ContextualMode mode = NOT_CONTEXTUAL;
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
CallIC(ic, mode, expr->CallRuntimeFeedbackId());
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
// Restore context register.
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
} else {

View File

@ -4229,8 +4229,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) {
ASSERT(ToRegister(instr->result()).is(eax));
int arity = instr->arity();
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
__ mov(ecx, instr->name());
CallCode(ic, RelocInfo::CODE_TARGET, instr);
}
@ -4257,8 +4256,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
ASSERT(ToRegister(instr->result()).is(eax));
int arity = instr->arity();
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
__ mov(ecx, instr->name());
CallCode(ic, RelocInfo::CODE_TARGET, instr);
}

View File

@ -489,9 +489,8 @@ void IC::Clear(Isolate* isolate, Address address) {
void CallICBase::Clear(Address address, Code* target) {
if (IsCleared(target)) return;
ContextualMode mode = IC::GetContextualMode(target->extra_ic_state());
Code* code = target->GetIsolate()->stub_cache()->FindCallInitialize(
target->arguments_count(), mode, target->kind());
target->arguments_count(), target->kind());
SetTargetAtAddress(address, code);
}

View File

@ -124,7 +124,7 @@ class IC {
// access to properties.
bool IsUndeclaredGlobal(Handle<Object> receiver) {
if (receiver->IsGlobalObject()) {
return IsContextual();
return IsCallStub() || IsContextual();
} else {
ASSERT(!IsContextual());
return false;
@ -140,10 +140,10 @@ class IC {
return target()->is_store_stub() || target()->is_keyed_store_stub();
}
#endif
bool IsCallStub() {
return target()->is_call_stub() || target()->is_keyed_call_stub();
}
#endif
// Determines which map must be used for keeping the code stub.
// These methods should not be called with undefined or null.
@ -323,10 +323,9 @@ enum StringStubFeedback {
class CallICBase: public IC {
public:
// ExtraICState bits
class StringStubState: public BitField<StringStubFeedback, 1, 1> {};
static ExtraICState ComputeExtraICState(ContextualMode mode,
StringStubFeedback feedback) {
return Contextual::encode(mode) | StringStubState::encode(feedback);
class StringStubState: public BitField<StringStubFeedback, 0, 1> {};
static ExtraICState ComputeExtraICState(StringStubFeedback feedback) {
return StringStubState::encode(feedback);
}
// Returns a JSFunction or a Failure.

View File

@ -418,12 +418,9 @@ static void FillCache(Isolate* isolate, Handle<Code> code) {
}
Code* StubCache::FindCallInitialize(int argc,
ContextualMode mode,
Code::Kind kind) {
Code* StubCache::FindCallInitialize(int argc, Code::Kind kind) {
ExtraICState extra_state =
CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) |
CallICBase::Contextual::encode(mode);
CallICBase::StringStubState::encode(DEFAULT_STRING_STUB);
Code::Flags flags =
Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc);
UnseededNumberDictionary* dictionary =
@ -450,11 +447,9 @@ Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) {
}
Handle<Code> StubCache::ComputeCallInitialize(int argc,
ContextualMode mode,
Code::Kind kind) {
Handle<Code> StubCache::ComputeCallInitialize(int argc, Code::Kind kind) {
ExtraICState extra_state =
CallICBase::ComputeExtraICState(mode, DEFAULT_STRING_STUB);
CallICBase::ComputeExtraICState(DEFAULT_STRING_STUB);
Code::Flags flags =
Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc);
Handle<UnseededNumberDictionary> cache =
@ -469,13 +464,13 @@ Handle<Code> StubCache::ComputeCallInitialize(int argc,
}
Handle<Code> StubCache::ComputeCallInitialize(int argc, ContextualMode mode) {
return ComputeCallInitialize(argc, mode, Code::CALL_IC);
Handle<Code> StubCache::ComputeCallInitialize(int argc) {
return ComputeCallInitialize(argc, Code::CALL_IC);
}
Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) {
return ComputeCallInitialize(argc, NOT_CONTEXTUAL, Code::KEYED_CALL_IC);
return ComputeCallInitialize(argc, Code::KEYED_CALL_IC);
}

View File

@ -138,7 +138,7 @@ class StubCache {
// ---
Handle<Code> ComputeCallInitialize(int argc, ContextualMode mode);
Handle<Code> ComputeCallInitialize(int argc);
Handle<Code> ComputeKeyedCallInitialize(int argc);
@ -185,7 +185,7 @@ class StubCache {
ExtraICState extra_ic_state);
// Finds the Code object stored in the Heap::non_monomorphic_cache().
Code* FindCallInitialize(int argc, ContextualMode mode, Code::Kind kind);
Code* FindCallInitialize(int argc, Code::Kind kind);
Code* FindPreMonomorphicIC(Code::Kind kind, ExtraICState extra_ic_state);
#ifdef ENABLE_DEBUGGER_SUPPORT
@ -269,9 +269,7 @@ class StubCache {
private:
explicit StubCache(Isolate* isolate);
Handle<Code> ComputeCallInitialize(int argc,
ContextualMode mode,
Code::Kind kind);
Handle<Code> ComputeCallInitialize(int argc, Code::Kind kind);
// The stub cache has a primary and secondary level. The two levels have
// different hashing algorithms in order to avoid simultaneous collisions

View File

@ -178,14 +178,11 @@ KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode(
void TypeFeedbackOracle::CallReceiverTypes(TypeFeedbackId id,
Handle<String> name,
int arity,
ContextualMode contextual_mode,
SmallMapList* types) {
// Note: Currently we do not take string extra ic data into account
// here.
ExtraICState extra_ic_state =
CallIC::Contextual::encode(contextual_mode);
Code::Flags flags = Code::ComputeMonomorphicFlags(
Code::CALL_IC, extra_ic_state, OWN_MAP, Code::NORMAL, arity);
Code::CALL_IC, kNoExtraICState, OWN_MAP, Code::NORMAL, arity);
CollectReceiverTypes(id, name, flags, types);
}

View File

@ -68,7 +68,6 @@ class TypeFeedbackOracle: public ZoneObject {
void CallReceiverTypes(TypeFeedbackId id,
Handle<String> name,
int arity,
ContextualMode contextual_mode,
SmallMapList* types);
void PropertyReceiverTypes(TypeFeedbackId id,
Handle<String> name,

View File

@ -530,11 +530,8 @@ void AstTyper::VisitProperty(Property* expr) {
void AstTyper::VisitCall(Call* expr) {
Expression* callee = expr->expression();
Property* prop = callee->AsProperty();
ContextualMode contextual_mode = prop == NULL ? CONTEXTUAL : NOT_CONTEXTUAL;
// Collect type feedback.
expr->RecordTypeFeedback(oracle(), contextual_mode);
expr->RecordTypeFeedback(oracle());
RECURSE(Visit(expr->expression()));
ZoneList<Expression*>* args = expr->arguments();

View File

@ -2551,8 +2551,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
// Record source position for debugger.
SetSourcePosition(expr->position());
// Call the IC initialization code.
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
TypeFeedbackId ast_id = mode == CONTEXTUAL
? TypeFeedbackId::None()
: expr->CallFeedbackId();
@ -4150,10 +4149,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
if (expr->is_jsruntime()) {
// Call the JS runtime function using a call IC.
__ Move(rcx, expr->name());
ContextualMode mode = NOT_CONTEXTUAL;
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
CallIC(ic, mode, expr->CallRuntimeFeedbackId());
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
// Restore context register.
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
} else {

View File

@ -3801,8 +3801,7 @@ void LCodeGen::DoCallNamed(LCallNamed* instr) {
ASSERT(ToRegister(instr->result()).is(rax));
int arity = instr->arity();
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
__ Move(rcx, instr->name());
CallCode(ic, RelocInfo::CODE_TARGET, instr);
}
@ -3828,8 +3827,7 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
ASSERT(ToRegister(instr->context()).is(rsi));
ASSERT(ToRegister(instr->result()).is(rax));
int arity = instr->arity();
Handle<Code> ic =
isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity);
__ Move(rcx, instr->name());
CallCode(ic, RelocInfo::CODE_TARGET, instr);
}

View File

@ -3090,7 +3090,7 @@ TEST(Regression144230) {
HandleScope inner_scope(isolate);
AlwaysAllocateScope always_allocate;
SimulateFullSpace(heap->code_space());
isolate->stub_cache()->ComputeCallInitialize(9, NOT_CONTEXTUAL);
isolate->stub_cache()->ComputeCallInitialize(9);
}
// Second compile a CallIC and execute it once so that it gets patched to

View File

@ -27,6 +27,6 @@
// Flags: --allow-natives-syntax
assertThrows("%foobar();", TypeError);
assertThrows("%constructor();", TypeError);
assertThrows("%constructor(23);", TypeError);
assertThrows("%foobar();", Error);
assertThrows("%constructor();", Error);
assertThrows("%constructor(23);", Error);

View File

@ -28,5 +28,5 @@
// Flags: --allow-natives-syntax
assertThrows("f()", ReferenceError);
assertThrows("%f()", TypeError);
assertThrows("%f()", Error);
assertThrows("%_f()", SyntaxError);