Commit 425799f3 authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

Add torque/csa functionality in preparation for Object.fromEntries

Change-Id: Ie7f3cec3ae6541f46b3f43c83bd9d53de7614d20
Reviewed-on: https://chromium-review.googlesource.com/c/1329689
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57425}
parent 4235fc0b
......@@ -65,6 +65,8 @@ type NumberDictionary extends HeapObject
type NativeContextSlot generates 'TNode<IntPtrT>' constexpr 'int32_t';
const ARRAY_JOIN_STACK_INDEX: constexpr NativeContextSlot
generates 'Context::ARRAY_JOIN_STACK_INDEX';
const OBJECT_FUNCTION_INDEX: constexpr NativeContextSlot
generates 'Context::OBJECT_FUNCTION_INDEX';
extern operator '[]' macro LoadContextElement(
NativeContext, NativeContextSlot): Object;
extern operator '[]=' macro StoreContextElement(
......@@ -168,6 +170,10 @@ const kCalledNonCallable: constexpr MessageTemplate
generates 'MessageTemplate::kCalledNonCallable';
const kCalledOnNullOrUndefined: constexpr MessageTemplate
generates 'MessageTemplate::kCalledOnNullOrUndefined';
const kIteratorValueNotAnObject: constexpr MessageTemplate
generates 'MessageTemplate::kIteratorValueNotAnObject';
const kNotIterable: constexpr MessageTemplate
generates 'MessageTemplate::kNotIterable';
const kMaxSafeInteger: constexpr float64 generates 'kMaxSafeInteger';
const kStringMaxLength: constexpr int31 generates 'String::kMaxLength';
......@@ -252,6 +258,8 @@ extern transitioning macro GetProperty(implicit context: Context)(
Object, Object): Object;
extern transitioning builtin SetProperty(implicit context: Context)(
Object, Object, Object);
extern transitioning builtin SetPropertyInLiteral(implicit context: Context)(
Object, Object, Object);
extern transitioning builtin DeleteProperty(implicit context: Context)(
Object, Object, LanguageMode);
extern transitioning builtin HasProperty(implicit context: Context)(
......@@ -806,6 +814,7 @@ UnsafeCast<String>(o: Object): String {
// RawCasts should *never* be used anywhere in Torque code except for
// in Torque-based UnsafeCast operators preceeded by an appropriate
// type check().
extern macro RawCastObjectToJSFunction(Object): JSFunction;
extern macro RawCastObjectToJSArgumentsObjectWithLength(Object):
JSArgumentsObjectWithLength;
extern macro RawCastObjectToFastJSArray(Object): FastJSArray;
......@@ -878,6 +887,38 @@ Cast<FastJSArrayForCopy>(implicit context: Context)(o: Object):
}
}
UnsafeCast<JSFunction>(implicit context: Context)(o: Object): JSFunction {
assert(IsJSFunction(Cast<HeapObject>(o) otherwise unreachable));
return RawCastObjectToJSFunction(o);
}
Cast<JSFunction>(implicit context: Context)(o: Object): JSFunction
labels CastError {
if (IsJSFunction(Cast<HeapObject>(o) otherwise CastError)) {
return UnsafeCast<JSFunction>(o);
} else {
goto CastError;
}
}
Cast<Map>(o: Object): Map
labels CastError {
if (IsMap(Cast<HeapObject>(o) otherwise CastError)) {
return UnsafeCast<Map>(o);
} else {
goto CastError;
}
}
Cast<JSReceiver>(o: Object): JSReceiver
labels CastError {
if (IsJSReceiver(Cast<HeapObject>(o) otherwise CastError)) {
return UnsafeCast<JSReceiver>(o);
} else {
goto CastError;
}
}
const kCOWMap: Map = UnsafeCast<Map>(LoadRoot(kFixedCOWArrayMapRootIndex));
const kEmptyFixedArray: FixedArrayBase =
UnsafeCast<FixedArrayBase>(LoadRoot(kEmptyFixedArrayRootIndex));
......@@ -947,6 +988,9 @@ extern macro StoreFixedArrayElementSmi(
extern operator '.instance_type' macro LoadMapInstanceType(Map): int32;
extern operator '.prototype_or_initial_map' macro
LoadJSFunctionPrototypeOrInitialMap(JSFunction): Object;
extern macro LoadFixedDoubleArrayElement(FixedDoubleArray, Smi): float64;
extern macro Float64SilenceNaN(float64): float64;
......@@ -1011,6 +1055,8 @@ extern macro CopyFixedArrayElements(
extern macro AllocateJSArray(constexpr ElementsKind, Map, intptr, Smi): JSArray;
extern macro AllocateJSArray(constexpr ElementsKind, Map, Smi, Smi): JSArray;
extern macro AllocateJSObjectFromMap(Map): HeapObject;
extern operator '[]=' macro StoreFixedDoubleArrayElementSmi(
FixedDoubleArray, Smi, float64): void;
......@@ -1020,6 +1066,11 @@ extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, intptr): float64
labels IfHole;
extern macro StoreFixedDoubleArrayHoleSmi(FixedDoubleArray, Smi): void;
macro GetObjectFunction(implicit context: Context)(): JSFunction {
return UnsafeCast<JSFunction>(
LoadNativeContext(context)[OBJECT_FUNCTION_INDEX]);
}
extern transitioning macro Call(Context, Callable, Object): Object;
extern transitioning macro Call(Context, Callable, Object, Object): Object;
extern transitioning macro Call(
......@@ -1111,6 +1162,8 @@ extern macro TransitionElementsKind(JSObject, Map, ElementsKind, ElementsKind):
extern macro IsCallable(HeapObject): bool;
extern macro IsJSArray(HeapObject): bool;
extern macro IsMap(HeapObject): bool;
extern macro IsJSFunction(HeapObject): bool;
extern macro IsJSReceiver(HeapObject): bool;
extern macro TaggedIsCallable(Object): bool;
extern macro IsDetachedBuffer(JSArrayBuffer): bool;
......
......@@ -427,6 +427,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
return TNode<JSArray>::UncheckedCast(p_o);
}
TNode<JSFunction> RawCastObjectToJSFunction(TNode<Object> p_o) {
return TNode<JSFunction>::UncheckedCast(p_o);
}
Node* MatchesParameterMode(Node* value, ParameterMode mode);
#define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName) \
......@@ -1221,6 +1225,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<BytecodeArray> LoadSharedFunctionInfoBytecodeArray(
SloppyTNode<SharedFunctionInfo> shared);
TNode<Object> LoadJSFunctionPrototypeOrInitialMap(
TNode<JSFunction> function) {
return LoadObjectField(function, JSFunction::kPrototypeOrInitialMapOffset);
}
void StoreObjectByteNoWriteBarrier(TNode<HeapObject> object, int offset,
TNode<Word32T> value);
......
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