Commit daf185b2 authored by oth's avatar oth Committed by Commit bot

Revert of [Interpreter] Add CreateClosure to BytecodeGraphBuilder. (patchset...

Revert of [Interpreter] Add CreateClosure to BytecodeGraphBuilder. (patchset #8 id:140001 of https://codereview.chromium.org/1458603012/ )

Reason for revert:
Build break.

Original issue's description:
> [Interpreter] Add CreateClosure to BytecodeGraphBuilder.
>
> Adds code and tests to support CreateClosure bytecode when building
> graphs.
>
> BUG=v8:4280
> LOG=N
>
> Committed: https://crrev.com/4cceb11b0929abcbc82bf0854554a9b66003335d
> Cr-Commit-Position: refs/heads/master@{#32224}

TBR=bmeurer@chromium.org,mythria@chromium.org,mstarzinger@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:4280

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

Cr-Commit-Position: refs/heads/master@{#32225}
parent 4cceb11b
...@@ -643,20 +643,7 @@ void BytecodeGraphBuilder::VisitPopContext( ...@@ -643,20 +643,7 @@ void BytecodeGraphBuilder::VisitPopContext(
void BytecodeGraphBuilder::VisitCreateClosure( void BytecodeGraphBuilder::VisitCreateClosure(
const interpreter::BytecodeArrayIterator& iterator) { const interpreter::BytecodeArrayIterator& iterator) {
Handle<SharedFunctionInfo> shared_info = UNIMPLEMENTED();
Handle<SharedFunctionInfo>::cast(iterator.GetConstantForIndexOperand(0));
PretenureFlag tenured =
iterator.GetImmediateOperand(1) ? TENURED : NOT_TENURED;
const Operator* op = javascript()->CreateClosure(shared_info, tenured);
Node* closure = NewNode(op);
AddEmptyFrameStateInputs(closure);
environment()->BindAccumulator(closure);
}
void BytecodeGraphBuilder::VisitCreateClosureWide(
const interpreter::BytecodeArrayIterator& iterator) {
VisitCreateClosure(iterator);
} }
......
...@@ -444,18 +444,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( ...@@ -444,18 +444,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty(
BytecodeArrayBuilder& BytecodeArrayBuilder::CreateClosure( BytecodeArrayBuilder& BytecodeArrayBuilder::CreateClosure(
Handle<SharedFunctionInfo> shared_info, PretenureFlag tenured) { PretenureFlag tenured) {
size_t entry = GetConstantPoolEntry(shared_info);
DCHECK(FitsInImm8Operand(tenured)); DCHECK(FitsInImm8Operand(tenured));
if (FitsInIdx8Operand(entry)) { Output(Bytecode::kCreateClosure, static_cast<uint8_t>(tenured));
Output(Bytecode::kCreateClosure, static_cast<uint8_t>(entry),
static_cast<uint8_t>(tenured));
} else if (FitsInIdx16Operand(entry)) {
Output(Bytecode::kCreateClosureWide, static_cast<uint16_t>(entry),
static_cast<uint8_t>(tenured));
} else {
UNIMPLEMENTED();
}
return *this; return *this;
} }
......
...@@ -116,9 +116,8 @@ class BytecodeArrayBuilder { ...@@ -116,9 +116,8 @@ class BytecodeArrayBuilder {
int feedback_slot, int feedback_slot,
LanguageMode language_mode); LanguageMode language_mode);
// Create a new closure for the SharedFunctionInfo. // Create a new closure for the SharedFunctionInfo in the accumulator.
BytecodeArrayBuilder& CreateClosure(Handle<SharedFunctionInfo> shared_info, BytecodeArrayBuilder& CreateClosure(PretenureFlag tenured);
PretenureFlag tenured);
// Create a new arguments object in the accumulator. // Create a new arguments object in the accumulator.
BytecodeArrayBuilder& CreateArguments(CreateArgumentsType type); BytecodeArrayBuilder& CreateArguments(CreateArgumentsType type);
......
...@@ -971,8 +971,10 @@ void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { ...@@ -971,8 +971,10 @@ void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
Handle<SharedFunctionInfo> shared_info = Handle<SharedFunctionInfo> shared_info =
Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); Compiler::GetSharedFunctionInfo(expr, info()->script(), info());
CHECK(!shared_info.is_null()); // TODO(rmcilroy): Set stack overflow? CHECK(!shared_info.is_null()); // TODO(rmcilroy): Set stack overflow?
builder()->CreateClosure(shared_info,
expr->pretenure() ? TENURED : NOT_TENURED); builder()
->LoadLiteral(shared_info)
.CreateClosure(expr->pretenure() ? TENURED : NOT_TENURED);
execution_result()->SetResultInAccumulator(); execution_result()->SetResultInAccumulator();
} }
......
...@@ -161,8 +161,7 @@ namespace interpreter { ...@@ -161,8 +161,7 @@ namespace interpreter {
V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kImm8) \ V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kImm8) \
\ \
/* Closure allocation */ \ /* Closure allocation */ \
V(CreateClosure, OperandType::kIdx8, OperandType::kImm8) \ V(CreateClosure, OperandType::kImm8) \
V(CreateClosureWide, OperandType::kIdx16, OperandType::kImm8) \
\ \
/* Arguments allocation */ \ /* Arguments allocation */ \
V(CreateMappedArguments, OperandType::kNone) \ V(CreateMappedArguments, OperandType::kNone) \
......
...@@ -1367,16 +1367,15 @@ void Interpreter::DoCreateObjectLiteral( ...@@ -1367,16 +1367,15 @@ void Interpreter::DoCreateObjectLiteral(
} }
// CreateClosure <index> <tenured> // CreateClosure <tenured>
// //
// Creates a new closure for SharedFunctionInfo at position |index| in the // Creates a new closure for SharedFunctionInfo in the accumulator with the
// constant pool and with the PretenureFlag <tenured>. // PretenureFlag <tenured>.
void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) {
// TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of
// calling into the runtime. // calling into the runtime.
Node* index = __ BytecodeOperandIdx(0); Node* shared = __ GetAccumulator();
Node* shared = __ LoadConstantPoolEntry(index); Node* tenured_raw = __ BytecodeOperandImm(0);
Node* tenured_raw = __ BytecodeOperandImm(1);
Node* tenured = __ SmiTag(tenured_raw); Node* tenured = __ SmiTag(tenured_raw);
Node* result = Node* result =
__ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured); __ CallRuntime(Runtime::kInterpreterNewClosure, shared, tenured);
...@@ -1385,16 +1384,6 @@ void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) { ...@@ -1385,16 +1384,6 @@ void Interpreter::DoCreateClosure(compiler::InterpreterAssembler* assembler) {
} }
// CreateClosureWide <index> <tenured>
//
// Creates a new closure for SharedFunctionInfo at position |index| in the
// constant pool and with the PretenureFlag <tenured>.
void Interpreter::DoCreateClosureWide(
compiler::InterpreterAssembler* assembler) {
return DoCreateClosure(assembler);
}
// CreateMappedArguments // CreateMappedArguments
// //
// Creates a new mapped arguments object. // Creates a new mapped arguments object.
......
...@@ -575,45 +575,6 @@ TEST(BytecodeGraphBuilderCallNew) { ...@@ -575,45 +575,6 @@ TEST(BytecodeGraphBuilderCallNew) {
} }
TEST(BytecodeGraphBuilderCreateClosure) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
Zone* zone = scope.main_zone();
Factory* factory = isolate->factory();
ExpectedSnippet<0> snippets[] = {
{"function f() {\n"
" function counter() { this.count = 20; }\n"
" var c = new counter();\n"
" return c.count;\n"
"}; f()",
{factory->NewNumberFromInt(20)}},
{"function f() {\n"
" function counter(arg0) { this.count = 17; this.x = arg0; }\n"
" var c = new counter(6);\n"
" return c.count + c.x;\n"
"}; f()",
{factory->NewNumberFromInt(23)}},
{"function f() {\n"
" function counter(arg0, arg1) {\n"
" this.count = 17; this.x = arg0; this.y = arg1;\n"
" }\n"
" var c = new counter(3, 5);\n"
" return c.count + c.x + c.y;\n"
"}; f()",
{factory->NewNumberFromInt(25)}},
};
size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
for (size_t i = 0; i < num_snippets; i++) {
BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
auto callable = tester.GetCallable<>();
Handle<Object> return_value = callable().ToHandleChecked();
CHECK(return_value->SameValue(*snippets[i].return_value()));
}
}
TEST(BytecodeGraphBuilderCallRuntime) { TEST(BytecodeGraphBuilderCallRuntime) {
HandleAndZoneScope scope; HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate(); Isolate* isolate = scope.main_isolate();
......
...@@ -40,12 +40,6 @@ class BytecodeGraphBuilderTest : public TestWithIsolateAndZone { ...@@ -40,12 +40,6 @@ class BytecodeGraphBuilderTest : public TestWithIsolateAndZone {
public: public:
BytecodeGraphBuilderTest() {} BytecodeGraphBuilderTest() {}
std::pair<Graph*, Handle<SharedFunctionInfo>> GetCompletedGraphAndSharedInfo(
Handle<BytecodeArray> bytecode_array,
MaybeHandle<TypeFeedbackVector> feedback_vector =
MaybeHandle<TypeFeedbackVector>(),
LanguageMode language_mode = LanguageMode::SLOPPY);
Graph* GetCompletedGraph(Handle<BytecodeArray> bytecode_array, Graph* GetCompletedGraph(Handle<BytecodeArray> bytecode_array,
MaybeHandle<TypeFeedbackVector> feedback_vector = MaybeHandle<TypeFeedbackVector> feedback_vector =
MaybeHandle<TypeFeedbackVector>(), MaybeHandle<TypeFeedbackVector>(),
...@@ -69,8 +63,7 @@ class BytecodeGraphBuilderTest : public TestWithIsolateAndZone { ...@@ -69,8 +63,7 @@ class BytecodeGraphBuilderTest : public TestWithIsolateAndZone {
}; };
std::pair<Graph*, Handle<SharedFunctionInfo>> Graph* BytecodeGraphBuilderTest::GetCompletedGraph(
BytecodeGraphBuilderTest::GetCompletedGraphAndSharedInfo(
Handle<BytecodeArray> bytecode_array, Handle<BytecodeArray> bytecode_array,
MaybeHandle<TypeFeedbackVector> feedback_vector, MaybeHandle<TypeFeedbackVector> feedback_vector,
LanguageMode language_mode) { LanguageMode language_mode) {
...@@ -98,17 +91,7 @@ BytecodeGraphBuilderTest::GetCompletedGraphAndSharedInfo( ...@@ -98,17 +91,7 @@ BytecodeGraphBuilderTest::GetCompletedGraphAndSharedInfo(
BytecodeGraphBuilder graph_builder(zone(), &info, jsgraph); BytecodeGraphBuilder graph_builder(zone(), &info, jsgraph);
graph_builder.CreateGraph(); graph_builder.CreateGraph();
return std::make_pair(graph_builder.graph(), shared_info); return graph;
}
Graph* BytecodeGraphBuilderTest::GetCompletedGraph(
Handle<BytecodeArray> bytecode_array,
MaybeHandle<TypeFeedbackVector> feedback_vector,
LanguageMode language_mode) {
return GetCompletedGraphAndSharedInfo(bytecode_array, feedback_vector,
language_mode)
.first;
} }
...@@ -824,39 +807,6 @@ TEST_F(BytecodeGraphBuilderTest, New) { ...@@ -824,39 +807,6 @@ TEST_F(BytecodeGraphBuilderTest, New) {
EXPECT_THAT(ret, IsReturn(call_construct, call_construct, IsIfSuccess(_))); EXPECT_THAT(ret, IsReturn(call_construct, call_construct, IsIfSuccess(_)));
} }
TEST_F(BytecodeGraphBuilderTest, CreateClosure) {
PretenureFlag kPretenureFlags[] = {NOT_TENURED, TENURED};
TRACED_FOREACH(PretenureFlag, pretenure_flag, kPretenureFlags) {
interpreter::BytecodeArrayBuilder inner_builder(isolate(), zone());
inner_builder.set_locals_count(0);
inner_builder.set_context_count(0);
inner_builder.set_parameter_count(3);
inner_builder.LoadAccumulatorWithRegister(inner_builder.Parameter(2))
.BinaryOperation(Token::Value::ADD, inner_builder.Parameter(1),
Strength::WEAK)
.Return();
std::pair<Graph*, Handle<SharedFunctionInfo>> inner_graph_and_shared_info =
GetCompletedGraphAndSharedInfo(inner_builder.ToBytecodeArray());
Handle<SharedFunctionInfo> shared_info = inner_graph_and_shared_info.second;
interpreter::BytecodeArrayBuilder builder(isolate(), zone());
builder.set_locals_count(4);
builder.set_context_count(0);
builder.set_parameter_count(3);
builder.CreateClosure(shared_info, pretenure_flag).Return();
Graph* graph = GetCompletedGraph(builder.ToBytecodeArray());
Node* start = graph->start();
Node* ret = graph->end()->InputAt(0);
Matcher<Node*> create_closure =
IsCreateClosure(shared_info, pretenure_flag, start, start);
EXPECT_THAT(ret, IsReturn(create_closure, create_closure, start));
}
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -27,7 +27,6 @@ bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) { ...@@ -27,7 +27,6 @@ bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) {
return lhs.is_identical_to(rhs); return lhs.is_identical_to(rhs);
} }
namespace compiler { namespace compiler {
namespace { namespace {
...@@ -1859,56 +1858,6 @@ class IsJSCallMatcher final : public NodeMatcher { ...@@ -1859,56 +1858,6 @@ class IsJSCallMatcher final : public NodeMatcher {
const Matcher<Node*> control_matcher_; const Matcher<Node*> control_matcher_;
}; };
class IsCreateClosureMatcher final : public NodeMatcher {
public:
IsCreateClosureMatcher(
const Matcher<Handle<SharedFunctionInfo>>& shared_info_matcher,
const Matcher<PretenureFlag>& pretenure_matcher,
const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher)
: NodeMatcher(IrOpcode::Value::kJSCreateClosure),
shared_info_matcher_(shared_info_matcher),
pretenure_matcher_(pretenure_matcher),
effect_matcher_(effect_matcher),
control_matcher_(control_matcher) {}
void DescribeTo(std::ostream* os) const final {
NodeMatcher::DescribeTo(os);
*os << " whose value (";
shared_info_matcher_.DescribeTo(os);
*os << ",";
pretenure_matcher_.DescribeTo(os);
*os << "), effect (";
effect_matcher_.DescribeTo(os);
*os << ") and control (";
control_matcher_.DescribeTo(os);
*os << ")";
}
bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
if (!NodeMatcher::MatchAndExplain(node, listener)) {
return false;
}
return (PrintMatchAndExplain(
OpParameter<const CreateClosureParameters>(node).shared_info(),
"value", shared_info_matcher_, listener) &&
PrintMatchAndExplain(
OpParameter<CreateClosureParameters>(node).pretenure(), "value",
pretenure_matcher_, listener) &&
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
effect_matcher_, listener) &&
PrintMatchAndExplain(NodeProperties::GetControlInput(node),
"control", control_matcher_, listener));
}
private:
const Matcher<Handle<SharedFunctionInfo>> shared_info_matcher_;
const Matcher<PretenureFlag> pretenure_matcher_;
const Matcher<Node*> effect_matcher_;
const Matcher<Node*> control_matcher_;
};
} // namespace } // namespace
...@@ -2586,15 +2535,6 @@ Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers, ...@@ -2586,15 +2535,6 @@ Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers,
} }
Matcher<Node*> IsCreateClosure(const Handle<SharedFunctionInfo> shared_info,
PretenureFlag pretenure,
const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher) {
return MakeMatcher(new IsCreateClosureMatcher(
shared_info, pretenure, effect_matcher, control_matcher));
}
#define IS_BINOP_MATCHER(Name) \ #define IS_BINOP_MATCHER(Name) \
Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
const Matcher<Node*>& rhs_matcher) { \ const Matcher<Node*>& rhs_matcher) { \
......
...@@ -17,7 +17,6 @@ class ExternalReference; ...@@ -17,7 +17,6 @@ class ExternalReference;
template <typename T> template <typename T>
class Handle; class Handle;
class HeapObject; class HeapObject;
class SharedFunctionInfo;
template <class> template <class>
class TypeImpl; class TypeImpl;
enum TypeofMode : int; enum TypeofMode : int;
...@@ -406,10 +405,6 @@ Matcher<Node*> IsJSDeleteProperty(const Matcher<Node*>& object_value_matcher, ...@@ -406,10 +405,6 @@ Matcher<Node*> IsJSDeleteProperty(const Matcher<Node*>& object_value_matcher,
const Matcher<Node*>& key_matcher, const Matcher<Node*>& key_matcher,
const Matcher<Node*>& effect_matcher, const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher); const Matcher<Node*>& control_matcher);
Matcher<Node*> IsCreateClosure(const Handle<SharedFunctionInfo> shared_info,
PretenureFlag pretenure,
const Matcher<Node*>& effect_matcher,
const Matcher<Node*>& control_matcher);
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
......
...@@ -94,10 +94,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { ...@@ -94,10 +94,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.StoreKeyedProperty(reg, reg, 2056, LanguageMode::STRICT); .StoreKeyedProperty(reg, reg, 2056, LanguageMode::STRICT);
// Emit closure operations. // Emit closure operations.
Factory* factory = isolate()->factory(); builder.CreateClosure(NOT_TENURED);
Handle<SharedFunctionInfo> shared_info = factory->NewSharedFunctionInfo(
factory->NewStringFromStaticChars("function_a"), MaybeHandle<Code>());
builder.CreateClosure(shared_info, NOT_TENURED);
// Emit argument creation operations. // Emit argument creation operations.
builder.CreateArguments(CreateArgumentsType::kMappedArguments) builder.CreateArguments(CreateArgumentsType::kMappedArguments)
...@@ -218,11 +215,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { ...@@ -218,11 +215,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
} }
builder.LoadLiteral(Smi::FromInt(20000000)); builder.LoadLiteral(Smi::FromInt(20000000));
// CreateClosureWide
Handle<SharedFunctionInfo> shared_info2 = factory->NewSharedFunctionInfo(
factory->NewStringFromStaticChars("function_b"), MaybeHandle<Code>());
builder.CreateClosure(shared_info2, NOT_TENURED);
builder.Return(); builder.Return();
// Generate BytecodeArray. // Generate BytecodeArray.
......
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