Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 15
#define V8_MINOR_VERSION 8
#define V8_BUILD_NUMBER 62
#define V8_PATCH_LEVEL 61
#define V8_PATCH_LEVEL 81

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
3 changes: 0 additions & 3 deletions deps/v8/src/builtins/base.tq
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,6 @@ extern macro Comment(constexpr string): void;
extern macro DebugBreak(): void;
extern macro PrintStringSimple(String): void;

extern macro SetSupportsDynamicParameterCount(
JSFunction, DispatchHandle): void;

// ES6 7.1.4 ToInteger ( argument )
transitioning macro ToIntegerImpl(
implicit context: Context)(input: JSAny): Number {
Expand Down
3 changes: 1 addition & 2 deletions deps/v8/src/builtins/builtins-internal-gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ TF_BUILTIN(DebugBreakTrampoline, CodeStubAssembler) {
#ifdef V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE
auto dispatch_handle =
UncheckedParameter<JSDispatchHandleT>(Descriptor::kJSDispatchHandle);
TNode<Uint16T> expected_parameter_count =
LoadParameterCountFromJSDispatchTable(dispatch_handle);
TNode<Uint16T> expected_parameter_count = DynamicJSParameterCount();
#else
auto dispatch_handle = InvalidDispatchHandleConstant();
TNode<Uint16T> expected_parameter_count = Uint16Constant(0);
Expand Down
5 changes: 3 additions & 2 deletions deps/v8/src/builtins/builtins-object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Tagged<Object> ObjectLookupAccessor(Isolate* isolate,
switch (it.state()) {
case LookupIterator::INTERCEPTOR:
case LookupIterator::TRANSITION:
case LookupIterator::STRING_LOOKUP_START_OBJECT:
UNREACHABLE();

case LookupIterator::ACCESS_CHECK:
Expand Down Expand Up @@ -152,7 +153,6 @@ Tagged<Object> ObjectLookupAccessor(Isolate* isolate,
}
return ObjectLookupAccessor(isolate, prototype, key, component);
}
case LookupIterator::STRING_LOOKUP_START_OBJECT:
case LookupIterator::WASM_OBJECT:
continue; // Continue to the prototype, if present.
case LookupIterator::TYPED_ARRAY_INDEX_NOT_FOUND:
Expand Down Expand Up @@ -181,7 +181,8 @@ Tagged<Object> ObjectLookupAccessor(Isolate* isolate,
return *AccessorPair::GetComponent(
isolate, holder_realm, Cast<AccessorPair>(maybe_pair), component);
}
continue;
DCHECK(IsAccessorInfo(*maybe_pair));
return ReadOnlyRoots(isolate).undefined_value();
}
}
UNREACHABLE();
Expand Down
4 changes: 1 addition & 3 deletions deps/v8/src/builtins/builtins-utils-gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ class CodeAssemblerState;
void Builtins::Generate_##Name(compiler::CodeAssemblerState* state) { \
Name##Assembler assembler(state); \
state->SetInitialDebugInformation(#Name, __FILE__, __LINE__); \
if (Builtins::KindOf(Builtin::k##Name) == Builtins::TFJ) { \
assembler.PerformStackCheck(assembler.GetJSContextParameter()); \
} \
assembler.EmitBuiltinProlog(Builtin::k##Name); \
assembler.Generate##Name##Impl(); \
} \
void Name##Assembler::Generate##Name##Impl()
Expand Down
24 changes: 6 additions & 18 deletions deps/v8/src/builtins/js-to-wasm.tq
Original file line number Diff line number Diff line change
Expand Up @@ -837,34 +837,22 @@ macro JSToWasmWrapperHelper(
}

transitioning javascript builtin JSToWasmWrapper(
js-implicit context: NativeContext, receiver: JSAny, target: JSFunction,
dispatchHandle: DispatchHandle)(...arguments): JSAny {
// This is a generic builtin that can be installed on functions with different
// parameter counts, so we need to support that.
SetSupportsDynamicParameterCount(target, dispatchHandle);

js-implicit context: NativeContext, receiver: JSAny, target: JSFunction)(
...arguments): JSAny {
return JSToWasmWrapperHelper(
context, receiver, target, arguments, Promise::kNoPromise);
}

transitioning javascript builtin WasmPromising(
js-implicit context: NativeContext, receiver: JSAny, target: JSFunction,
dispatchHandle: DispatchHandle)(...arguments): JSAny {
// This is a generic builtin that can be installed on functions with different
// parameter counts, so we need to support that.
SetSupportsDynamicParameterCount(target, dispatchHandle);

js-implicit context: NativeContext, receiver: JSAny, target: JSFunction)(
...arguments): JSAny {
return JSToWasmWrapperHelper(
context, receiver, target, arguments, Promise::kPromise);
}

transitioning javascript builtin WasmStressSwitch(
js-implicit context: NativeContext, receiver: JSAny, target: JSFunction,
dispatchHandle: DispatchHandle)(...arguments): JSAny {
// This is a generic builtin that can be installed on functions with different
// parameter counts, so we need to support that.
SetSupportsDynamicParameterCount(target, dispatchHandle);

js-implicit context: NativeContext, receiver: JSAny, target: JSFunction)(
...arguments): JSAny {
return JSToWasmWrapperHelper(
context, receiver, target, arguments, Promise::kStressSwitch);
}
Expand Down
34 changes: 17 additions & 17 deletions deps/v8/src/builtins/js-trampoline-assembler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,27 @@ void JSTrampolineAssembler::TailCallJSFunction(
expected_parameter_count);
}

void JSTrampolineAssembler::CompileLazy(TNode<JSFunction> function,
TNode<Context> context) {
TNode<Uint16T> JSTrampolineAssembler::LoadIncomingParameterCount() {
#ifdef V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE
// TODO(crbug.com/465487205): Until incoming JSDispatchHandles are kept alive
// via the stack, the parameter count must be loaded at the very start of the
// builtin before any runtime call or stack check can trigger a GC and sweep
// an unrooted dispatch table entry.
DCHECK(IsAtStart());
auto dispatch_handle =
UncheckedParameter<JSDispatchHandleT>(Descriptor::kDispatchHandle);
TNode<Uint16T> expected_parameter_count =
LoadParameterCountFromJSDispatchTable(dispatch_handle);
return LoadParameterCountFromJSDispatchTable(dispatch_handle);
#else
CHECK(!V8_ENABLE_SANDBOX_BOOL);
TNode<Uint16T> expected_parameter_count = Uint16Constant(0);
return Uint16Constant(0);
#endif
}

TF_BUILTIN(CompileLazy, JSTrampolineAssembler) {
TNode<Uint16T> expected_parameter_count = LoadIncomingParameterCount();

auto function = Parameter<JSFunction>(Descriptor::kTarget);
auto context = Parameter<Context>(Descriptor::kContext);

// First lookup code, maybe we don't need to compile!
Label compile_function(this, Label::kDeferred);
Expand Down Expand Up @@ -98,16 +108,10 @@ void JSTrampolineAssembler::CompileLazy(TNode<JSFunction> function,
TailCallJSFunction(function, expected_parameter_count);
}

TF_BUILTIN(CompileLazy, JSTrampolineAssembler) {
auto function = Parameter<JSFunction>(Descriptor::kTarget);
auto context = Parameter<Context>(Descriptor::kContext);

CompileLazy(function, context);
}


template <typename Function>
void JSTrampolineAssembler::TieringBuiltinImpl(const Function& Impl) {
TNode<Uint16T> expected_parameter_count = LoadIncomingParameterCount();

auto function = Parameter<JSFunction>(Descriptor::kTarget);
auto context = Parameter<Context>(Descriptor::kContext);
auto argc = UncheckedParameter<Int32T>(Descriptor::kActualArgumentsCount);
Expand All @@ -116,13 +120,9 @@ void JSTrampolineAssembler::TieringBuiltinImpl(const Function& Impl) {
#ifdef V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE
auto dispatch_handle =
UncheckedParameter<JSDispatchHandleT>(Descriptor::kDispatchHandle);
TNode<Uint16T> expected_parameter_count =
LoadParameterCountFromJSDispatchTable(dispatch_handle);
#else
CHECK(!V8_ENABLE_SANDBOX_BOOL);
auto dispatch_handle = LoadObjectField<JSDispatchHandleT>(
function, offsetof(JSFunction, dispatch_handle_));
TNode<Uint16T> expected_parameter_count = Uint16Constant(0);
#endif

// Apply the actual tiering. This function must uninstall the tiering builtin.
Expand Down
3 changes: 1 addition & 2 deletions deps/v8/src/builtins/js-trampoline-assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class JSTrampolineAssembler : public CodeStubAssembler {
template <typename Function>
void TieringBuiltinImpl(const Function& Impl);


void CompileLazy(TNode<JSFunction> function, TNode<Context> context);
TNode<Uint16T> LoadIncomingParameterCount();
};

} // namespace v8::internal
Expand Down
7 changes: 2 additions & 5 deletions deps/v8/src/builtins/wasm-interpreter-wrappers.tq
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ macro LocationAllocatorForWasmInterpreterReturns(stack: RawPtr):


transitioning javascript builtin JSToWasmInterpreterWrapper(
js-implicit context: NativeContext, receiver: JSAny, target: JSFunction,
dispatchHandle: DispatchHandle)(...arguments): JSAny {
// This is a generic builtin that can be installed on functions with different
// parameter counts, so we need to support that.
SetSupportsDynamicParameterCount(target, dispatchHandle);
js-implicit context: NativeContext, receiver: JSAny, target: JSFunction)(
...arguments): JSAny {
const functionData = target.shared_function_info.wasm_exported_function_data;

const internalFunction = functionData.internal;
Expand Down
45 changes: 38 additions & 7 deletions deps/v8/src/codegen/code-stub-assembler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,25 @@ TNode<Uint16T> CodeStubAssembler::LoadParameterCountFromJSDispatchTable(
return Load<Uint16T>(table, offset);
}

TNode<Uint16T> CodeStubAssembler::GetParameterCountFromDispatchHandle() {
// TODO(crbug.com/465487205): Until incoming JSDispatchHandles are kept alive
// via the stack, the parameter count must be loaded at the very start of the
// builtin before any runtime call or stack check can trigger a GC and sweep
// an unrooted dispatch table entry.
DCHECK(IsAtStart());
DCHECK(IsJSFunctionCall());
TNode<JSDispatchHandleT> dispatch_handle;
#ifdef V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE
dispatch_handle = GetJSDispatchHandleParameter();
#else
TNode<JSFunction> function =
UncheckedParameter<JSFunction>(kTargetParameterIndex);
dispatch_handle = LoadObjectField<JSDispatchHandleT>(
function, offsetof(JSFunction, dispatch_handle_));
#endif
return LoadParameterCountFromJSDispatchTable(dispatch_handle);
}

void CodeStubAssembler::TailCallJSCode(
TNode<Code> code, TNode<Context> context, TNode<JSFunction> function,
TNode<Object> new_target, TNode<Int32T> arg_count,
Expand Down Expand Up @@ -2353,13 +2372,6 @@ TNode<TrustedObject> CodeStubAssembler::ResolveTrustedPointerHandle(

#endif // V8_ENABLE_SANDBOX

void CodeStubAssembler::SetSupportsDynamicParameterCount(
TNode<JSFunction> callee, TNode<JSDispatchHandleT> dispatch_handle) {
TNode<Uint16T> dynamic_parameter_count =
LoadParameterCountFromJSDispatchTable(dispatch_handle);
SetDynamicJSParameterCount(dynamic_parameter_count);
}

TNode<JSDispatchHandleT> CodeStubAssembler::InvalidDispatchHandleConstant() {
return UncheckedCast<JSDispatchHandleT>(
Uint32Constant(kInvalidDispatchHandle.value()));
Expand Down Expand Up @@ -20943,6 +20955,25 @@ IntegerLiteral CodeStubAssembler::ConstexprIntegerLiteralBitwiseOr(
return lhs | rhs;
}

void CodeStubAssembler::EmitBuiltinProlog(Builtin builtin_id) {
if (Builtins::KindOf(builtin_id) == Builtins::TFJ) {
if (Builtins::IsJSTrampoline(builtin_id)) {
// JS trampolines (such as generic Wasm wrappers and DebugBreakTrampoline)
// can be installed on functions with different parameter counts and load
// the expected parameter count from the JSDispatchTable entry (used to
// clean up the caller's argument slots in PopAndReturn for Wasm wrappers,
// or re-verified in TailCallJSCode for DebugBreakTrampoline).
// TODO(crbug.com/465487205): Until incoming JSDispatchHandles are kept
// alive via the stack, this load must happen before the stack check
// below, as Runtime::kStackGuard can trigger a GC that sweeps an unrooted
// dispatch table entry if the JSFunction's dispatch_handle field in the
// heap was concurrently overwritten.
SetDynamicJSParameterCount(GetParameterCountFromDispatchHandle());
}
PerformStackCheck(GetJSContextParameter());
}
}

void CodeStubAssembler::PerformStackCheck(TNode<Context> context) {
Label ok(this), stack_check_interrupt(this, Label::kDeferred);

Expand Down
22 changes: 3 additions & 19 deletions deps/v8/src/codegen/code-stub-assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4509,6 +4509,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Load the parameter count of a JSDispatchTable entry.
TNode<Uint16T> LoadParameterCountFromJSDispatchTable(
TNode<JSDispatchHandleT> dispatch_handle);
// Load the parameter count of the incoming JS call's dispatch handle.
TNode<Uint16T> GetParameterCountFromDispatchHandle();

TNode<UintPtrT> ComputeJSDispatchTableEntryOffset(
TNode<JSDispatchHandleT> handle);
Expand Down Expand Up @@ -4539,25 +4541,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<JSDispatchHandleT> dispatch_handle,
TNode<Uint16T> expected_parameter_count);

// Indicate that this code must support a dynamic parameter count.
//
// This is used for builtins that must work on functions with different
// parameter counts. In that case, the true JS parameter count is only known
// at runtime and must be obtained in order to compute the total number of
// arguments (which may include padding arguments). The parameter count is
// subsequently available through the corresponding CodeAssembler accessors.
// The target function object and the dispatch handle need to be passed in
// and are used to obtain the actual parameter count of the called function.
//
// This should generally be invoked directly at the start of the function.
//
// TODO(saelo): it would be a bit nicer if this would happen automatically in
// the function prologue for functions marked as requiring this (e.g. via the
// call descriptor). It's not clear if that's worth the effort though for the
// handful of builtins that need this.
void SetSupportsDynamicParameterCount(
TNode<JSFunction> callee, TNode<JSDispatchHandleT> dispatch_handle);

// Figure out the SFI's code object using its data field.
// If |data_type_out| is provided, the instance type of the function data will
// be stored in it. In case the code object is a builtin (data is a Smi),
Expand Down Expand Up @@ -4792,6 +4775,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
#endif
}

void EmitBuiltinProlog(Builtin builtin_id);
void PerformStackCheck(TNode<Context> context);

void SetPropertyLength(TNode<Context> context, TNode<JSAny> array,
Expand Down
37 changes: 13 additions & 24 deletions deps/v8/src/codegen/s390/macro-assembler-s390.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4564,16 +4564,12 @@ void MacroAssembler::SwapFloat32(DoubleRegister src, MemOperand dst,

void MacroAssembler::SwapFloat32(MemOperand src, MemOperand dst,
DoubleRegister scratch) {
// push d0, to be used as scratch
lay(sp, MemOperand(sp, -kDoubleSize));
StoreF64(d0, MemOperand(sp));
DCHECK(!AreAliased(scratch, kDoubleRegZero));
LoadF32(scratch, src);
LoadF32(d0, dst);
LoadF32(kDoubleRegZero, dst);
StoreF32(scratch, dst);
StoreF32(d0, src);
// restore d0
LoadF64(d0, MemOperand(sp));
lay(sp, MemOperand(sp, kDoubleSize));
StoreF32(kDoubleRegZero, src);
lzdr(kDoubleRegZero);
}

void MacroAssembler::SwapDouble(DoubleRegister src, DoubleRegister dst,
Expand All @@ -4595,16 +4591,12 @@ void MacroAssembler::SwapDouble(DoubleRegister src, MemOperand dst,

void MacroAssembler::SwapDouble(MemOperand src, MemOperand dst,
DoubleRegister scratch) {
// push d0, to be used as scratch
lay(sp, MemOperand(sp, -kDoubleSize));
StoreF64(d0, MemOperand(sp));
DCHECK(!AreAliased(scratch, kDoubleRegZero));
LoadF64(scratch, src);
LoadF64(d0, dst);
LoadF64(kDoubleRegZero, dst);
StoreF64(scratch, dst);
StoreF64(d0, src);
// restore d0
LoadF64(d0, MemOperand(sp));
lay(sp, MemOperand(sp, kDoubleSize));
StoreF64(kDoubleRegZero, src);
lzdr(kDoubleRegZero);
}

void MacroAssembler::SwapSimd128(Simd128Register src, Simd128Register dst,
Expand All @@ -4625,16 +4617,13 @@ void MacroAssembler::SwapSimd128(Simd128Register src, MemOperand dst,

void MacroAssembler::SwapSimd128(MemOperand src, MemOperand dst,
Simd128Register scratch) {
// push d0, to be used as scratch
lay(sp, MemOperand(sp, -kSimd128Size));
StoreV128(d0, MemOperand(sp), ip);
DCHECK(!AreAliased(scratch, kDoubleRegZero));
LoadV128(scratch, src, ip);
LoadV128(d0, dst, ip);
LoadV128(kDoubleRegZero, dst, ip);
StoreV128(scratch, dst, ip);
StoreV128(d0, src, ip);
// restore d0
LoadV128(d0, MemOperand(sp), ip);
lay(sp, MemOperand(sp, kSimd128Size));
StoreV128(kDoubleRegZero, src, ip);
vx(kDoubleRegZero, kDoubleRegZero, kDoubleRegZero, Condition(0), Condition(0),
Condition(0));
}

void MacroAssembler::ComputeCodeStartAddress(Register dst) {
Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/codegen/turboshaft-builtins-assembler-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ class BuiltinsReducer : public Next {
// TODO(nicohartmann): CSA tracks some debug information here.
// Emit stack check.
if (Builtins::KindOf(builtin_id) == Builtins::TFJ_TSA) {
// JS trampolines require loading the dynamic JS parameter count before
// the stack check (see CodeStubAssembler::EmitBuiltinProlog) and are not
// currently supported in TSA.
DCHECK(!Builtins::IsJSTrampoline(builtin_id));
__ PerformStackCheck(__ JSContextParameter());
}
}
Expand Down
Loading
Loading