Compute correct contextual load ICs in fullcodegen.

BUG=
R=dcarney@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26941}
This commit is contained in:
Toon Verwaest 2015-03-02 14:36:38 +01:00
parent 1fcedda668
commit 7ee31a2348
10 changed files with 58 additions and 4 deletions

View File

@ -1529,7 +1529,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
__ mov(VectorLoadICDescriptor::SlotRegister(),
Operand(SmiFromSlot(proxy->VariableFeedbackSlot())));
}
CallLoadIC(CONTEXTUAL);
CallGlobalLoadIC(var->name());
context()->Plug(r0);
break;
}

View File

@ -1508,7 +1508,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
__ Mov(VectorLoadICDescriptor::SlotRegister(),
SmiFromSlot(proxy->VariableFeedbackSlot()));
}
CallLoadIC(CONTEXTUAL);
CallGlobalLoadIC(var->name());
context()->Plug(x0);
break;
}

View File

@ -11,6 +11,15 @@
namespace v8 {
namespace internal {
// static
Callable CodeFactory::LoadGlobalIC(Isolate* isolate,
Handle<GlobalObject> global,
Handle<String> name) {
return Callable(LoadIC::load_global(isolate, global, name),
LoadDescriptor(isolate));
}
// static
Callable CodeFactory::LoadIC(Isolate* isolate, ContextualMode mode) {
return Callable(

View File

@ -32,6 +32,8 @@ class Callable FINAL BASE_EMBEDDED {
class CodeFactory FINAL {
public:
// Initial states for ICs.
static Callable LoadGlobalIC(Isolate* isolate, Handle<GlobalObject> global,
Handle<String> name);
static Callable LoadIC(Isolate* isolate, ContextualMode mode);
static Callable LoadICInOptimizedCode(Isolate* isolate, ContextualMode mode,
InlineCacheState initialization_state);

View File

@ -441,6 +441,14 @@ void FullCodeGenerator::CallLoadIC(ContextualMode contextual_mode,
}
void FullCodeGenerator::CallGlobalLoadIC(Handle<String> name) {
if (masm()->serializer_enabled()) return CallLoadIC(CONTEXTUAL);
Handle<Code> ic = CodeFactory::LoadGlobalIC(
isolate(), isolate()->global_object(), name).code();
CallIC(ic, TypeFeedbackId::None());
}
void FullCodeGenerator::CallStoreIC(TypeFeedbackId id) {
Handle<Code> ic = CodeFactory::StoreIC(isolate(), language_mode()).code();
CallIC(ic, id);

View File

@ -646,6 +646,7 @@ class FullCodeGenerator: public AstVisitor {
void CallLoadIC(ContextualMode mode,
TypeFeedbackId id = TypeFeedbackId::None());
void CallGlobalLoadIC(Handle<String> name);
void CallStoreIC(TypeFeedbackId id = TypeFeedbackId::None());
void SetFunctionPosition(FunctionLiteral* fun);

View File

@ -1453,7 +1453,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
__ mov(VectorLoadICDescriptor::SlotRegister(),
Immediate(SmiFromSlot(proxy->VariableFeedbackSlot())));
}
CallLoadIC(CONTEXTUAL);
CallGlobalLoadIC(var->name());
context()->Plug(eax);
break;
}

View File

@ -949,6 +949,38 @@ Handle<Code> LoadIC::initialize_stub(Isolate* isolate,
}
Handle<Code> LoadIC::load_global(Isolate* isolate, Handle<GlobalObject> global,
Handle<String> name) {
Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table());
ScriptContextTable::LookupResult lookup_result;
if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) {
return initialize_stub(isolate, LoadICState(CONTEXTUAL).GetExtraICState());
}
Handle<Map> global_map(global->map());
Handle<Code> handler = PropertyHandlerCompiler::Find(
name, global_map, Code::LOAD_IC, kCacheOnReceiver, Code::NORMAL);
if (handler.is_null()) {
LookupIterator it(global, name);
if (!it.IsFound() || !it.GetHolder<JSObject>().is_identical_to(global) ||
it.state() != LookupIterator::DATA) {
return initialize_stub(isolate,
LoadICState(CONTEXTUAL).GetExtraICState());
}
NamedLoadHandlerCompiler compiler(isolate, global_map, global,
kCacheOnReceiver);
Handle<PropertyCell> cell = it.GetPropertyCell();
handler = compiler.CompileLoadGlobal(cell, name, it.IsConfigurable());
Map::UpdateCodeCache(global_map, name, handler);
}
return PropertyICCompiler::ComputeMonomorphic(
Code::LOAD_IC, name, handle(global->map()), handler,
LoadICState(CONTEXTUAL).GetExtraICState());
}
Handle<Code> LoadIC::initialize_stub_in_optimized_code(
Isolate* isolate, ExtraICState extra_state, State initialization_state) {
if (FLAG_vector_ics) {

View File

@ -398,6 +398,8 @@ class LoadIC : public IC {
ExtraICState extra_state);
static Handle<Code> initialize_stub_in_optimized_code(
Isolate* isolate, ExtraICState extra_state, State initialization_state);
static Handle<Code> load_global(Isolate* isolate, Handle<GlobalObject> global,
Handle<String> name);
MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
Handle<Name> name);

View File

@ -1489,7 +1489,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) {
__ Move(VectorLoadICDescriptor::SlotRegister(),
SmiFromSlot(proxy->VariableFeedbackSlot()));
}
CallLoadIC(CONTEXTUAL);
CallGlobalLoadIC(var->name());
context()->Plug(rax);
break;
}