Commit 42b4180d authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[ubsan] Use Address parameters for calling generated code

The simulated C++ signature for generated code entry points should
rely on primitive values (as opposed to ObjectPtr).

Bug: v8:3770
Change-Id: I6f6f4dc8a93c7ba46bfc7052dc4745b16e9fd62f
Reviewed-on: https://chromium-review.googlesource.com/c/1386875Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58409}
parent a01508e2
...@@ -532,9 +532,9 @@ namespace { ...@@ -532,9 +532,9 @@ namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Object*( // using JSEntryFunction = GeneratedCode<Address(
// Object * new_target, Object * target, Object * receiver, int argc, // Address new_target, Address target, Address receiver, int argc,
// Object*** args, Address root_register_value)>; // Address** args, Address root_register_value)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
// r0: code entry // r0: code entry
......
...@@ -601,9 +601,9 @@ namespace { ...@@ -601,9 +601,9 @@ namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Object*( // using JSEntryFunction = GeneratedCode<Address(
// Object * new_target, Object * target, Object * receiver, int argc, // Address new_target, Address target, Address receiver, int argc,
// Object*** args, Address root_register_value)>; // Address** args, Address root_register_value)>;
// //
// Input: // Input:
// x0: code entry. // x0: code entry.
......
...@@ -373,9 +373,9 @@ namespace { ...@@ -373,9 +373,9 @@ namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Object*( // using JSEntryFunction = GeneratedCode<Address(
// Object * new_target, Object * target, Object * receiver, int argc, // Address new_target, Address target, Address receiver, int argc,
// Object*** args, Address root_register_value)>; // Address** args, Address root_register_value)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
......
...@@ -395,9 +395,9 @@ namespace { ...@@ -395,9 +395,9 @@ namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Object*( // using JSEntryFunction = GeneratedCode<Address(
// Object * new_target, Object * target, Object * receiver, int argc, // Address new_target, Address target, Address receiver, int argc,
// Object*** args, Address root_register_value)>; // Address** args, Address root_register_value)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
......
...@@ -540,9 +540,9 @@ namespace { ...@@ -540,9 +540,9 @@ namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Object*( // using JSEntryFunction = GeneratedCode<Address(
// Object * new_target, Object * target, Object * receiver, int argc, // Address new_target, Address target, Address receiver, int argc,
// Object*** args, Address root_register_value)>; // Address** args, Address root_register_value)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
......
...@@ -367,9 +367,9 @@ namespace { ...@@ -367,9 +367,9 @@ namespace {
// Called with the native C calling convention. The corresponding function // Called with the native C calling convention. The corresponding function
// signature is: // signature is:
// //
// using JSEntryFunction = GeneratedCode<Object*( // using JSEntryFunction = GeneratedCode<Address(
// Object * new_target, Object * target, Object * receiver, int argc, // Address new_target, Address target, Address receiver, int argc,
// Object*** args, Address root_register_value)>; // Address** args, Address root_register_value)>;
void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
Builtins::Name entry_trampoline) { Builtins::Name entry_trampoline) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
...@@ -555,11 +555,11 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { ...@@ -555,11 +555,11 @@ void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) {
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
bool is_construct) { bool is_construct) {
// Expects five C++ function parameters. // Expects five C++ function parameters.
// - Object* new_target // - Address new_target (tagged Object pointer)
// - JSFunction function // - Address function (tagged JSFunction pointer)
// - Object* receiver // - Address receiver (tagged Object pointer)
// - int argc // - int argc
// - Object*** argv // - Address** argv (pointer to array of tagged Object pointers)
// (see Handle::Invoke in execution.cc). // (see Handle::Invoke in execution.cc).
// Open a C++ scope for the FrameScope. // Open a C++ scope for the FrameScope.
......
...@@ -253,7 +253,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, ...@@ -253,7 +253,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
} }
// Placeholder for return value. // Placeholder for return value.
Object* value = nullptr; ObjectPtr value;
Handle<Code> code = Handle<Code> code =
JSEntry(isolate, params.execution_target, params.is_construct); JSEntry(isolate, params.execution_target, params.is_construct);
...@@ -270,9 +270,11 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, ...@@ -270,9 +270,11 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
SaveContext save(isolate); SaveContext save(isolate);
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
// clang-format off // clang-format off
using JSEntryFunction = GeneratedCode<Object*( // {new_target}, {target}, {receiver}, return value: tagged pointers
Object* new_target, Object* target, Object* receiver, int argc, // {argv}: pointer to array of tagged pointers
Object*** argv, Address root_register_value)>; using JSEntryFunction = GeneratedCode<Address(
Address new_target, Address target, Address receiver, int argc,
Address** argv, Address root_register_value)>;
// clang-format on // clang-format on
JSEntryFunction stub_entry = JSEntryFunction stub_entry =
JSEntryFunction::FromAddress(isolate, code->InstructionStart()); JSEntryFunction::FromAddress(isolate, code->InstructionStart());
...@@ -280,16 +282,16 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, ...@@ -280,16 +282,16 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
if (FLAG_clear_exceptions_on_js_entry) isolate->clear_pending_exception(); if (FLAG_clear_exceptions_on_js_entry) isolate->clear_pending_exception();
// Call the function through the right JS entry stub. // Call the function through the right JS entry stub.
Object* orig_func = *params.new_target; Address orig_func = params.new_target->ptr();
Object* func = *params.target; Address func = params.target->ptr();
Object* recv = *params.receiver; Address recv = params.receiver->ptr();
Object*** argv = reinterpret_cast<Object***>(params.argv); Address** argv = reinterpret_cast<Address**>(params.argv);
if (FLAG_profile_deserialization && params.target->IsJSFunction()) { if (FLAG_profile_deserialization && params.target->IsJSFunction()) {
PrintDeserializedCodeInfo(Handle<JSFunction>::cast(params.target)); PrintDeserializedCodeInfo(Handle<JSFunction>::cast(params.target));
} }
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution); RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kJS_Execution);
value = stub_entry.Call(orig_func, func, recv, params.argc, argv, value = ObjectPtr(stub_entry.Call(orig_func, func, recv, params.argc, argv,
isolate->isolate_data()->isolate_root()); isolate->isolate_data()->isolate_root()));
} }
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
......
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