| Index: src/compiler/frame-states.cc
|
| diff --git a/src/compiler/frame-states.cc b/src/compiler/frame-states.cc
|
| index ec014dac9429ab3ce229def045aaeb74bf2fd8c3..a560dc935f502ef40e50a129bb2800becffc7b5d 100644
|
| --- a/src/compiler/frame-states.cc
|
| +++ b/src/compiler/frame-states.cc
|
| @@ -5,6 +5,10 @@
|
| #include "src/compiler/frame-states.h"
|
|
|
| #include "src/base/functional.h"
|
| +#include "src/callable.h"
|
| +#include "src/compiler/graph.h"
|
| +#include "src/compiler/js-graph.h"
|
| +#include "src/compiler/node.h"
|
| #include "src/handles-inl.h"
|
| #include "src/objects-inl.h"
|
|
|
| @@ -65,6 +69,9 @@ std::ostream& operator<<(std::ostream& os, FrameStateType type) {
|
| case FrameStateType::kConstructStub:
|
| os << "CONSTRUCT_STUB";
|
| break;
|
| + case FrameStateType::kBuiltinContinuation:
|
| + os << "BUILTIN_CONTINUATION_FRAME";
|
| + break;
|
| case FrameStateType::kGetterStub:
|
| os << "GETTER_STUB";
|
| break;
|
| @@ -86,6 +93,106 @@ std::ostream& operator<<(std::ostream& os, FrameStateInfo const& info) {
|
| return os;
|
| }
|
|
|
| +namespace {
|
| +std::pair<Node*, Node*> CreateBuiltinContinuationFrameStateCommon(
|
| + JSGraph* js_graph, Builtins::Name name, Node** parameters,
|
| + int parameter_count, Node* effect, Node* control, Node* outer_frame_state,
|
| + CheckpointMode mode, Handle<SharedFunctionInfo> shared) {
|
| + Isolate* isolate = js_graph->isolate();
|
| + Graph* graph = js_graph->graph();
|
| + CommonOperatorBuilder* common = js_graph->common();
|
| +
|
| + BailoutId bailout_id = Builtins::GetContinuationBailoutId(name);
|
| + Callable callable = Builtins::CallableFor(isolate, name);
|
| +
|
| + const Operator* op_param =
|
| + common->StateValues(parameter_count, SparseInputMask::Dense());
|
| + Node* params_node = graph->NewNode(op_param, parameter_count, parameters);
|
| +
|
| + const FrameStateFunctionInfo* state_info =
|
| + common->CreateFrameStateFunctionInfo(FrameStateType::kBuiltinContinuation,
|
| + parameter_count, 0, shared);
|
| + const Operator* op = common->FrameState(
|
| + bailout_id, OutputFrameStateCombine::Ignore(), state_info);
|
| + const Operator* op0 = common->StateValues(0, SparseInputMask::Dense());
|
| + Node* node0 = graph->NewNode(op0);
|
| +
|
| + Node* frame_state = graph->NewNode(
|
| + op, params_node, node0, node0, js_graph->UndefinedConstant(),
|
| + js_graph->UndefinedConstant(), outer_frame_state);
|
| +
|
| + return std::make_pair(
|
| + frame_state,
|
| + mode == CREATE_CHECKPOINT
|
| + ? graph->NewNode(common->Checkpoint(), frame_state, effect, control)
|
| + : effect);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +std::pair<Node*, Node*> CreateStubBuiltinContinuationFrameState(
|
| + JSGraph* js_graph, Builtins::Name name, Node* context, Node** parameters,
|
| + int parameter_count, Node* effect, Node* control, Node* outer_frame_state,
|
| + CheckpointMode mode) {
|
| + Isolate* isolate = js_graph->isolate();
|
| + Callable callable = Builtins::CallableFor(isolate, name);
|
| + CallInterfaceDescriptor descriptor = callable.descriptor();
|
| +
|
| + std::vector<Node*> actual_parameters;
|
| + if (descriptor.GetRegisterParameterCount() == 0) {
|
| + actual_parameters.push_back(context);
|
| + }
|
| + for (int i = 0; i < parameter_count; ++i) {
|
| + actual_parameters.push_back(parameters[i]);
|
| + if (i == descriptor.GetRegisterParameterCount() - 1) {
|
| + actual_parameters.push_back(context);
|
| + }
|
| + }
|
| +
|
| + return CreateBuiltinContinuationFrameStateCommon(
|
| + js_graph, name, &actual_parameters[0],
|
| + static_cast<int>(actual_parameters.size()), effect, control,
|
| + outer_frame_state, mode, Handle<SharedFunctionInfo>());
|
| +}
|
| +
|
| +std::pair<Node*, Node*> CreateJavaScriptBuiltinContinuationFrameState(
|
| + JSGraph* js_graph, Handle<SharedFunctionInfo> shared, Builtins::Name name,
|
| + Node* target, Node* context, Node** stack_parameters,
|
| + int stack_parameter_count, Node* effect, Node* control,
|
| + Node* outer_frame_state, CheckpointMode mode) {
|
| + Isolate* isolate = js_graph->isolate();
|
| + Callable callable = Builtins::CallableFor(isolate, name);
|
| +
|
| + // Lazy deopt points where the frame state is assocated with a call get an
|
| + // additional parameter for the return result from the call that's added by
|
| + // the deoptimizer and not explicitly specified in the frame state. Check that
|
| + // there is not a mismatch between the number of frame state parameters and
|
| + // the stack parameters required by the builtin taking this into account.
|
| + DCHECK_EQ(
|
| + Builtins::GetStackParameterCount(isolate, name) + 1, // add receiver
|
| + stack_parameter_count + (mode == CREATE_CHECKPOINT ? 0 : 1));
|
| +
|
| + std::vector<Node*> actual_parameters;
|
| + // target
|
| + actual_parameters.push_back(target);
|
| + // new target
|
| + actual_parameters.push_back(js_graph->UndefinedConstant());
|
| + // argc, remove receiver and add in return value for lazy deopts from calls
|
| + actual_parameters.push_back(js_graph->Constant(
|
| + stack_parameter_count - (mode == CREATE_CHECKPOINT ? 1 : 0)));
|
| + // context
|
| + actual_parameters.push_back(context);
|
| +
|
| + for (int i = 0; i < stack_parameter_count; ++i) {
|
| + actual_parameters.push_back(stack_parameters[i]);
|
| + }
|
| +
|
| + return CreateBuiltinContinuationFrameStateCommon(
|
| + js_graph, name, &actual_parameters[0],
|
| + static_cast<int>(actual_parameters.size()), effect, control,
|
| + outer_frame_state, mode, shared);
|
| +}
|
| +
|
| } // namespace compiler
|
| } // namespace internal
|
| } // namespace v8
|
|
|