Commit 9128e8bf authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[ignition] Move object/array literal init to bytecode gen

Move the object and array literal flag and depth initialization to when
they are visited by the bytecode generator. This avoids issues with
doing this initialization before we know whether the (syntactic) literal
is actually a literal value or a destructuring assignment.

Bug: chromium:795922
Bug: v8:7178
Change-Id: I022178ab4bc9e71f80560f3b78a759d95d4d0584
Reviewed-on: https://chromium-review.googlesource.com/833882Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50204}
parent 4695e979
......@@ -1361,7 +1361,6 @@ class ObjectLiteral final : public AggregateLiteral {
HasRestPropertyField::encode(has_rest_property) |
FastElementsField::encode(false) |
HasNullPrototypeField::encode(false);
InitDepthAndFlags();
}
void InitFlagsForPendingNullPrototype(int i);
......@@ -1467,7 +1466,6 @@ class ArrayLiteral final : public AggregateLiteral {
: AggregateLiteral(pos, kArrayLiteral),
first_spread_index_(first_spread_index),
values_(values) {
InitDepthAndFlags();
}
int first_spread_index_;
......
......@@ -2095,6 +2095,8 @@ void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
}
void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
expr->InitDepthAndFlags();
// Fast path for the empty object literal which doesn't need an
// AllocationSite.
if (expr->IsEmptyObjectLiteral()) {
......@@ -2301,6 +2303,8 @@ void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
}
void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
expr->InitDepthAndFlags();
// Deep-copy the literal boilerplate.
int literal_index = feedback_index(feedback_spec()->AddLiteralSlot());
if (expr->is_empty()) {
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
assertThrows(
// Should throw a syntax error, but not crash.
"({ __proto__: null, __proto__: 1 })",
SyntaxError
);
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