Commit 8c830bfd authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[wasm] Torqueify some builtins.

- Implements WasmInt32ToHeapNumber, WasmTaggedNonSmiToInt32, and
  WasmTaggedToFloat64 as Torque builtins.

Bug: v8:10070
Change-Id: I8b16d000b5283f27f7762341e9dbbaf5ab3ebb62
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2173395Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67544}
parent 7b582b61
......@@ -1108,6 +1108,7 @@ torque_files = [
"src/builtins/typed-array-sort.tq",
"src/builtins/typed-array-subarray.tq",
"src/builtins/typed-array.tq",
"src/builtins/wasm.tq",
"src/ic/handler-configuration.tq",
"src/objects/allocation-site.tq",
"src/objects/api-callbacks.tq",
......
......@@ -899,9 +899,13 @@ extern macro SmiToTaggedIndex(Smi): TaggedIndex;
extern macro RoundIntPtrToFloat64(intptr): float64;
extern macro ChangeFloat32ToFloat64(float32): float64;
extern macro ChangeNumberToFloat64(Number): float64;
extern macro ChangeTaggedNonSmiToInt32(implicit context: Context)(JSAnyNotSmi):
int32;
extern macro ChangeTaggedToFloat64(implicit context: Context)(JSAny): float64;
extern macro ChangeFloat64ToTagged(float64): Number;
extern macro ChangeFloat64ToUintPtr(float64): uintptr;
extern macro ChangeFloat64ToIntPtr(float64): intptr;
extern macro ChangeInt32ToFloat64(int32): float64;
extern macro ChangeInt32ToIntPtr(int32): intptr; // Sign-extends.
extern macro ChangeUint32ToWord(uint32): uintptr; // Doesn't sign-extend.
extern macro LoadNativeContext(Context): NativeContext;
......
......@@ -839,11 +839,8 @@ namespace internal {
/* Wasm */ \
ASM(WasmCompileLazy, Dummy) \
ASM(WasmDebugBreak, Dummy) \
TFC(WasmInt32ToHeapNumber, WasmInt32ToHeapNumber) \
TFC(WasmTaggedNonSmiToInt32, WasmTaggedNonSmiToInt32) \
TFC(WasmFloat32ToNumber, WasmFloat32ToNumber) \
TFC(WasmFloat64ToNumber, WasmFloat64ToNumber) \
TFC(WasmTaggedToFloat64, WasmTaggedToFloat64) \
TFS(WasmAllocateJSArray, kArraySize) \
TFC(WasmAtomicNotify, WasmAtomicNotify) \
TFS(WasmGetOwnProperty, kObject, kUniqueName) \
......
......@@ -37,17 +37,6 @@ class WasmBuiltinsAssembler : public CodeStubAssembler {
}
};
TF_BUILTIN(WasmInt32ToHeapNumber, WasmBuiltinsAssembler) {
TNode<Int32T> val = UncheckedCast<Int32T>(Parameter(Descriptor::kValue));
Return(AllocateHeapNumberWithValue(ChangeInt32ToFloat64(val)));
}
TF_BUILTIN(WasmTaggedNonSmiToInt32, WasmBuiltinsAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Return(
ChangeTaggedNonSmiToInt32(context, CAST(Parameter(Descriptor::kValue))));
}
TF_BUILTIN(WasmFloat32ToNumber, WasmBuiltinsAssembler) {
TNode<Float32T> val = UncheckedCast<Float32T>(Parameter(Descriptor::kValue));
Return(ChangeFloat32ToTagged(val));
......@@ -58,11 +47,6 @@ TF_BUILTIN(WasmFloat64ToNumber, WasmBuiltinsAssembler) {
Return(ChangeFloat64ToTagged(val));
}
TF_BUILTIN(WasmTaggedToFloat64, WasmBuiltinsAssembler) {
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Return(ChangeTaggedToFloat64(context, CAST(Parameter(Descriptor::kValue))));
}
TF_BUILTIN(WasmStackGuard, WasmBuiltinsAssembler) {
TNode<WasmInstanceObject> instance = LoadInstanceFromFrame();
TNode<Context> context = LoadContextFromInstance(instance);
......
......@@ -213,6 +213,9 @@ Convert<float64, Number>(n: Number): float64 {
Convert<uintptr, Number>(n: Number): uintptr {
return ChangeUintPtrNumberToUintPtr(n);
}
Convert<float64, int32>(f: int32): float64 {
return ChangeInt32ToFloat64(f);
}
Convert<float64, float32>(f: float32): float64 {
return ChangeFloat32ToFloat64(f);
}
......
// Copyright 2020 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.
namespace wasm {
builtin WasmInt32ToHeapNumber(val: int32): HeapNumber {
return AllocateHeapNumberWithValue(Convert<float64>(val));
}
builtin WasmTaggedNonSmiToInt32(implicit context: Context)(val: JSAnyNotSmi):
int32 {
return ChangeTaggedNonSmiToInt32(val);
}
builtin WasmTaggedToFloat64(implicit context: Context)(val: JSAny): float64 {
return ChangeTaggedToFloat64(val);
}
}
......@@ -85,7 +85,7 @@ void CallDescriptors::InitializeOncePerProcess() {
DCHECK(!AllocateDescriptor{}.HasContextParameter());
DCHECK(!AllocateHeapNumberDescriptor{}.HasContextParameter());
DCHECK(!AbortDescriptor{}.HasContextParameter());
DCHECK(!WasmInt32ToHeapNumberDescriptor{}.HasContextParameter());
DCHECK(!WasmFloat32ToNumberDescriptor{}.HasContextParameter());
DCHECK(!WasmFloat64ToNumberDescriptor{}.HasContextParameter());
}
......@@ -377,16 +377,6 @@ void ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void WasmInt32ToHeapNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount);
}
void WasmTaggedNonSmiToInt32Descriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount);
}
#if !V8_TARGET_ARCH_IA32
// We need a custom descriptor on ia32 to avoid using xmm0.
void WasmFloat32ToNumberDescriptor::InitializePlatformSpecific(
......@@ -401,11 +391,6 @@ void WasmFloat64ToNumberDescriptor::InitializePlatformSpecific(
}
#endif // !V8_TARGET_ARCH_IA32
void WasmTaggedToFloat64Descriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount);
}
void WasmMemoryGrowDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount);
......
......@@ -90,11 +90,8 @@ namespace internal {
V(TypeConversionStackParameter) \
V(Typeof) \
V(Void) \
V(WasmInt32ToHeapNumber) \
V(WasmTaggedNonSmiToInt32) \
V(WasmFloat32ToNumber) \
V(WasmFloat64ToNumber) \
V(WasmTaggedToFloat64) \
V(WasmAtomicNotify) \
V(WasmI32AtomicWait32) \
V(WasmI32AtomicWait64) \
......@@ -1318,22 +1315,6 @@ class RunMicrotasksDescriptor final : public CallInterfaceDescriptor {
static Register MicrotaskQueueRegister();
};
class WasmInt32ToHeapNumberDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS_NO_CONTEXT(kValue)
DEFINE_RESULT_AND_PARAMETER_TYPES(MachineType::AnyTagged(), // result
MachineType::Int32()) // value
DECLARE_DESCRIPTOR(WasmInt32ToHeapNumberDescriptor, CallInterfaceDescriptor)
};
class WasmTaggedNonSmiToInt32Descriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kValue)
DEFINE_RESULT_AND_PARAMETER_TYPES(MachineType::Int32(), // result
MachineType::AnyTagged()) // value
DECLARE_DESCRIPTOR(WasmTaggedNonSmiToInt32Descriptor, CallInterfaceDescriptor)
};
class WasmFloat32ToNumberDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS_NO_CONTEXT(kValue)
......@@ -1350,14 +1331,6 @@ class WasmFloat64ToNumberDescriptor final : public CallInterfaceDescriptor {
DECLARE_DESCRIPTOR(WasmFloat64ToNumberDescriptor, CallInterfaceDescriptor)
};
class WasmTaggedToFloat64Descriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kValue)
DEFINE_RESULT_AND_PARAMETER_TYPES(MachineType::Float64(), // result
MachineType::AnyTagged()) // value
DECLARE_DESCRIPTOR(WasmTaggedToFloat64Descriptor, CallInterfaceDescriptor)
};
class WasmMemoryGrowDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS_NO_CONTEXT(kNumPages)
......
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