Commit 20d29a36 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] check TNode return types of CSA macros

This disallows using CSA macros from Torque that have a Node* return
type instead of TNode<>. By enforcing CSA types at the boundary between
CSA and Torque, we can ensure that the Torque types and the CSA types
match.

As a drive-by, this CL adds a bit more of CSA typing where it made sense.

Bug: v8:7793, v8:6949

Change-Id: I12ea0337c628105ea3c420be747ae50d3a172547
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660481
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62293}
parent 31a951d8
......@@ -56,7 +56,7 @@ namespace array_join {
assert(!IsDetachedBuffer(typedArray.buffer));
return typed_array::LoadFixedTypedArrayElementAsTagged(
typedArray.data_ptr, UnsafeCast<Smi>(k),
typed_array::KindForArrayType<T>(), SMI_PARAMETERS);
typed_array::KindForArrayType<T>());
}
transitioning builtin ConvertToLocaleString(
......
......@@ -189,9 +189,7 @@ type LayoutDescriptor extends ByteArray
type TransitionArray extends WeakFixedArray
generates 'TNode<TransitionArray>';
// InstanceType actually extends uint16, but a bunch of methods in
// CodeStubAssembler expect a TNode<Int32T>, so keeping it signed for now.
type InstanceType extends int16 constexpr 'InstanceType';
type InstanceType extends uint16 constexpr 'InstanceType';
extern class Map extends HeapObject {
instance_size_in_words: uint8;
......@@ -342,8 +340,8 @@ extern class JSFunction extends JSObject {
}
extern class JSProxy extends JSReceiver {
target: Object;
handler: Object;
target: JSReceiver | Null;
handler: JSReceiver | Null;
}
// Just a starting shape for JSObject; properties can move after initialization.
......@@ -763,8 +761,6 @@ type LanguageMode extends Smi constexpr 'LanguageMode';
type ExtractFixedArrayFlags
generates 'TNode<Smi>'
constexpr 'CodeStubAssembler::ExtractFixedArrayFlags';
type ParameterMode
generates 'TNode<Int32T>' constexpr 'ParameterMode';
type WriteBarrierMode
generates 'TNode<Int32T>' constexpr 'WriteBarrierMode';
......@@ -1128,11 +1124,6 @@ const false: constexpr bool generates 'false';
const kStrict: constexpr LanguageMode generates 'LanguageMode::kStrict';
const kSloppy: constexpr LanguageMode generates 'LanguageMode::kSloppy';
const SMI_PARAMETERS: constexpr ParameterMode
generates 'CodeStubAssembler::SMI_PARAMETERS';
const INTPTR_PARAMETERS: constexpr ParameterMode
generates 'CodeStubAssembler::INTPTR_PARAMETERS';
const SKIP_WRITE_BARRIER:
constexpr WriteBarrierMode generates 'SKIP_WRITE_BARRIER';
const UNSAFE_SKIP_WRITE_BARRIER:
......@@ -2059,7 +2050,7 @@ extern macro ChangeInt32ToIntPtr(int32): intptr; // Sign-extends.
extern macro ChangeUint32ToWord(uint32): uintptr; // Doesn't sign-extend.
extern macro LoadNativeContext(Context): NativeContext;
extern macro TruncateFloat64ToFloat32(float64): float32;
extern macro TruncateHeapNumberValueToWord32(Number): int32;
extern macro TruncateHeapNumberValueToWord32(HeapNumber): int32;
extern macro LoadJSArrayElementsMap(constexpr ElementsKind, Context): Map;
extern macro LoadJSArrayElementsMap(ElementsKind, Context): Map;
extern macro ChangeNonnegativeNumberToUintPtr(Number): uintptr;
......@@ -2487,7 +2478,7 @@ extern macro AllocateJSArray(constexpr ElementsKind, Map, Smi, Smi): JSArray;
extern macro AllocateJSArray(Map, FixedArrayBase, Smi): JSArray;
extern macro AllocateJSObjectFromMap(Map): JSObject;
extern macro AllocateJSObjectFromMap(
Map, FixedArray, FixedArray, constexpr AllocationFlags,
Map, FixedArray | PropertyArray, FixedArray, constexpr AllocationFlags,
constexpr SlackTrackingMode): JSObject;
extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, Smi): float64
......
......@@ -266,7 +266,8 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
var_list1, argument_offset, mapped_offset,
[this, elements, &current_argument](Node* offset) {
Increment(&current_argument, kSystemPointerSize);
Node* arg = LoadBufferObject(current_argument.value(), 0);
Node* arg = LoadBufferObject(
UncheckedCast<RawPtrT>(current_argument.value()), 0);
StoreNoWriteBarrier(MachineRepresentation::kTagged, elements, offset,
arg);
},
......
......@@ -227,7 +227,7 @@ ArrayBuiltinsAssembler::ArrayBuiltinsAssembler(
VariableList list({&a_, &k_, &to_}, zone());
FastLoopBody body = [&](Node* index) {
GotoIf(IsDetachedBuffer(array_buffer), detached);
GotoIf(IsDetachedBuffer(CAST(array_buffer)), detached);
TNode<RawPtrT> data_ptr = LoadJSTypedArrayBackingStore(typed_array);
Node* value = LoadFixedTypedArrayElementAsTagged(
data_ptr, index, source_elements_kind_, SMI_PARAMETERS);
......@@ -402,7 +402,7 @@ TF_BUILTIN(ArrayPrototypePush, CodeStubAssembler) {
CodeStubArguments args(this, ChangeInt32ToIntPtr(argc));
TNode<Object> receiver = args.GetReceiver();
TNode<JSArray> array_receiver;
Node* kind = nullptr;
TNode<Int32T> kind;
Label fast(this);
BranchIfFastJSArray(receiver, context, &fast, &runtime);
......@@ -709,19 +709,19 @@ TF_BUILTIN(ArrayFrom, ArrayPopulatorAssembler) {
iterator_assembler.GetIterator(context, items, iterator_method);
TNode<Context> native_context = LoadNativeContext(context);
TNode<Object> fast_iterator_result_map =
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX);
TNode<Map> fast_iterator_result_map = CAST(
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX));
Goto(&loop);
BIND(&loop);
{
// Loop while iterator is not done.
TNode<Object> next = iterator_assembler.IteratorStep(
TNode<JSReceiver> next = iterator_assembler.IteratorStep(
context, iterator_record, &loop_done, fast_iterator_result_map);
TVARIABLE(Object, value,
CAST(iterator_assembler.IteratorValue(
context, next, fast_iterator_result_map)));
iterator_assembler.IteratorValue(context, next,
fast_iterator_result_map));
// If a map_function is supplied then call it (using this_arg as
// receiver), on the value returned from the iterator. Exceptions are
......@@ -2035,8 +2035,7 @@ void ArrayBuiltinsAssembler::CreateArrayDispatchSingleArgument(
&normal_sequence);
{
// Make elements kind holey and update elements kind in the type info.
var_elements_kind =
Signed(Word32Or(var_elements_kind.value(), Int32Constant(1)));
var_elements_kind = Word32Or(var_elements_kind.value(), Int32Constant(1));
StoreObjectFieldNoWriteBarrier(
allocation_site, AllocationSite::kTransitionInfoOrBoilerplateOffset,
SmiOr(transition_info, SmiConstant(fast_elements_kind_holey_mask)));
......
......@@ -15,22 +15,23 @@ namespace internal {
// ES6 #sec-boolean.prototype.tostring
TF_BUILTIN(BooleanPrototypeToString, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Node* value = ToThisValue(context, receiver, PrimitiveType::kBoolean,
"Boolean.prototype.toString");
Node* result = LoadObjectField(value, Oddball::kToStringOffset);
TNode<Oddball> value =
CAST(ToThisValue(context, receiver, PrimitiveType::kBoolean,
"Boolean.prototype.toString"));
TNode<String> result = CAST(LoadObjectField(value, Oddball::kToStringOffset));
Return(result);
}
// ES6 #sec-boolean.prototype.valueof
TF_BUILTIN(BooleanPrototypeValueOf, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Node* result = ToThisValue(context, receiver, PrimitiveType::kBoolean,
"Boolean.prototype.valueOf");
TNode<Oddball> result = CAST(ToThisValue(
context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.valueOf"));
Return(result);
}
......
......@@ -66,19 +66,19 @@ class BaseCollectionsAssembler : public CodeStubAssembler {
TNode<Object> iterable);
// Constructs a collection instance. Choosing a fast path when possible.
TNode<Object> AllocateJSCollection(TNode<Context> context,
TNode<JSFunction> constructor,
TNode<Object> new_target);
TNode<JSObject> AllocateJSCollection(TNode<Context> context,
TNode<JSFunction> constructor,
TNode<JSReceiver> new_target);
// Fast path for constructing a collection instance if the constructor
// function has not been modified.
TNode<Object> AllocateJSCollectionFast(TNode<HeapObject> constructor);
TNode<JSObject> AllocateJSCollectionFast(TNode<JSFunction> constructor);
// Fallback for constructing a collection instance if the constructor function
// has been modified.
TNode<Object> AllocateJSCollectionSlow(TNode<Context> context,
TNode<JSFunction> constructor,
TNode<Object> new_target);
TNode<JSObject> AllocateJSCollectionSlow(TNode<Context> context,
TNode<JSFunction> constructor,
TNode<JSReceiver> new_target);
// Allocates the backing store for a collection.
virtual TNode<Object> AllocateTable(Variant variant, TNode<Context> context,
......@@ -320,17 +320,17 @@ void BaseCollectionsAssembler::AddConstructorEntriesFromIterable(
CSA_ASSERT(this, Word32BinaryNot(IsUndefined(iterator.object)));
TNode<Object> fast_iterator_result_map =
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX);
TNode<Map> fast_iterator_result_map = CAST(
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX));
TVARIABLE(Object, var_exception);
Goto(&loop);
BIND(&loop);
{
TNode<Object> next = iterator_assembler.IteratorStep(
TNode<JSReceiver> next = iterator_assembler.IteratorStep(
context, iterator, &exit, fast_iterator_result_map);
TNode<Object> next_value = CAST(iterator_assembler.IteratorValue(
context, next, fast_iterator_result_map));
TNode<Object> next_value = iterator_assembler.IteratorValue(
context, next, fast_iterator_result_map);
AddConstructorEntry(variant, context, collection, add_func, next_value,
nullptr, &if_exception, &var_exception);
Goto(&loop);
......@@ -367,33 +367,33 @@ void BaseCollectionsAssembler::GotoIfInitialAddFunctionModified(
GetAddFunctionNameIndex(variant), if_modified);
}
TNode<Object> BaseCollectionsAssembler::AllocateJSCollection(
TNode<JSObject> BaseCollectionsAssembler::AllocateJSCollection(
TNode<Context> context, TNode<JSFunction> constructor,
TNode<Object> new_target) {
TNode<JSReceiver> new_target) {
TNode<BoolT> is_target_unmodified = WordEqual(constructor, new_target);
return Select<Object>(is_target_unmodified,
[=] { return AllocateJSCollectionFast(constructor); },
[=] {
return AllocateJSCollectionSlow(context, constructor,
new_target);
});
return Select<JSObject>(
is_target_unmodified,
[=] { return AllocateJSCollectionFast(constructor); },
[=] {
return AllocateJSCollectionSlow(context, constructor, new_target);
});
}
TNode<Object> BaseCollectionsAssembler::AllocateJSCollectionFast(
TNode<HeapObject> constructor) {
TNode<JSObject> BaseCollectionsAssembler::AllocateJSCollectionFast(
TNode<JSFunction> constructor) {
CSA_ASSERT(this, IsConstructorMap(LoadMap(constructor)));
TNode<Object> initial_map =
LoadObjectField(constructor, JSFunction::kPrototypeOrInitialMapOffset);
return CAST(AllocateJSObjectFromMap(initial_map));
TNode<Map> initial_map =
CAST(LoadJSFunctionPrototypeOrInitialMap(constructor));
return AllocateJSObjectFromMap(initial_map);
}
TNode<Object> BaseCollectionsAssembler::AllocateJSCollectionSlow(
TNode<JSObject> BaseCollectionsAssembler::AllocateJSCollectionSlow(
TNode<Context> context, TNode<JSFunction> constructor,
TNode<Object> new_target) {
TNode<JSReceiver> new_target) {
ConstructorBuiltinsAssembler constructor_assembler(this->state());
return CAST(constructor_assembler.EmitFastNewObject(context, constructor,
new_target));
return constructor_assembler.EmitFastNewObject(context, constructor,
new_target);
}
void BaseCollectionsAssembler::GenerateConstructor(
......@@ -408,7 +408,7 @@ void BaseCollectionsAssembler::GenerateConstructor(
TNode<Context> native_context = LoadNativeContext(context);
TNode<Object> collection = AllocateJSCollection(
context, GetConstructor(variant, native_context), new_target);
context, GetConstructor(variant, native_context), CAST(new_target));
AddConstructorEntries(variant, context, native_context, collection, iterable);
Return(collection);
......
......@@ -147,44 +147,40 @@ TF_BUILTIN(FastNewClosure, ConstructorBuiltinsAssembler) {
}
TF_BUILTIN(FastNewObject, ConstructorBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* target = Parameter(Descriptor::kTarget);
Node* new_target = Parameter(Descriptor::kNewTarget);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<JSFunction> target = CAST(Parameter(Descriptor::kTarget));
TNode<JSReceiver> new_target = CAST(Parameter(Descriptor::kNewTarget));
Label call_runtime(this);
Node* result = EmitFastNewObject(context, target, new_target, &call_runtime);
TNode<JSObject> result =
EmitFastNewObject(context, target, new_target, &call_runtime);
Return(result);
BIND(&call_runtime);
TailCallRuntime(Runtime::kNewObject, context, target, new_target);
}
Node* ConstructorBuiltinsAssembler::EmitFastNewObject(Node* context,
Node* target,
Node* new_target) {
VARIABLE(var_obj, MachineRepresentation::kTagged);
compiler::TNode<JSObject> ConstructorBuiltinsAssembler::EmitFastNewObject(
SloppyTNode<Context> context, SloppyTNode<JSFunction> target,
SloppyTNode<JSReceiver> new_target) {
TVARIABLE(JSObject, var_obj);
Label call_runtime(this), end(this);
Node* result = EmitFastNewObject(context, target, new_target, &call_runtime);
var_obj.Bind(result);
var_obj = EmitFastNewObject(context, target, new_target, &call_runtime);
Goto(&end);
BIND(&call_runtime);
var_obj.Bind(CallRuntime(Runtime::kNewObject, context, target, new_target));
var_obj = CAST(CallRuntime(Runtime::kNewObject, context, target, new_target));
Goto(&end);
BIND(&end);
return var_obj.value();
}
Node* ConstructorBuiltinsAssembler::EmitFastNewObject(Node* context,
Node* target,
Node* new_target,
Label* call_runtime) {
CSA_ASSERT(this, HasInstanceType(target, JS_FUNCTION_TYPE));
CSA_ASSERT(this, IsJSReceiver(new_target));
compiler::TNode<JSObject> ConstructorBuiltinsAssembler::EmitFastNewObject(
SloppyTNode<Context> context, SloppyTNode<JSFunction> target,
SloppyTNode<JSReceiver> new_target, Label* call_runtime) {
// Verify that the new target is a JSFunction.
Label fast(this), end(this);
GotoIf(HasInstanceType(new_target, JS_FUNCTION_TYPE), &fast);
......
......@@ -31,10 +31,14 @@ class ConstructorBuiltinsAssembler : public CodeStubAssembler {
Label* call_runtime);
Node* EmitCreateEmptyObjectLiteral(Node* context);
Node* EmitFastNewObject(Node* context, Node* target, Node* new_target);
Node* EmitFastNewObject(Node* context, Node* target, Node* new_target,
Label* call_runtime);
TNode<JSObject> EmitFastNewObject(SloppyTNode<Context> context,
SloppyTNode<JSFunction> target,
SloppyTNode<JSReceiver> new_target);
TNode<JSObject> EmitFastNewObject(SloppyTNode<Context> context,
SloppyTNode<JSFunction> target,
SloppyTNode<JSReceiver> new_target,
Label* call_runtime);
};
} // namespace internal
......
......@@ -17,13 +17,13 @@ class DataViewBuiltinsAssembler : public CodeStubAssembler {
explicit DataViewBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
TNode<Int32T> LoadUint8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) {
return UncheckedCast<Int32T>(
TNode<Uint8T> LoadUint8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) {
return UncheckedCast<Uint8T>(
Load(MachineType::Uint8(), data_pointer, offset));
}
TNode<Int32T> LoadInt8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) {
return UncheckedCast<Int32T>(
TNode<Int8T> LoadInt8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) {
return UncheckedCast<Int8T>(
Load(MachineType::Int8(), data_pointer, offset));
}
......
......@@ -75,7 +75,7 @@ IteratorRecord IteratorBuiltinsAssembler::GetIterator(Node* context,
}
}
TNode<Object> IteratorBuiltinsAssembler::IteratorStep(
TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep(
Node* context, const IteratorRecord& iterator, Label* if_done,
Node* fast_iterator_result_map, Label* if_exception, Variable* exception) {
DCHECK_NOT_NULL(if_done);
......@@ -125,23 +125,21 @@ TNode<Object> IteratorBuiltinsAssembler::IteratorStep(
}
BIND(&return_result);
return UncheckedCast<Object>(result);
return CAST(result);
}
Node* IteratorBuiltinsAssembler::IteratorValue(Node* context, Node* result,
Node* fast_iterator_result_map,
Label* if_exception,
Variable* exception) {
CSA_ASSERT(this, IsJSReceiver(result));
TNode<Object> IteratorBuiltinsAssembler::IteratorValue(
TNode<Context> context, TNode<JSReceiver> result,
base::Optional<TNode<Map>> fast_iterator_result_map, Label* if_exception,
Variable* exception) {
Label exit(this);
VARIABLE(var_value, MachineRepresentation::kTagged);
if (fast_iterator_result_map != nullptr) {
TVARIABLE(Object, var_value);
if (fast_iterator_result_map) {
// Fast iterator result case:
Label if_generic(this);
Node* map = LoadMap(result);
GotoIfNot(WordEqual(map, fast_iterator_result_map), &if_generic);
var_value.Bind(LoadObjectField(result, JSIteratorResult::kValueOffset));
GotoIfNot(WordEqual(map, *fast_iterator_result_map), &if_generic);
var_value = LoadObjectField(result, JSIteratorResult::kValueOffset);
Goto(&exit);
BIND(&if_generic);
......@@ -149,9 +147,10 @@ Node* IteratorBuiltinsAssembler::IteratorValue(Node* context, Node* result,
// Generic iterator result case:
{
Node* value = GetProperty(context, result, factory()->value_string());
TNode<Object> value =
GetProperty(context, result, factory()->value_string());
GotoIfException(value, if_exception, exception);
var_value.Bind(value);
var_value = value;
Goto(&exit);
}
......@@ -217,10 +216,10 @@ TNode<JSArray> IteratorBuiltinsAssembler::IterableToList(
BIND(&loop_start);
{
// a. Set next to ? IteratorStep(iteratorRecord).
TNode<Object> next = IteratorStep(context, iterator_record, &done);
TNode<JSReceiver> next = IteratorStep(context, iterator_record, &done);
// b. If next is not false, then
// i. Let nextValue be ? IteratorValue(next).
TNode<Object> next_value = CAST(IteratorValue(context, next));
TNode<Object> next_value = IteratorValue(context, next);
// ii. Append nextValue to the end of the List values.
values.Push(next_value);
Goto(&loop_start);
......
......@@ -32,18 +32,19 @@ class IteratorBuiltinsAssembler : public CodeStubAssembler {
Variable* exception = nullptr);
// https://tc39.github.io/ecma262/#sec-iteratorstep
// Returns `false` if the iterator is done, otherwise returns an
// iterator result.
// If the iterator is done, goto {if_done}, otherwise returns an iterator
// result.
// `fast_iterator_result_map` refers to the map for the JSIteratorResult
// object, loaded from the native context.
TNode<Object> IteratorStep(Node* context, const IteratorRecord& iterator,
Label* if_done,
Node* fast_iterator_result_map = nullptr,
Label* if_exception = nullptr,
Variable* exception = nullptr);
TNode<Object> IteratorStep(Node* context, const IteratorRecord& iterator,
Node* fast_iterator_result_map, Label* if_done) {
TNode<JSReceiver> IteratorStep(Node* context, const IteratorRecord& iterator,
Label* if_done,
Node* fast_iterator_result_map = nullptr,
Label* if_exception = nullptr,
Variable* exception = nullptr);
TNode<JSReceiver> IteratorStep(Node* context, const IteratorRecord& iterator,
Node* fast_iterator_result_map,
Label* if_done) {
return IteratorStep(context, iterator, if_done, fast_iterator_result_map);
}
......@@ -51,10 +52,10 @@ class IteratorBuiltinsAssembler : public CodeStubAssembler {
// Return the `value` field from an iterator.
// `fast_iterator_result_map` refers to the map for the JSIteratorResult
// object, loaded from the native context.
Node* IteratorValue(Node* context, Node* result,
Node* fast_iterator_result_map = nullptr,
Label* if_exception = nullptr,
Variable* exception = nullptr);
TNode<Object> IteratorValue(
TNode<Context> context, TNode<JSReceiver> result,
base::Optional<TNode<Map>> fast_iterator_result_map = base::nullopt,
Label* if_exception = nullptr, Variable* exception = nullptr);
// https://tc39.github.io/ecma262/#sec-iteratorclose
void IteratorCloseOnException(Node* context, const IteratorRecord& iterator,
......
......@@ -315,8 +315,8 @@ TF_BUILTIN(NumberParseInt, CodeStubAssembler) {
// ES6 #sec-number.prototype.valueof
TF_BUILTIN(NumberPrototypeValueOf, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Node* result = ToThisValue(context, receiver, PrimitiveType::kNumber,
"Number.prototype.valueOf");
......@@ -996,8 +996,8 @@ TF_BUILTIN(Equal, CodeStubAssembler) {
}
TF_BUILTIN(StrictEqual, CodeStubAssembler) {
Node* lhs = Parameter(Descriptor::kLeft);
Node* rhs = Parameter(Descriptor::kRight);
TNode<Object> lhs = CAST(Parameter(Descriptor::kLeft));
TNode<Object> rhs = CAST(Parameter(Descriptor::kRight));
Return(StrictEqual(lhs, rhs));
}
......
......@@ -2077,9 +2077,9 @@ Node* PromiseBuiltinsAssembler::PerformPromiseAll(
// Let next be IteratorStep(iteratorRecord.[[Iterator]]).
// If next is an abrupt completion, set iteratorRecord.[[Done]] to true.
// ReturnIfAbrupt(next).
Node* const fast_iterator_result_map =
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX);
Node* const next = iter_assembler.IteratorStep(
TNode<Map> const fast_iterator_result_map = CAST(
LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX));
TNode<JSReceiver> const next = iter_assembler.IteratorStep(
native_context, iterator, &done_loop, fast_iterator_result_map,
if_exception, var_exception);
......@@ -2087,7 +2087,7 @@ Node* PromiseBuiltinsAssembler::PerformPromiseAll(
// If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to
// true.
// ReturnIfAbrupt(nextValue).
Node* const next_value = iter_assembler.IteratorValue(
TNode<Object> const next_value = iter_assembler.IteratorValue(
native_context, next, fast_iterator_result_map, if_exception,
var_exception);
......@@ -2148,7 +2148,7 @@ Node* PromiseBuiltinsAssembler::PerformPromiseAll(
&if_slow);
GotoIf(IsPromiseSpeciesProtectorCellInvalid(), &if_slow);
GotoIf(TaggedIsSmi(next_value), &if_slow);
Node* const next_value_map = LoadMap(next_value);
Node* const next_value_map = LoadMap(CAST(next_value));
BranchIfPromiseThenLookupChainIntact(native_context, next_value_map,
&if_fast, &if_slow);
......@@ -2526,8 +2526,7 @@ TF_BUILTIN(PromiseAllSettledResolveElementClosure, PromiseBuiltinsAssembler) {
LoadContextElement(native_context, Context::OBJECT_FUNCTION_INDEX));
TNode<Map> object_function_map = Cast(LoadObjectField(
object_function, JSFunction::kPrototypeOrInitialMapOffset));
TNode<JSObject> obj =
Cast(AllocateJSObjectFromMap(object_function_map));
TNode<JSObject> obj = AllocateJSObjectFromMap(object_function_map);
// 10. Perform ! CreateDataProperty(obj, "status", "fulfilled").
CallBuiltin(Builtins::kFastCreateDataProperty, context, obj,
......@@ -2557,8 +2556,7 @@ TF_BUILTIN(PromiseAllSettledRejectElementClosure, PromiseBuiltinsAssembler) {
LoadContextElement(native_context, Context::OBJECT_FUNCTION_INDEX));
TNode<Map> object_function_map = Cast(LoadObjectField(
object_function, JSFunction::kPrototypeOrInitialMapOffset));
TNode<JSObject> obj =
Cast(AllocateJSObjectFromMap(object_function_map));
TNode<JSObject> obj = AllocateJSObjectFromMap(object_function_map);
// 10. Perform ! CreateDataProperty(obj, "status", "rejected").
CallBuiltin(Builtins::kFastCreateDataProperty, context, obj,
......@@ -2579,7 +2577,7 @@ TF_BUILTIN(PromiseRace, PromiseBuiltinsAssembler) {
VARIABLE(var_exception, MachineRepresentation::kTagged, TheHoleConstant());
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const context = Parameter(Descriptor::kContext);
TNode<Context> const context = CAST(Parameter(Descriptor::kContext));
ThrowIfNotJSReceiver(context, receiver, MessageTemplate::kCalledOnNonObject,
"Promise.race");
......@@ -2630,7 +2628,7 @@ TF_BUILTIN(PromiseRace, PromiseBuiltinsAssembler) {
// 4. If IsCallable(_promiseResolve_) is *false*, throw a *TypeError*
// exception.
ThrowIfNotCallable(CAST(context), resolve, "resolve");
ThrowIfNotCallable(context, resolve, "resolve");
var_promise_resolve_function = resolve;
Goto(&loop);
......@@ -2638,13 +2636,13 @@ TF_BUILTIN(PromiseRace, PromiseBuiltinsAssembler) {
BIND(&loop);
{
Node* const fast_iterator_result_map = LoadContextElement(
native_context, Context::ITERATOR_RESULT_MAP_INDEX);
TNode<Map> const fast_iterator_result_map = CAST(LoadContextElement(
native_context, Context::ITERATOR_RESULT_MAP_INDEX));
// Let next be IteratorStep(iteratorRecord.[[Iterator]]).
// If next is an abrupt completion, set iteratorRecord.[[Done]] to true.
// ReturnIfAbrupt(next).
Node* const next = iter_assembler.IteratorStep(
TNode<JSReceiver> const next = iter_assembler.IteratorStep(
context, iterator, &break_loop, fast_iterator_result_map,
&reject_promise, &var_exception);
......@@ -2652,7 +2650,7 @@ TF_BUILTIN(PromiseRace, PromiseBuiltinsAssembler) {
// If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to
// true.
// ReturnIfAbrupt(nextValue).
Node* const next_value =
TNode<Object> const next_value =
iter_assembler.IteratorValue(context, next, fast_iterator_result_map,
&reject_promise, &var_exception);
......
......@@ -13,8 +13,9 @@
namespace v8 {
namespace internal {
Node* ProxiesCodeStubAssembler::AllocateProxy(Node* target, Node* handler,
Node* context) {
compiler::TNode<JSProxy> ProxiesCodeStubAssembler::AllocateProxy(
TNode<Context> context, TNode<JSReceiver> target,
TNode<JSReceiver> handler) {
VARIABLE(map, MachineRepresentation::kTagged);
Label callable_target(this), constructor_target(this), none_target(this),
......@@ -53,7 +54,7 @@ Node* ProxiesCodeStubAssembler::AllocateProxy(Node* target, Node* handler,
StoreObjectFieldNoWriteBarrier(proxy, JSProxy::kTargetOffset, target);
StoreObjectFieldNoWriteBarrier(proxy, JSProxy::kHandlerOffset, handler);
return proxy;
return CAST(proxy);
}
Node* ProxiesCodeStubAssembler::AllocateJSArrayForCodeStubArguments(
......@@ -121,8 +122,9 @@ Node* ProxiesCodeStubAssembler::CreateProxyRevokeFunctionContext(
return context;
}
Node* ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(Node* proxy,
Node* context) {
compiler::TNode<JSFunction>
ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(TNode<Context> context,
TNode<JSProxy> proxy) {
Node* const native_context = LoadNativeContext(context);
Node* const proxy_context =
......@@ -132,8 +134,8 @@ Node* ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(Node* proxy,
Node* const revoke_info =
LoadContextElement(native_context, Context::PROXY_REVOKE_SHARED_FUN);
return AllocateFunctionWithMapAndContext(revoke_map, revoke_info,
proxy_context);
return CAST(AllocateFunctionWithMapAndContext(revoke_map, revoke_info,
proxy_context));
}
TF_BUILTIN(CallProxy, ProxiesCodeStubAssembler) {
......@@ -257,8 +259,9 @@ TF_BUILTIN(ConstructProxy, ProxiesCodeStubAssembler) {
{ ThrowTypeError(context, MessageTemplate::kProxyRevoked, "construct"); }
}
Node* ProxiesCodeStubAssembler::CheckGetSetTrapResult(
Node* context, Node* target, Node* proxy, Node* name, Node* trap_result,
void ProxiesCodeStubAssembler::CheckGetSetTrapResult(
TNode<Context> context, TNode<JSReceiver> target, TNode<JSProxy> proxy,
TNode<Name> name, TNode<Object> trap_result,
JSProxy::AccessKind access_kind) {
// TODO(mslekova): Think of a better name for the trap_result param.
Node* map = LoadMap(target);
......@@ -269,7 +272,7 @@ Node* ProxiesCodeStubAssembler::CheckGetSetTrapResult(
Label if_found_value(this), check_in_runtime(this, Label::kDeferred),
check_passed(this);
GotoIfNot(IsUniqueNameNoIndex(CAST(name)), &check_in_runtime);
GotoIfNot(IsUniqueNameNoIndex(name), &check_in_runtime);
Node* instance_type = LoadInstanceType(target);
TryGetOwnProperty(context, target, target, map, instance_type, name,
&if_found_value, &var_value, &var_details, &var_raw_value,
......@@ -362,12 +365,13 @@ Node* ProxiesCodeStubAssembler::CheckGetSetTrapResult(
}
BIND(&check_passed);
return trap_result;
}
}
Node* ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target,
Node* proxy, Node* name) {
void ProxiesCodeStubAssembler::CheckHasTrapResult(TNode<Context> context,
TNode<JSReceiver> target,
TNode<JSProxy> proxy,
TNode<Name> name) {
Node* target_map = LoadMap(target);
VARIABLE(var_value, MachineRepresentation::kTagged);
VARIABLE(var_details, MachineRepresentation::kWord32);
......@@ -379,7 +383,7 @@ Node* ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target,
check_in_runtime(this, Label::kDeferred);
// 9.a. Let targetDesc be ? target.[[GetOwnProperty]](P).
GotoIfNot(IsUniqueNameNoIndex(CAST(name)), &check_in_runtime);
GotoIfNot(IsUniqueNameNoIndex(name), &check_in_runtime);
Node* instance_type = LoadInstanceType(target);
TryGetOwnProperty(context, target, target, target_map, instance_type, name,
&if_found_value, &var_value, &var_details, &var_raw_value,
......@@ -415,7 +419,6 @@ Node* ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target,
}
BIND(&check_passed);
return FalseConstant();
}
} // namespace internal
......
......@@ -17,15 +17,18 @@ class ProxiesCodeStubAssembler : public CodeStubAssembler {
explicit ProxiesCodeStubAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
Node* AllocateProxy(Node* target, Node* handler, Node* context);
Node* AllocateProxyRevokeFunction(Node* proxy, Node* context);
Node* CheckGetSetTrapResult(Node* context, Node* target, Node* proxy,
Node* name, Node* trap_result,
JSProxy::AccessKind access_kind);
Node* CheckHasTrapResult(Node* context, Node* target, Node* proxy,
Node* name);
TNode<JSProxy> AllocateProxy(TNode<Context> context, TNode<JSReceiver> target,
TNode<JSReceiver> handler);
TNode<JSFunction> AllocateProxyRevokeFunction(TNode<Context> context,
TNode<JSProxy> proxy);
void CheckGetSetTrapResult(TNode<Context> context, TNode<JSReceiver> target,
TNode<JSProxy> proxy, TNode<Name> name,
TNode<Object> trap_result,
JSProxy::AccessKind access_kind);
void CheckHasTrapResult(TNode<Context> context, TNode<JSReceiver> target,
TNode<JSProxy> proxy, TNode<Name> name);
protected:
enum ProxyRevokeFunctionContextSlot {
......
This diff is collapsed.
......@@ -42,15 +42,20 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
TNode<Context> context, TNode<Smi> length, TNode<Smi> index,
TNode<String> input, TNode<FixedArray>* elements_out = nullptr);
TNode<Object> FastLoadLastIndex(TNode<JSRegExp> regexp);
TNode<Object> FastLoadLastIndexBeforeSmiCheck(TNode<JSRegExp> regexp);
TNode<Smi> FastLoadLastIndex(TNode<JSRegExp> regexp) {
return CAST(FastLoadLastIndexBeforeSmiCheck(regexp));
}
TNode<Object> SlowLoadLastIndex(TNode<Context> context, TNode<Object> regexp);
TNode<Object> LoadLastIndex(TNode<Context> context, TNode<Object> regexp,
bool is_fastpath);
void FastStoreLastIndex(Node* regexp, Node* value);
void SlowStoreLastIndex(Node* context, Node* regexp, Node* value);
void StoreLastIndex(Node* context, Node* regexp, Node* value,
bool is_fastpath);
void FastStoreLastIndex(TNode<JSRegExp> regexp, TNode<Smi> value);
void SlowStoreLastIndex(SloppyTNode<Context> context,
SloppyTNode<Object> regexp,
SloppyTNode<Number> value);
void StoreLastIndex(TNode<Context> context, TNode<Object> regexp,
TNode<Number> value, bool is_fastpath);
// Loads {var_string_start} and {var_string_end} with the corresponding
// offsets into the given {string_data}.
......@@ -127,20 +132,23 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
Node* RegExpExec(Node* context, Node* regexp, Node* string);
Node* AdvanceStringIndex(Node* const string, Node* const index,
Node* const is_unicode, bool is_fastpath);
TNode<Number> AdvanceStringIndex(SloppyTNode<String> string,
SloppyTNode<Number> index,
SloppyTNode<BoolT> is_unicode,
bool is_fastpath);
Node* AdvanceStringIndexFast(Node* const string, Node* const index,
Node* const is_unicode) {
return AdvanceStringIndex(string, index, is_unicode, true);
TNode<Smi> AdvanceStringIndexFast(TNode<String> string, TNode<Smi> index,
TNode<BoolT> is_unicode) {
return CAST(AdvanceStringIndex(string, index, is_unicode, true));
}
void RegExpPrototypeMatchBody(Node* const context, Node* const regexp,
void RegExpPrototypeMatchBody(TNode<Context> context, TNode<Object> regexp,
TNode<String> const string,
const bool is_fastpath);
void RegExpPrototypeSearchBodyFast(Node* const context, Node* const regexp,
Node* const string);
void RegExpPrototypeSearchBodyFast(TNode<Context> context,
TNode<JSRegExp> regexp,
TNode<String> string);
void RegExpPrototypeSearchBodySlow(Node* const context, Node* const regexp,
Node* const string);
......
......@@ -1986,12 +1986,12 @@ TNode<Int32T> StringBuiltinsAssembler::LoadSurrogatePairAt(
switch (encoding) {
case UnicodeEncoding::UTF16:
var_result = Signed(Word32Or(
var_result = Word32Or(
// Need to swap the order for big-endian platforms
#if V8_TARGET_BIG_ENDIAN
Word32Shl(lead, Int32Constant(16)), trail));
Word32Shl(lead, Int32Constant(16)), trail);
#else
Word32Shl(trail, Int32Constant(16)), lead));
Word32Shl(trail, Int32Constant(16)), lead);
#endif
break;
......@@ -2002,8 +2002,8 @@ TNode<Int32T> StringBuiltinsAssembler::LoadSurrogatePairAt(
Int32Constant(0x10000 - (0xD800 << 10) - 0xDC00);
// (lead << 10) + trail + SURROGATE_OFFSET
var_result = Signed(Int32Add(Word32Shl(lead, Int32Constant(10)),
Int32Add(trail, surrogate_offset)));
var_result = Int32Add(Word32Shl(lead, Int32Constant(10)),
Int32Add(trail, surrogate_offset));
break;
}
}
......
......@@ -13,8 +13,8 @@ namespace internal {
// ES #sec-symbol-objects
// ES #sec-symbol.prototype.description
TF_BUILTIN(SymbolPrototypeDescriptionGetter, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Node* value = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.description");
......@@ -24,8 +24,8 @@ TF_BUILTIN(SymbolPrototypeDescriptionGetter, CodeStubAssembler) {
// ES6 #sec-symbol.prototype-@@toprimitive
TF_BUILTIN(SymbolPrototypeToPrimitive, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype [ @@toPrimitive ]");
......@@ -34,8 +34,8 @@ TF_BUILTIN(SymbolPrototypeToPrimitive, CodeStubAssembler) {
// ES6 #sec-symbol.prototype.tostring
TF_BUILTIN(SymbolPrototypeToString, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Node* value = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.toString");
......@@ -45,8 +45,8 @@ TF_BUILTIN(SymbolPrototypeToString, CodeStubAssembler) {
// ES6 #sec-symbol.prototype.valueof
TF_BUILTIN(SymbolPrototypeValueOf, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* receiver = Parameter(Descriptor::kReceiver);
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.valueOf");
......
......@@ -169,13 +169,13 @@ TF_BUILTIN(TypedArrayPrototypeLength, TypedArrayBuiltinsAssembler) {
Return(ChangeUintPtrToTagged(length));
}
TNode<Word32T> TypedArrayBuiltinsAssembler::IsUint8ElementsKind(
TNode<BoolT> TypedArrayBuiltinsAssembler::IsUint8ElementsKind(
TNode<Word32T> kind) {
return Word32Or(Word32Equal(kind, Int32Constant(UINT8_ELEMENTS)),
Word32Equal(kind, Int32Constant(UINT8_CLAMPED_ELEMENTS)));
}
TNode<Word32T> TypedArrayBuiltinsAssembler::IsBigInt64ElementsKind(
TNode<BoolT> TypedArrayBuiltinsAssembler::IsBigInt64ElementsKind(
TNode<Word32T> kind) {
return Word32Or(Word32Equal(kind, Int32Constant(BIGINT64_ELEMENTS)),
Word32Equal(kind, Int32Constant(BIGUINT64_ELEMENTS)));
......@@ -268,10 +268,9 @@ TNode<JSArrayBuffer> TypedArrayBuiltinsAssembler::GetBuffer(
Label call_runtime(this), done(this);
TVARIABLE(Object, var_result);
TNode<Object> buffer = LoadObjectField(array, JSTypedArray::kBufferOffset);
TNode<JSArrayBuffer> buffer = LoadJSArrayBufferViewBuffer(array);
GotoIf(IsDetachedBuffer(buffer), &call_runtime);
TNode<UintPtrT> backing_store = LoadObjectField<UintPtrT>(
CAST(buffer), JSArrayBuffer::kBackingStoreOffset);
TNode<RawPtrT> backing_store = LoadJSArrayBufferBackingStore(buffer);
GotoIf(WordEqual(backing_store, IntPtrConstant(0)), &call_runtime);
var_result = buffer;
Goto(&done);
......@@ -301,10 +300,10 @@ void TypedArrayBuiltinsAssembler::SetTypedArraySource(
TNode<Context> context, TNode<JSTypedArray> source,
TNode<JSTypedArray> target, TNode<IntPtrT> offset, Label* call_runtime,
Label* if_source_too_large) {
CSA_ASSERT(this, Word32BinaryNot(IsDetachedBuffer(
LoadObjectField(source, JSTypedArray::kBufferOffset))));
CSA_ASSERT(this, Word32BinaryNot(IsDetachedBuffer(
LoadObjectField(target, JSTypedArray::kBufferOffset))));
CSA_ASSERT(this, Word32BinaryNot(
IsDetachedBuffer(LoadJSArrayBufferViewBuffer(source))));
CSA_ASSERT(this, Word32BinaryNot(
IsDetachedBuffer(LoadJSArrayBufferViewBuffer(target))));
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(offset, IntPtrConstant(0)));
CSA_ASSERT(this,
IntPtrLessThanOrEqual(offset, IntPtrConstant(Smi::kMaxValue)));
......@@ -748,8 +747,8 @@ TF_BUILTIN(TypedArrayOf, TypedArrayBuiltinsAssembler) {
// ToNumber/ToBigInt may execute JavaScript code, which could
// detach the array's buffer.
Node* buffer =
LoadObjectField(new_typed_array, JSTypedArray::kBufferOffset);
TNode<JSArrayBuffer> buffer =
LoadJSArrayBufferViewBuffer(new_typed_array);
GotoIf(IsDetachedBuffer(buffer), &if_detached);
// GC may move backing store in ToNumber, thus load backing
......@@ -971,8 +970,8 @@ TF_BUILTIN(TypedArrayFrom, TypedArrayBuiltinsAssembler) {
// ToNumber/ToBigInt may execute JavaScript code, which could
// detach the array's buffer.
Node* buffer = LoadObjectField(target_obj.value(),
JSTypedArray::kBufferOffset);
TNode<JSArrayBuffer> buffer =
LoadJSArrayBufferViewBuffer(target_obj.value());
GotoIf(IsDetachedBuffer(buffer), &if_detached);
// GC may move backing store in map_fn, thus load backing
......
......@@ -41,10 +41,10 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler {
TNode<UintPtrT> byte_offset);
// Returns true if kind is either UINT8_ELEMENTS or UINT8_CLAMPED_ELEMENTS.
TNode<Word32T> IsUint8ElementsKind(TNode<Word32T> kind);
TNode<BoolT> IsUint8ElementsKind(TNode<Word32T> kind);
// Returns true if kind is either BIGINT64_ELEMENTS or BIGUINT64_ELEMENTS.
TNode<Word32T> IsBigInt64ElementsKind(TNode<Word32T> kind);
TNode<BoolT> IsBigInt64ElementsKind(TNode<Word32T> kind);
// Returns the byte size of an element for a TypedArray elements kind.
TNode<IntPtrT> GetTypedArrayElementSize(TNode<Word32T> elements_kind);
......
......@@ -20,16 +20,16 @@ namespace iterator {
implicit context: Context)(Object): IteratorRecord;
extern macro IteratorBuiltinsAssembler::IteratorStep(
implicit context: Context)(IteratorRecord): Object
implicit context: Context)(IteratorRecord): JSReceiver
labels Done;
extern macro IteratorBuiltinsAssembler::IteratorStep(
implicit context: Context)(IteratorRecord, Map): Object
implicit context: Context)(IteratorRecord, Map): JSReceiver
labels Done;
extern macro IteratorBuiltinsAssembler::IteratorValue(
implicit context: Context)(Object): Object;
implicit context: Context)(JSReceiver): Object;
extern macro IteratorBuiltinsAssembler::IteratorValue(
implicit context: Context)(Object, Map): Object;
implicit context: Context)(JSReceiver, Map): Object;
extern macro IteratorBuiltinsAssembler::IteratorCloseOnException(
implicit context: Context)(IteratorRecord, Object): never;
......
......@@ -47,7 +47,8 @@ namespace object {
try {
assert(!IsNullOrUndefined(i.object));
while (true) {
const step: Object = iterator::IteratorStep(i, fastIteratorResultMap)
const step: JSReceiver =
iterator::IteratorStep(i, fastIteratorResultMap)
otherwise return result;
const iteratorValue: Object =
iterator::IteratorValue(step, fastIteratorResultMap);
......
......@@ -22,30 +22,32 @@ namespace proxy {
assert(!IsPrivateSymbol(name));
// 2. Let handler be O.[[ProxyHandler]].
const handler: Object = proxy.handler;
// 3. If handler is null, throw a TypeError exception.
if (handler == Null) {
ThrowTypeError(kProxyRevoked, 'get');
}
// 4. Assert: Type(handler) is Object.
const handlerJSReceiver = UnsafeCast<JSReceiver>(handler);
let handler: JSReceiver;
typeswitch (proxy.handler) {
case (Null): {
ThrowTypeError(kProxyRevoked, 'get');
}
case (h: JSReceiver): {
handler = h;
}
}
// 5. Let target be O.[[ProxyTarget]].
const target = proxy.target;
const target = Cast<JSReceiver>(proxy.target) otherwise unreachable;
// 6. Let trap be ? GetMethod(handler, "get").
// 7. If trap is undefined, then (see 7.a below).
// 7.a. Return ? target.[[Get]](P, Receiver).
// TODO(mslekova): Introduce GetPropertyWithReceiver stub
const trap: Callable = GetMethod(handlerJSReceiver, 'get')
const trap: Callable = GetMethod(handler, 'get')
otherwise return GetPropertyWithReceiver(
target, name, receiverValue, onNonExistent);
// 8. Let trapResult be ? Call(trap, handler, « target, P, Receiver »).
const trapResult =
Call(context, trap, handlerJSReceiver, target, name, receiverValue);
Call(context, trap, handler, target, name, receiverValue);
// 9. Let targetDesc be ? target.[[GetOwnProperty]](P).
// 10. If targetDesc is not undefined and targetDesc.[[Configurable]] is
......@@ -58,6 +60,7 @@ namespace proxy {
// is undefined, then
// i. If trapResult is not undefined, throw a TypeError exception.
// 11. Return trapResult.
return CheckGetSetTrapResult(target, proxy, name, trapResult, kProxyGet);
CheckGetSetTrapResult(target, proxy, name, trapResult, kProxyGet);
return trapResult;
}
}
......@@ -26,7 +26,7 @@ namespace proxy {
Cast<JSReceiver>(proxy.handler) otherwise ThrowProxyHandlerRevoked;
// 5. Let target be O.[[ProxyTarget]].
const target = proxy.target;
const target = Cast<JSReceiver>(proxy.target) otherwise unreachable;
// 6. Let trap be ? GetMethod(handler, "has").
// 7. If trap is undefined, then (see 7.a below).
......@@ -42,7 +42,8 @@ namespace proxy {
if (BranchIfToBooleanIsTrue(trapResult)) {
return True;
}
return CheckHasTrapResult(target, proxy, name);
CheckHasTrapResult(target, proxy, name);
return False;
}
label TrapUndefined(target: Object) {
// 7.a. Return ? target.[[HasProperty]](P).
......
......@@ -7,11 +7,7 @@
namespace proxy {
extern macro ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(
Object, Object): JSFunction;
macro AllocateProxyRevokeFunction(implicit context: Context)(proxy: JSProxy):
JSFunction {
return AllocateProxyRevokeFunction(proxy, context);
}
implicit context: Context)(JSProxy): JSFunction;
// Proxy.revocable(target, handler)
// https://tc39.github.io/ecma262/#sec-proxy.revocable
......
......@@ -40,7 +40,7 @@ namespace proxy {
Cast<JSReceiver>(handler) otherwise ThrowProxyHandlerRevoked;
// 5. Let target be O.[[ProxyTarget]].
const target = proxy.target;
const target = UnsafeCast<JSReceiver>(proxy.target);
// 6. Let trap be ? GetMethod(handler, "set").
// 7. If trap is undefined, then (see 7.a below).
......@@ -64,7 +64,8 @@ namespace proxy {
const trapResult = Call(
context, trap, handlerJSReceiver, target, name, value, receiverValue);
if (BranchIfToBooleanIsTrue(trapResult)) {
return CheckGetSetTrapResult(target, proxy, name, value, kProxySet);
CheckGetSetTrapResult(target, proxy, name, value, kProxySet);
return value;
}
ThrowTypeErrorIfStrict(
SmiConstant(kProxyTrapReturnedFalsishFor), 'set', name);
......
......@@ -7,11 +7,7 @@
namespace proxy {
extern macro ProxiesCodeStubAssembler::AllocateProxy(
JSReceiver, JSReceiver, Context): JSProxy;
macro AllocateProxy(implicit context: Context)(
target: JSReceiver, handler: JSReceiver): JSProxy {
return AllocateProxy(target, handler, context);
}
implicit context: Context)(JSReceiver, JSReceiver): JSProxy;
macro IsRevokedProxy(implicit context: Context)(o: JSReceiver): bool {
const proxy: JSProxy = Cast<JSProxy>(o) otherwise return false;
......@@ -21,10 +17,10 @@ namespace proxy {
extern transitioning macro ProxiesCodeStubAssembler::CheckGetSetTrapResult(
implicit context:
Context)(Object, JSProxy, Name, Object, constexpr int31): Object;
Context)(JSReceiver, JSProxy, Name, Object, constexpr int31);
extern transitioning macro ProxiesCodeStubAssembler::CheckHasTrapResult(
implicit context: Context)(Object, JSProxy, Name): Object;
implicit context: Context)(JSReceiver, JSProxy, Name);
const kProxyNonObject: constexpr MessageTemplate
generates 'MessageTemplate::kProxyNonObject';
......
......@@ -22,7 +22,7 @@ namespace regexp_replace {
String, JSRegExp, Callable): String;
extern macro
RegExpBuiltinsAssembler::AdvanceStringIndexFast(String, Number, bool): Smi;
RegExpBuiltinsAssembler::AdvanceStringIndexFast(String, Smi, bool): Smi;
extern macro
RegExpBuiltinsAssembler::RegExpPrototypeExecBodyWithoutResultFast(
implicit context: Context)(JSReceiver, String):
......
......@@ -70,10 +70,9 @@ namespace typed_array {
extern macro TypedArrayBuiltinsAssembler::IsBigInt64ElementsKind(
ElementsKind): bool;
extern macro LoadFixedTypedArrayElementAsTagged(
RawPtr, Smi, constexpr ElementsKind, constexpr ParameterMode): Object;
RawPtr, Smi, constexpr ElementsKind): Numeric;
extern macro StoreJSTypedArrayElementFromTagged(
Context, JSTypedArray, Smi, Object, constexpr ElementsKind,
constexpr ParameterMode);
Context, JSTypedArray, Smi, Object, constexpr ElementsKind);
type LoadFn = builtin(Context, JSTypedArray, Smi) => Object;
type StoreFn = builtin(Context, JSTypedArray, Smi, Object) => Object;
......@@ -193,15 +192,14 @@ namespace typed_array {
builtin LoadFixedElement<T: type>(
_context: Context, array: JSTypedArray, index: Smi): Object {
return LoadFixedTypedArrayElementAsTagged(
array.data_ptr, index, KindForArrayType<T>(), SMI_PARAMETERS);
array.data_ptr, index, KindForArrayType<T>());
}
builtin StoreFixedElement<T: type>(
context: Context, typedArray: JSTypedArray, index: Smi,
value: Object): Object {
StoreJSTypedArrayElementFromTagged(
context, typedArray, index, value, KindForArrayType<T>(),
SMI_PARAMETERS);
context, typedArray, index, value, KindForArrayType<T>());
return Undefined;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -441,16 +441,16 @@ void CodeAssembler::Bind(Label* label, AssemblerDebugInfo debug_info) {
}
#endif // DEBUG
Node* CodeAssembler::LoadFramePointer() {
return raw_assembler()->LoadFramePointer();
TNode<RawPtrT> CodeAssembler::LoadFramePointer() {
return UncheckedCast<RawPtrT>(raw_assembler()->LoadFramePointer());
}
Node* CodeAssembler::LoadParentFramePointer() {
return raw_assembler()->LoadParentFramePointer();
TNode<RawPtrT> CodeAssembler::LoadParentFramePointer() {
return UncheckedCast<RawPtrT>(raw_assembler()->LoadParentFramePointer());
}
Node* CodeAssembler::LoadStackPointer() {
return raw_assembler()->LoadStackPointer();
TNode<RawPtrT> CodeAssembler::LoadStackPointer() {
return UncheckedCast<RawPtrT>(raw_assembler()->LoadStackPointer());
}
TNode<Object> CodeAssembler::TaggedPoisonOnSpeculation(
......
......@@ -107,13 +107,13 @@ struct Uint32T : Word32T {
struct Int16T : Int32T {
static constexpr MachineType kMachineType = MachineType::Int16();
};
struct Uint16T : Uint32T {
struct Uint16T : Uint32T, Int32T {
static constexpr MachineType kMachineType = MachineType::Uint16();
};
struct Int8T : Int16T {
static constexpr MachineType kMachineType = MachineType::Int8();
};
struct Uint8T : Uint16T {
struct Uint8T : Uint16T, Int16T {
static constexpr MachineType kMachineType = MachineType::Uint8();
};
......@@ -419,6 +419,10 @@ struct types_have_common_values {
static const bool value = is_subtype<T, U>::value || is_subtype<U, T>::value;
};
template <class U>
struct types_have_common_values<BoolT, U> {
static const bool value = types_have_common_values<Word32T, U>::value;
};
template <class U>
struct types_have_common_values<Uint32T, U> {
static const bool value = types_have_common_values<Word32T, U>::value;
};
......@@ -617,15 +621,15 @@ TNode<Float64T> Float64Add(TNode<Float64T> a, TNode<Float64T> b);
V(Float64Sqrt, Float64T, Float64T) \
V(Float64Tan, Float64T, Float64T) \
V(Float64Tanh, Float64T, Float64T) \
V(Float64ExtractLowWord32, Word32T, Float64T) \
V(Float64ExtractHighWord32, Word32T, Float64T) \
V(Float64ExtractLowWord32, Uint32T, Float64T) \
V(Float64ExtractHighWord32, Uint32T, Float64T) \
V(BitcastTaggedToWord, IntPtrT, Object) \
V(BitcastTaggedSignedToWord, IntPtrT, Smi) \
V(BitcastMaybeObjectToWord, IntPtrT, MaybeObject) \
V(BitcastWordToTagged, Object, WordT) \
V(BitcastWordToTaggedSigned, Smi, WordT) \
V(TruncateFloat64ToFloat32, Float32T, Float64T) \
V(TruncateFloat64ToWord32, Word32T, Float64T) \
V(TruncateFloat64ToWord32, Uint32T, Float64T) \
V(TruncateInt64ToInt32, Int32T, Int64T) \
V(ChangeFloat32ToFloat64, Float64T, Float32T) \
V(ChangeFloat64ToUint32, Uint32T, Float64T) \
......@@ -635,7 +639,7 @@ TNode<Float64T> Float64Add(TNode<Float64T> a, TNode<Float64T> b);
V(ChangeUint32ToFloat64, Float64T, Word32T) \
V(ChangeUint32ToUint64, Uint64T, Word32T) \
V(BitcastInt32ToFloat32, Float32T, Word32T) \
V(BitcastFloat32ToInt32, Word32T, Float32T) \
V(BitcastFloat32ToInt32, Uint32T, Float32T) \
V(RoundFloat64ToInt32, Int32T, Float64T) \
V(RoundInt32ToFloat32, Int32T, Float32T) \
V(Float64SilenceNaN, Float64T, Float64T) \
......@@ -948,11 +952,11 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Label** case_labels, size_t case_count);
// Access to the frame pointer
Node* LoadFramePointer();
Node* LoadParentFramePointer();
TNode<RawPtrT> LoadFramePointer();
TNode<RawPtrT> LoadParentFramePointer();
// Access to the stack pointer
Node* LoadStackPointer();
TNode<RawPtrT> LoadStackPointer();
// Poison |value| on speculative paths.
TNode<Object> TaggedPoisonOnSpeculation(SloppyTNode<Object> value);
......@@ -1057,20 +1061,60 @@ class V8_EXPORT_PRIVATE CodeAssembler {
CODE_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_ASSEMBLER_BINARY_OP)
#undef DECLARE_CODE_ASSEMBLER_BINARY_OP
TNode<IntPtrT> WordShr(TNode<IntPtrT> left, TNode<IntegralT> right) {
return UncheckedCast<IntPtrT>(
TNode<UintPtrT> WordShr(TNode<UintPtrT> left, TNode<IntegralT> right) {
return Unsigned(
WordShr(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<IntPtrT> WordSar(TNode<IntPtrT> left, TNode<IntegralT> right) {
return UncheckedCast<IntPtrT>(
WordSar(static_cast<Node*>(left), static_cast<Node*>(right)));
return Signed(WordSar(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<IntPtrT> WordShl(TNode<IntPtrT> left, TNode<IntegralT> right) {
return Signed(WordShl(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<UintPtrT> WordShl(TNode<UintPtrT> left, TNode<IntegralT> right) {
return Unsigned(
WordShl(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Int32T> Word32Shl(TNode<Int32T> left, TNode<Int32T> right) {
return Signed(
Word32Shl(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Uint32T> Word32Shl(TNode<Uint32T> left, TNode<Uint32T> right) {
return Unsigned(
Word32Shl(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Uint32T> Word32Shr(TNode<Uint32T> left, TNode<Uint32T> right) {
return Unsigned(
Word32Shr(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<IntPtrT> WordAnd(TNode<IntPtrT> left, TNode<IntPtrT> right) {
return UncheckedCast<IntPtrT>(
return Signed(WordAnd(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<UintPtrT> WordAnd(TNode<UintPtrT> left, TNode<UintPtrT> right) {
return Unsigned(
WordAnd(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Int32T> Word32And(TNode<Int32T> left, TNode<Int32T> right) {
return Signed(
Word32And(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Uint32T> Word32And(TNode<Uint32T> left, TNode<Uint32T> right) {
return Unsigned(
Word32And(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Int32T> Word32Or(TNode<Int32T> left, TNode<Int32T> right) {
return Signed(
Word32Or(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Uint32T> Word32Or(TNode<Uint32T> left, TNode<Uint32T> right) {
return Unsigned(
Word32Or(static_cast<Node*>(left), static_cast<Node*>(right)));
}
template <class Left, class Right,
class = typename std::enable_if<
std::is_base_of<Object, Left>::value &&
......@@ -1116,6 +1160,15 @@ class V8_EXPORT_PRIVATE CodeAssembler {
TNode<BoolT> Word64NotEqual(SloppyTNode<Word64T> left,
SloppyTNode<Word64T> right);
TNode<BoolT> Word32Or(TNode<BoolT> left, TNode<BoolT> right) {
return UncheckedCast<BoolT>(
Word32Or(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<BoolT> Word32And(TNode<BoolT> left, TNode<BoolT> right) {
return UncheckedCast<BoolT>(
Word32And(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Int32T> Int32Add(TNode<Int32T> left, TNode<Int32T> right) {
return Signed(
Int32Add(static_cast<Node*>(left), static_cast<Node*>(right)));
......@@ -1126,6 +1179,16 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Int32Add(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Int32T> Int32Sub(TNode<Int32T> left, TNode<Int32T> right) {
return Signed(
Int32Sub(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<Int32T> Int32Mul(TNode<Int32T> left, TNode<Int32T> right) {
return Signed(
Int32Mul(static_cast<Node*>(left), static_cast<Node*>(right)));
}
TNode<WordT> IntPtrAdd(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
TNode<IntPtrT> IntPtrDiv(TNode<IntPtrT> left, TNode<IntPtrT> right);
TNode<WordT> IntPtrSub(SloppyTNode<WordT> left, SloppyTNode<WordT> right);
......
......@@ -1964,7 +1964,7 @@ void AccessorAssembler::EmitElementLoad(
{
Comment("typed elements");
// Check if buffer has been detached.
Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset);
TNode<JSArrayBuffer> buffer = LoadJSArrayBufferViewBuffer(CAST(object));
GotoIf(IsDetachedBuffer(buffer), miss);
// Bounds check.
......@@ -1973,7 +1973,8 @@ void AccessorAssembler::EmitElementLoad(
if (access_mode == LoadAccessMode::kHas) {
exit_point->Return(TrueConstant());
} else {
Node* backing_store = LoadJSTypedArrayBackingStore(CAST(object));
TNode<RawPtrT> backing_store =
LoadJSTypedArrayBackingStore(CAST(object));
Label uint8_elements(this), int8_elements(this), uint16_elements(this),
int16_elements(this), uint32_elements(this), int32_elements(this),
......@@ -3640,7 +3641,7 @@ void AccessorAssembler::GenerateCloneObjectIC_Slow() {
LoadObjectField(object_fn, JSFunction::kPrototypeOrInitialMapOffset));
CSA_ASSERT(this, IsMap(initial_map));
TNode<JSObject> result = CAST(AllocateJSObjectFromMap(initial_map));
TNode<JSObject> result = AllocateJSObjectFromMap(initial_map);
{
Label did_set_proto_if_needed(this);
......@@ -3708,8 +3709,8 @@ void AccessorAssembler::GenerateCloneObjectIC() {
// Handlers for the CloneObjectIC stub are weak references to the Map of
// a result object.
TNode<Map> result_map = CAST(var_handler.value());
TVARIABLE(Object, var_properties, EmptyFixedArrayConstant());
TVARIABLE(FixedArrayBase, var_elements, EmptyFixedArrayConstant());
TVARIABLE(HeapObject, var_properties, EmptyFixedArrayConstant());
TVARIABLE(FixedArray, var_elements, EmptyFixedArrayConstant());
Label allocate_object(this);
GotoIf(IsNullOrUndefined(source), &allocate_object);
......
......@@ -185,7 +185,7 @@ void KeyedStoreGenericAssembler::BranchIfPrototypesHaveNonFastElements(
TNode<Int32T> instance_type = LoadMapInstanceType(prototype_map);
GotoIf(IsCustomElementsReceiverInstanceType(instance_type),
non_fast_elements);
Node* elements_kind = LoadMapElementsKind(prototype_map);
TNode<Int32T> elements_kind = LoadMapElementsKind(prototype_map);
GotoIf(IsFastElementsKind(elements_kind), &loop_body);
GotoIf(Word32Equal(elements_kind, Int32Constant(NO_ELEMENTS)), &loop_body);
Goto(non_fast_elements);
......@@ -500,7 +500,7 @@ void KeyedStoreGenericAssembler::EmitGenericElementStore(
if_grow(this), if_nonfast(this), if_typed_array(this),
if_dictionary(this);
Node* elements = LoadElements(receiver);
Node* elements_kind = LoadMapElementsKind(receiver_map);
TNode<Int32T> elements_kind = LoadMapElementsKind(receiver_map);
Branch(IsFastElementsKind(elements_kind), &if_fast, &if_nonfast);
BIND(&if_fast);
......
......@@ -1265,7 +1265,7 @@ void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) {
// Make sure we include the current bytecode in the budget calculation.
TNode<Int32T> budget_after_bytecode =
Signed(Int32Sub(old_budget, Int32Constant(CurrentBytecodeSize())));
Int32Sub(old_budget, Int32Constant(CurrentBytecodeSize()));
Label done(this);
TVARIABLE(Int32T, new_budget);
......
......@@ -314,8 +314,7 @@ void CSAGenerator::EmitInstruction(const CallCsaMacroInstruction& instruction,
out_ << ") = ";
} else {
if (results.size() == 1) {
out_ << results[0] << " = ca_.UncheckedCast<"
<< return_type->GetGeneratedTNodeTypeName() << ">(";
out_ << results[0] << " = ";
} else {
DCHECK_EQ(0, results.size());
}
......@@ -330,7 +329,6 @@ void CSAGenerator::EmitInstruction(const CallCsaMacroInstruction& instruction,
if (needs_flattening) {
out_ << ").Flatten();\n";
} else {
if (results.size() == 1) out_ << ")";
out_ << ");\n";
}
PostCallableExceptionPreparation(catch_name, return_type,
......
......@@ -744,16 +744,16 @@ namespace test {
// IteratorBuiltinsAssembler match the signatures provided in
// iterator.tq.
@export
macro TestIterator(implicit context: Context)(o: Object, map: Map) {
macro TestIterator(implicit context: Context)(o: JSReceiver, map: Map) {
try {
const t1: Object = iterator::GetIteratorMethod(o);
const t2: iterator::IteratorRecord = iterator::GetIterator(o);
const _t3: Object = iterator::IteratorStep(t2) otherwise Fail;
const t4: Object = iterator::IteratorStep(t2, map) otherwise Fail;
const _t4: Object = iterator::IteratorStep(t2, map) otherwise Fail;
const t5: Object = iterator::IteratorValue(t4);
const _t6: Object = iterator::IteratorValue(t4, map);
const t5: Object = iterator::IteratorValue(o);
const _t6: Object = iterator::IteratorValue(o, map);
const _t7: JSArray = iterator::IterableToList(t1, t1);
......
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