Commit 4c2379e5 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

Generate correct bytecode for calls of optional chains

The receiver may be undefined when calling optionally chained
properties, so CallAnyReceiver should be used instead of CallProperty.

TBR=rmcilroy@chromium.org

Bug: chromium:1038178
Change-Id: Id91f2ecda1a5b38f6d1c9a6b6f90c0ae7dcbe638
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1986205
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65580}
parent eb2d9591
......@@ -1733,16 +1733,8 @@ class Call final : public Expression {
PRIVATE_CALL,
SUPER_CALL,
OTHER_CALL,
FIRST_NON_SUPER_PROPERTY_CALL = NAMED_PROPERTY_CALL,
LAST_NON_SUPER_PROPERTY_CALL = KEYED_OPTIONAL_CHAIN_PROPERTY_CALL
};
static bool IsNonSuperPropertyCall(CallType call_type) {
return base::IsInRange(call_type, FIRST_NON_SUPER_PROPERTY_CALL,
LAST_NON_SUPER_PROPERTY_CALL);
}
enum PossiblyEval {
IS_POSSIBLY_EVAL,
NOT_EVAL,
......
......@@ -4834,7 +4834,8 @@ void BytecodeGenerator::VisitCall(Call* expr) {
} else if (optimize_as_one_shot) {
DCHECK(!implicit_undefined_receiver);
builder()->CallNoFeedback(callee, args);
} else if (Call::IsNonSuperPropertyCall(call_type)) {
} else if (call_type == Call::NAMED_PROPERTY_CALL ||
call_type == Call::KEYED_PROPERTY_CALL) {
DCHECK(!implicit_undefined_receiver);
builder()->CallProperty(callee, args,
feedback_index(feedback_spec()->AddCallICSlot()));
......
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