Commit 46aecaa6 authored by Creddy's avatar Creddy Committed by Commit Bot

Add bytecode-generator test for function in assignments

Adding test to confirm that no one-shot optimizations are not done
for functions enclosed in parentheses but not immediately invoked
in an assignment.

Bug: v8:8072
Change-Id: I282132a7cc570b59290f2ec314462be060d48e5a
Reviewed-on: https://chromium-review.googlesource.com/c/1238576
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56763}
parent cc23ea83
......@@ -649,3 +649,164 @@ constant pool: [
handlers: [
]
---
snippet: "
var f = function(l) { l.a = 3; return l; };
f({});
f;
"
frame size: 0
parameter count: 2
bytecode array length: 10
bytecodes: [
/* 25 E> */ B(StackCheck),
/* 32 S> */ B(LdaSmi), I8(3),
/* 36 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(0),
/* 41 S> */ B(Ldar), R(arg0),
/* 50 S> */ B(Return),
]
constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
]
handlers: [
]
---
snippet: "
var f = (function(l) { l.a = 3; return l; });
f;
"
frame size: 0
parameter count: 2
bytecode array length: 10
bytecodes: [
/* 26 E> */ B(StackCheck),
/* 33 S> */ B(LdaSmi), I8(3),
/* 37 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(0),
/* 42 S> */ B(Ldar), R(arg0),
/* 51 S> */ B(Return),
]
constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
]
handlers: [
]
---
snippet: "
var f = (function foo(l) { l.a = 3; return l; });
f;
"
frame size: 0
parameter count: 2
bytecode array length: 10
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 37 S> */ B(LdaSmi), I8(3),
/* 41 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(0),
/* 46 S> */ B(Ldar), R(arg0),
/* 55 S> */ B(Return),
]
constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
]
handlers: [
]
---
snippet: "
var f = function foo(l) { l.a = 3; return l; };
f({});
f;
"
frame size: 0
parameter count: 2
bytecode array length: 10
bytecodes: [
/* 29 E> */ B(StackCheck),
/* 36 S> */ B(LdaSmi), I8(3),
/* 40 E> */ B(StaNamedProperty), R(arg0), U8(0), U8(0),
/* 45 S> */ B(Ldar), R(arg0),
/* 54 S> */ B(Return),
]
constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
]
handlers: [
]
---
snippet: "
l = {};
var f = (function foo(l) { l.a = 3; return arguments.callee; })(l);
f;
"
frame size: 3
parameter count: 2
bytecode array length: 27
bytecodes: [
B(CreateFunctionContext), U8(0), U8(1),
B(PushContext), R(1),
B(Ldar), R(arg0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(Star), R(0),
/* 46 E> */ B(StackCheck),
/* 53 S> */ B(LdaCurrentContextSlot), U8(4),
B(Star), R(2),
B(LdaSmi), I8(3),
/* 57 E> */ B(StaNamedPropertyNoFeedback), R(2), U8(1), U8(0),
/* 79 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(2),
/* 86 S> */ B(Return),
]
constant pool: [
SCOPE_INFO_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"],
]
handlers: [
]
---
snippet: "
var f = (function foo(l) { l.a = 3; return arguments.callee; })({});
f;
"
frame size: 3
parameter count: 2
bytecode array length: 27
bytecodes: [
B(CreateFunctionContext), U8(0), U8(1),
B(PushContext), R(1),
B(Ldar), R(arg0),
B(StaCurrentContextSlot), U8(4),
B(CreateMappedArguments),
B(Star), R(0),
/* 30 E> */ B(StackCheck),
/* 37 S> */ B(LdaCurrentContextSlot), U8(4),
B(Star), R(2),
B(LdaSmi), I8(3),
/* 41 E> */ B(StaNamedPropertyNoFeedback), R(2), U8(1), U8(0),
/* 63 S> */ B(LdaNamedPropertyNoFeedback), R(0), U8(2),
/* 70 S> */ B(Return),
]
constant pool: [
SCOPE_INFO_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"],
]
handlers: [
]
......@@ -690,6 +690,34 @@ TEST(IIFEWithOneshotOpt) {
}
f();
)",
R"(
var f = function(l) { l.a = 3; return l; };
f({});
f;
)",
// No one-shot opt for top-level functions enclosed in parentheses
R"(
var f = (function(l) { l.a = 3; return l; });
f;
)",
R"(
var f = (function foo(l) { l.a = 3; return l; });
f;
)",
R"(
var f = function foo(l) { l.a = 3; return l; };
f({});
f;
)",
R"(
l = {};
var f = (function foo(l) { l.a = 3; return arguments.callee; })(l);
f;
)",
R"(
var f = (function foo(l) { l.a = 3; return arguments.callee; })({});
f;
)",
};
CHECK(CompareTexts(BuildActual(printer, snippets),
LoadGolden("IIFEWithOneshotOpt.golden")));
......
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