Commit 13210753 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Fix several OSR entries within literals.

With do-expressions any expression used within literals can turn into an
OSR entry-point. This means the literal object being constructed is then
renamed to an OSR value and needs to be reloaded from the environment.

R=rossberg@chromium.org
TEST=mjsunit/regress/regress-osr-in-literal

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

Cr-Commit-Position: refs/heads/master@{#32050}
parent 519df935
......@@ -1796,6 +1796,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
// Create nodes to define accessors, using only a single call to the runtime
// for each pair of corresponding getters and setters.
literal = environment()->Top(); // Reload from operand stack.
for (AccessorTable::Iterator it = accessor_table.begin();
it != accessor_table.end(); ++it) {
VisitForValue(it->first);
......@@ -1880,6 +1881,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
}
// Transform literals that contain functions to fast properties.
literal = environment()->Top(); // Reload from operand stack.
if (expr->has_function()) {
const Operator* op =
javascript()->CallRuntime(Runtime::kToFastProperties, 1);
......
......@@ -8,14 +8,15 @@
var p = {};
var testCases = [
{ s:"[1, do { _OSR_ 2 }, 3]", r:[1, 2, 3] },
{ s:"[1, ...[2], do { _OSR_ 3 }, 4]", r:[1, 2, 3, 4] },
{ s:"[1, ...do { _OSR_ [2,3] }, 4]", r:[1, 2, 3, 4] },
{ s:"{ a:do { _OSR_ 1 } }", r:{ a:1 } },
{ s:"{ a:do { _OSR_ 2 }, __proto__:p }", r:{ a:2, __proto__:p } },
{ s:"{ [do { _OSR_ 'b' }]: 3 }", r:{ b:3 } },
{ s:"{ [do { _OSR_ 'b' }]: 3, c: 4 }", r:{ b:3, c:4 } },
{ s:"{ [do { _OSR_ 'b' }]: 3, __proto__:p }", r:{ b:3, __proto__:p } },
{ s:"[1, do { _OSR_ 2 }, 3]", r:[1, 2, 3] },
{ s:"[1, ...[2], do { _OSR_ 3 }, 4]", r:[1, 2, 3, 4] },
{ s:"[1, ...do { _OSR_ [2,3] }, 4]", r:[1, 2, 3, 4] },
{ s:"{ a:do { _OSR_ 1 } }", r:{ a:1 } },
{ s:"{ a:do { _OSR_ 2 }, __proto__:p }", r:{ a:2, __proto__:p } },
{ s:"{ a:do { _OSR_ 3 }, get b() { return 4; } }", r:{ a:3, b:4 } },
{ s:"{ [do { _OSR_ 'b' }]: 3 }", r:{ b:3 } },
{ s:"{ [do { _OSR_ 'b' }]: 3, c: 4 }", r:{ b:3, c:4 } },
{ s:"{ [do { _OSR_ 'b' }]: 3, __proto__:p }", r:{ b:3, __proto__:p } },
{ s:"class { [do { _OSR_ 'f' }]() {} }" },
{ s:"class { [do { _OSR_ 'f' }]() {}; g() {} }" },
];
......
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