}
-Node* AstGraphBuilder::NewCurrentContextOsrValue() {
- // TODO(titzer): use a real OSR value here; a parameter works by accident.
- // Parameter (arity + 1) is special for the outer context of the function
- const Operator* op = common()->Parameter(
- info()->num_parameters_including_this(), "%osr-context");
- return NewNode(op, graph()->start());
-}
-
-
bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
Scope* scope = info()->scope();
DCHECK(graph() != NULL);
Node* osr_context = nullptr;
const Operator* op =
builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true);
+ const Operator* op_inner =
+ builder_->common()->OsrValue(Linkage::kOsrContextSpillSlotIndex);
int last = static_cast<int>(contexts()->size() - 1);
for (int i = last; i >= 0; i--) {
Node* val = contexts()->at(i);
if (!IrOpcode::IsConstantOpcode(val->opcode())) {
- osr_context = (i == last) ? builder_->NewCurrentContextOsrValue()
+ osr_context = (i == last) ? graph->NewNode(op_inner, osr_loop_entry)
: graph->NewNode(op, osr_context, osr_context,
osr_loop_entry);
contexts()->at(i) = builder_->MergeValue(val, osr_context, control);
Node* NewEffectPhi(int count, Node* input, Node* control);
Node* NewOuterContextParam();
- Node* NewCurrentContextOsrValue();
// Helpers for merging control, effect or value dependencies.
Node* MergeControl(Node* control, Node* other);
int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1);
int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count);
- if (index >= first_stack_slot) {
+ if (index == kOsrContextSpillSlotIndex) {
+ // Context. Use the parameter location of the context spill slot.
+ // Parameter (arity + 1) is special for the context of the function frame.
+ int context_index = 1 + 1 + parameter_count; // target + receiver + params
+ return incoming_->GetInputLocation(context_index);
+ } else if (index >= first_stack_slot) {
// Local variable stored in this (callee) stack.
int spill_index =
LinkageLocation::ANY_REGISTER + 1 + index - first_stack_slot;
// A special parameter index for JSCalls that represents the closure.
static const int kJSFunctionCallClosureParamIndex = -1;
+ // A special {OsrValue} index to indicate the context spill slot.
+ static const int kOsrContextSpillSlotIndex = -1;
+
private:
CallDescriptor* const incoming_;