Commit 9ee47bbc authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] No need to load the feedback vector on the JS graph level.

Fix JSLoadGlobal/JSStoreGlobal, JSLoadNamed/JSStoreNamed and
JSLoadProperty/JSStoreProperty to take the current function closure
instead of the type feedback as input, and load the feedback vector
from the closure as required (in JSGenericLowering). There's still
JSLoadDynamic left to be done, and then we don't have any machine
operators in the initial JS graph left.

There'll be more refactoring on the JSGenericLowering in a follow-up
CL, which takes care of the current code duplication and also tries
to use the more efficient LoadIC/KeyedLoadIC instead of the current
LoadICInOptimizedCode/KeyedLoadICInOptimizedCode (and same for store
ICs) whenever possible.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#33854}
parent 97579fd7
......@@ -3578,7 +3578,7 @@ Node* AstGraphBuilder::BuildVariableAssignment(
Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
const VectorSlotPair& feedback) {
const Operator* op = javascript()->LoadProperty(language_mode(), feedback);
Node* node = NewNode(op, object, key, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, key, GetFunctionClosure());
return node;
}
......@@ -3586,7 +3586,7 @@ Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
const VectorSlotPair& feedback) {
const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback);
Node* node = NewNode(op, object, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, GetFunctionClosure());
return node;
}
......@@ -3594,7 +3594,7 @@ Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value,
const VectorSlotPair& feedback) {
const Operator* op = javascript()->StoreProperty(language_mode(), feedback);
Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, key, value, GetFunctionClosure());
return node;
}
......@@ -3604,7 +3604,7 @@ Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name,
const VectorSlotPair& feedback) {
const Operator* op =
javascript()->StoreNamed(language_mode(), name, feedback);
Node* node = NewNode(op, object, value, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, value, GetFunctionClosure());
return node;
}
......@@ -3657,7 +3657,7 @@ Node* AstGraphBuilder::BuildGlobalLoad(Handle<Name> name,
const VectorSlotPair& feedback,
TypeofMode typeof_mode) {
const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode);
Node* node = NewNode(op, BuildLoadFeedbackVector());
Node* node = NewNode(op, GetFunctionClosure());
return node;
}
......@@ -3666,7 +3666,7 @@ Node* AstGraphBuilder::BuildGlobalStore(Handle<Name> name, Node* value,
const VectorSlotPair& feedback) {
const Operator* op =
javascript()->StoreGlobal(language_mode(), name, feedback);
Node* node = NewNode(op, value, BuildLoadFeedbackVector());
Node* node = NewNode(op, value, GetFunctionClosure());
return node;
}
......
......@@ -663,7 +663,7 @@ void BytecodeGraphBuilder::BuildLoadGlobal(
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode);
Node* node = NewNode(op, BuildLoadFeedbackVector());
Node* node = NewNode(op, GetFunctionClosure());
environment()->BindAccumulator(node, &states);
}
......@@ -708,7 +708,7 @@ void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) {
Node* value = environment()->LookupAccumulator();
const Operator* op = javascript()->StoreGlobal(language_mode, name, feedback);
Node* node = NewNode(op, value, BuildLoadFeedbackVector());
Node* node = NewNode(op, value, GetFunctionClosure());
environment()->RecordAfterState(node, &states);
}
......@@ -820,7 +820,7 @@ void BytecodeGraphBuilder::BuildNamedLoad() {
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback);
Node* node = NewNode(op, object, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, GetFunctionClosure());
environment()->BindAccumulator(node, &states);
}
......@@ -853,7 +853,7 @@ void BytecodeGraphBuilder::BuildKeyedLoad() {
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
const Operator* op = javascript()->LoadProperty(language_mode(), feedback);
Node* node = NewNode(op, object, key, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, key, GetFunctionClosure());
environment()->BindAccumulator(node, &states);
}
......@@ -888,7 +888,7 @@ void BytecodeGraphBuilder::BuildNamedStore(LanguageMode language_mode) {
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = javascript()->StoreNamed(language_mode, name, feedback);
Node* node = NewNode(op, object, value, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, value, GetFunctionClosure());
environment()->RecordAfterState(node, &states);
}
......@@ -919,7 +919,7 @@ void BytecodeGraphBuilder::BuildKeyedStore(LanguageMode language_mode) {
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = javascript()->StoreProperty(language_mode, feedback);
Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector());
Node* node = NewNode(op, object, key, value, GetFunctionClosure());
environment()->RecordAfterState(node, &states);
}
......
......@@ -280,99 +280,187 @@ void JSGenericLowering::LowerJSToObject(Node* node) {
void JSGenericLowering::LowerJSLoadProperty(Node* node) {
Node* closure = NodeProperties::GetValueInput(node, 2);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const PropertyAccess& p = PropertyAccessOf(node->op());
Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(
isolate(), p.language_mode(), UNINITIALIZED);
// Load the type feedback vector from the closure.
Node* shared_info = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), closure,
jsgraph()->IntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
kHeapObjectTag),
effect, control);
Node* vector = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), shared_info,
jsgraph()->IntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(3, vector);
node->ReplaceInput(6, effect);
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSLoadNamed(Node* node) {
Node* closure = NodeProperties::GetValueInput(node, 1);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
NamedAccess const& p = NamedAccessOf(node->op());
Callable callable = CodeFactory::LoadICInOptimizedCode(
isolate(), NOT_INSIDE_TYPEOF, p.language_mode(), UNINITIALIZED);
// Load the type feedback vector from the closure.
Node* shared_info = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), closure,
jsgraph()->IntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
kHeapObjectTag),
effect, control);
Node* vector = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), shared_info,
jsgraph()->IntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(3, vector);
node->ReplaceInput(6, effect);
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
Node* closure = NodeProperties::GetValueInput(node, 0);
Node* context = NodeProperties::GetContextInput(node);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
Callable callable = CodeFactory::LoadICInOptimizedCode(
isolate(), p.typeof_mode(), SLOPPY, UNINITIALIZED);
// Load the type feedback vector from the closure.
Node* shared_info = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), closure,
jsgraph()->IntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
kHeapObjectTag),
effect, control);
Node* vector = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), shared_info,
jsgraph()->IntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
// Load global object from the context.
Node* native_context =
Node* native_context = effect =
graph()->NewNode(machine()->Load(MachineType::AnyTagged()), context,
jsgraph()->IntPtrConstant(
Context::SlotOffset(Context::NATIVE_CONTEXT_INDEX)),
effect, graph()->start());
Node* global = graph()->NewNode(
effect, control);
Node* global = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), native_context,
jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)),
effect, graph()->start());
effect, control);
node->InsertInput(zone(), 0, global);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(3, vector);
node->ReplaceInput(6, effect);
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSStoreProperty(Node* node) {
Node* closure = NodeProperties::GetValueInput(node, 3);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
PropertyAccess const& p = PropertyAccessOf(node->op());
LanguageMode language_mode = p.language_mode();
Callable callable = CodeFactory::KeyedStoreICInOptimizedCode(
isolate(), language_mode, UNINITIALIZED);
DCHECK(p.feedback().index() != -1);
// Load the type feedback vector from the closure.
Node* shared_info = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), closure,
jsgraph()->IntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
kHeapObjectTag),
effect, control);
Node* vector = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), shared_info,
jsgraph()->IntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
ReplaceWithStubCall(node, callable,
CallDescriptor::kPatchableCallSite | flags);
node->ReplaceInput(4, vector);
node->ReplaceInput(7, effect);
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSStoreNamed(Node* node) {
Node* closure = NodeProperties::GetValueInput(node, 2);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
NamedAccess const& p = NamedAccessOf(node->op());
Callable callable = CodeFactory::StoreICInOptimizedCode(
isolate(), p.language_mode(), UNINITIALIZED);
// Load the type feedback vector from the closure.
Node* shared_info = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), closure,
jsgraph()->IntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
kHeapObjectTag),
effect, control);
Node* vector = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), shared_info,
jsgraph()->IntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
DCHECK(p.feedback().index() != -1);
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
ReplaceWithStubCall(node, callable,
CallDescriptor::kPatchableCallSite | flags);
node->ReplaceInput(4, vector);
node->ReplaceInput(7, effect);
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
Node* closure = NodeProperties::GetValueInput(node, 1);
Node* context = NodeProperties::GetContextInput(node);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
Callable callable = CodeFactory::StoreICInOptimizedCode(
isolate(), p.language_mode(), UNINITIALIZED);
// Load the type feedback vector from the closure.
Node* shared_info = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), closure,
jsgraph()->IntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
kHeapObjectTag),
effect, control);
Node* vector = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), shared_info,
jsgraph()->IntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
// Load global object from the context.
Node* native_context =
Node* native_context = effect =
graph()->NewNode(machine()->Load(MachineType::AnyTagged()), context,
jsgraph()->IntPtrConstant(
Context::SlotOffset(Context::NATIVE_CONTEXT_INDEX)),
effect, graph()->start());
Node* global = graph()->NewNode(
effect, control);
Node* global = effect = graph()->NewNode(
machine()->Load(MachineType::AnyTagged()), native_context,
jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)),
effect, graph()->start());
effect, control);
node->InsertInput(zone(), 0, global);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
DCHECK(p.feedback().index() != -1);
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
ReplaceWithStubCall(node, callable,
CallDescriptor::kPatchableCallSite | flags);
node->ReplaceInput(4, vector);
node->ReplaceInput(7, effect);
ReplaceWithStubCall(node, callable, flags);
}
......
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