Commit f2d604aa authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[wasm] Torqueify WasmGetOwnProperty.

- Reworks it to use a builtin to GetProperty, after making sure it's
  an "own" property. This reduces the size of the builtin by 2/3 (from
  1476 to 596 bytes on x64).

Change-Id: I41c1642369f73e5322790f3091b8cea9a650a529
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2181642Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67693}
parent db9d56f1
......@@ -844,7 +844,6 @@ namespace internal {
TFS(WasmAllocateArray, kMapIndex, kLength, kElementSize) \
TFS(WasmAllocateStruct, kMapIndex) \
TFC(WasmAtomicNotify, WasmAtomicNotify) \
TFS(WasmGetOwnProperty, kObject, kUniqueName) \
TFC(WasmI32AtomicWait32, WasmI32AtomicWait32) \
TFC(WasmI32AtomicWait64, WasmI32AtomicWait64) \
TFC(WasmI64AtomicWait32, WasmI64AtomicWait32) \
......
......@@ -56,37 +56,6 @@ TF_BUILTIN(WasmFloat64ToNumber, WasmBuiltinsAssembler) {
Return(ChangeFloat64ToTagged(val));
}
TF_BUILTIN(WasmGetOwnProperty, CodeStubAssembler) {
TNode<Object> object = CAST(Parameter(Descriptor::kObject));
TNode<Name> unique_name = CAST(Parameter(Descriptor::kUniqueName));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TVariable<Object> var_value(this);
Label if_found(this), if_not_found(this), if_bailout(this);
GotoIf(TaggedIsSmi(object), &if_not_found);
GotoIf(IsUndefined(object), &if_not_found);
TNode<Map> map = LoadMap(CAST(object));
TNode<Uint16T> instance_type = LoadMapInstanceType(map);
GotoIfNot(IsJSReceiverInstanceType(instance_type), &if_not_found);
TryGetOwnProperty(context, CAST(object), CAST(object), map, instance_type,
unique_name, &if_found, &var_value, &if_not_found,
&if_bailout);
BIND(&if_found);
Return(var_value.value());
BIND(&if_not_found);
Return(UndefinedConstant());
BIND(&if_bailout); // This shouldn't happen when called from wasm compiler
Unreachable();
}
TF_BUILTIN(WasmAtomicNotify, WasmBuiltinsAssembler) {
TNode<Uint32T> address =
UncheckedCast<Uint32T>(Parameter(Descriptor::kAddress));
......
......@@ -168,6 +168,37 @@ namespace wasm {
return AllocateJSArray(ElementsKind::PACKED_ELEMENTS, map, size, size);
}
extern macro TryHasOwnProperty(HeapObject, Map, InstanceType, Name): never
labels Found, NotFound, Bailout;
type OnNonExistent constexpr 'OnNonExistent';
const kReturnUndefined: constexpr OnNonExistent
generates 'OnNonExistent::kReturnUndefined';
extern macro SmiConstant(constexpr OnNonExistent): Smi;
extern transitioning builtin GetPropertyWithReceiver(
implicit context: Context)(JSAny, Name, JSAny, Smi): JSAny;
transitioning builtin WasmGetOwnProperty(implicit context: Context)(
object: Object, uniqueName: Name): JSAny {
try {
const heapObject: HeapObject =
TaggedToHeapObject(object) otherwise NotFound;
const receiver: JSReceiver =
Cast<JSReceiver>(heapObject) otherwise NotFound;
try {
TryHasOwnProperty(
receiver, receiver.map, receiver.instanceType, uniqueName)
otherwise Found, NotFound, Bailout;
} label Found {
tail GetPropertyWithReceiver(
receiver, uniqueName, receiver, SmiConstant(kReturnUndefined));
}
} label NotFound deferred {
return Undefined;
} label Bailout deferred {
unreachable;
}
}
// Trap builtins.
builtin WasmTrap(error: Smi): JSAny {
......
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