Commit b9d3651e authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[turbofan] Fix wrong expectation when serializing API calls

Bug: v8:7790, chromium:985660
Change-Id: I4e931a4a23421982f05e16c8ffa2ccc68fb34b63
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1709423
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62862}
parent f641d987
...@@ -3012,8 +3012,7 @@ Reduction JSCallReducer::ReduceCallApiFunction( ...@@ -3012,8 +3012,7 @@ Reduction JSCallReducer::ReduceCallApiFunction(
<< function_template_info); << function_template_info);
return NoChange(); return NoChange();
} }
CallHandlerInfoRef call_handler_info = CallHandlerInfoRef call_handler_info = *function_template_info.call_code();
function_template_info.call_code()->AsCallHandlerInfo();
Callable call_api_callback = CodeFactory::CallApiCallback(isolate()); Callable call_api_callback = CodeFactory::CallApiCallback(isolate());
CallInterfaceDescriptor cid = call_api_callback.descriptor(); CallInterfaceDescriptor cid = call_api_callback.descriptor();
auto call_descriptor = Linkage::GetStubCallDescriptor( auto call_descriptor = Linkage::GetStubCallDescriptor(
......
...@@ -217,10 +217,7 @@ void FunctionTemplateInfoData::SerializeCallCode(JSHeapBroker* broker) { ...@@ -217,10 +217,7 @@ void FunctionTemplateInfoData::SerializeCallCode(JSHeapBroker* broker) {
DCHECK_NULL(call_code_); DCHECK_NULL(call_code_);
call_code_ = broker->GetOrCreateData(function_template_info->call_code()) call_code_ = broker->GetOrCreateData(function_template_info->call_code())
->AsCallHandlerInfo(); ->AsCallHandlerInfo();
call_code_->Serialize(broker);
if (call_code_->IsCallHandlerInfo()) {
call_code_->Serialize(broker);
}
} }
void CallHandlerInfoData::Serialize(JSHeapBroker* broker) { void CallHandlerInfoData::Serialize(JSHeapBroker* broker) {
......
...@@ -2039,13 +2039,16 @@ Node* JSNativeContextSpecialization::InlineApiCall( ...@@ -2039,13 +2039,16 @@ Node* JSNativeContextSpecialization::InlineApiCall(
Node* receiver, Node* holder, Node* frame_state, Node* value, Node** effect, Node* receiver, Node* holder, Node* frame_state, Node* value, Node** effect,
Node** control, SharedFunctionInfoRef const& shared_info, Node** control, SharedFunctionInfoRef const& shared_info,
FunctionTemplateInfoRef const& function_template_info) { FunctionTemplateInfoRef const& function_template_info) {
if (!function_template_info.has_call_code()) {
return nullptr;
}
if (!function_template_info.call_code().has_value()) { if (!function_template_info.call_code().has_value()) {
TRACE_BROKER_MISSING(broker(), "call code for function template info " TRACE_BROKER_MISSING(broker(), "call code for function template info "
<< function_template_info); << function_template_info);
return nullptr; return nullptr;
} }
auto call_handler_info = CallHandlerInfoRef call_handler_info = *function_template_info.call_code();
function_template_info.call_code()->AsCallHandlerInfo();
// Only setters have a value. // Only setters have a value.
int const argc = value == nullptr ? 0 : 1; int const argc = value == nullptr ? 0 : 1;
......
...@@ -1989,13 +1989,13 @@ SerializerForBackgroundCompilation::ProcessFeedbackMapsForNamedAccess( ...@@ -1989,13 +1989,13 @@ SerializerForBackgroundCompilation::ProcessFeedbackMapsForNamedAccess(
if (sfi->IsApiFunction()) { if (sfi->IsApiFunction()) {
FunctionTemplateInfoRef fti_ref( FunctionTemplateInfoRef fti_ref(
broker(), handle(sfi->get_api_func_data(), broker()->isolate())); broker(), handle(sfi->get_api_func_data(), broker()->isolate()));
fti_ref.SerializeCallCode(); if (fti_ref.has_call_code()) fti_ref.SerializeCallCode();
ProcessReceiverMapForApiCall(fti_ref, map); ProcessReceiverMapForApiCall(fti_ref, map);
} }
} else { } else {
FunctionTemplateInfoRef fti_ref( FunctionTemplateInfoRef fti_ref(
broker(), Handle<FunctionTemplateInfo>::cast(info.constant())); broker(), Handle<FunctionTemplateInfo>::cast(info.constant()));
fti_ref.SerializeCallCode(); if (fti_ref.has_call_code()) fti_ref.SerializeCallCode();
} }
} }
} }
......
// Copyright 2019 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.
// Flags: --allow-natives-syntax
try {
Object.defineProperty(Number.prototype, "v", {
get: constructor
});
} catch (e) {}
function foo(obj) {
return obj.v;
}
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo(3);
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo(3);
foo(4);
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