Commit e620ba13 authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[torque] Address remaining usages of @noVerifier in base.tq

For every @noVerifier in base.tq, this change either removes it or
ensures that it has some annotation explaining why it can't be removed.
The @noVerifier usages that can't be removed fall into the following
categories:
1. Classes that don't have their own instance types and therefore have
   no meaningful way to do an Is...() check
2. Fields that might not exist
3. Fields that are waiting for MaybeObject support in Torque

Bug: v8:9311
Change-Id: Id452d4151ec07347ae96a9b5f3b26e2ac8065d31
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1659134Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#62263}
parent d8164d59
...@@ -37,7 +37,7 @@ namespace array_join { ...@@ -37,7 +37,7 @@ namespace array_join {
const array: JSArray = UnsafeCast<JSArray>(receiver); const array: JSArray = UnsafeCast<JSArray>(receiver);
const fixedArray: FixedArray = UnsafeCast<FixedArray>(array.elements); const fixedArray: FixedArray = UnsafeCast<FixedArray>(array.elements);
const element: Object = fixedArray.objects[UnsafeCast<Smi>(k)]; const element: Object = fixedArray.objects[UnsafeCast<Smi>(k)];
return element == Hole ? kEmptyString : element; return element == TheHole ? kEmptyString : element;
} }
LoadJoinElement<array::FastDoubleElements>( LoadJoinElement<array::FastDoubleElements>(
...@@ -448,7 +448,7 @@ namespace array_join { ...@@ -448,7 +448,7 @@ namespace array_join {
const previouslyVisited: Object = stack.objects[i]; const previouslyVisited: Object = stack.objects[i];
// Add `receiver` to the first open slot // Add `receiver` to the first open slot
if (previouslyVisited == Hole) { if (previouslyVisited == TheHole) {
stack.objects[i] = receiver; stack.objects[i] = receiver;
return True; return True;
} }
...@@ -473,7 +473,7 @@ namespace array_join { ...@@ -473,7 +473,7 @@ namespace array_join {
try { try {
const stack: FixedArray = LoadJoinStack() const stack: FixedArray = LoadJoinStack()
otherwise IfUninitialized; otherwise IfUninitialized;
if (stack.objects[0] == Hole) { if (stack.objects[0] == TheHole) {
stack.objects[0] = receiver; stack.objects[0] = receiver;
} else if (JoinStackPush(stack, receiver) == False) } else if (JoinStackPush(stack, receiver) == False)
deferred { deferred {
...@@ -504,7 +504,7 @@ namespace array_join { ...@@ -504,7 +504,7 @@ namespace array_join {
SetJoinStack(newStack); SetJoinStack(newStack);
} }
else { else {
stack.objects[i] = Hole; stack.objects[i] = TheHole;
} }
return Undefined; return Undefined;
} }
...@@ -521,7 +521,7 @@ namespace array_join { ...@@ -521,7 +521,7 @@ namespace array_join {
// Builtin call was not nested (receiver is the first entry) and // Builtin call was not nested (receiver is the first entry) and
// did not contain other nested arrays that expanded the stack. // did not contain other nested arrays that expanded the stack.
if (stack.objects[0] == receiver && len == kMinJoinStackSize) { if (stack.objects[0] == receiver && len == kMinJoinStackSize) {
StoreFixedArrayElement(stack, 0, Hole, SKIP_WRITE_BARRIER); StoreFixedArrayElement(stack, 0, TheHole, SKIP_WRITE_BARRIER);
} else } else
deferred { deferred {
JoinStackPop(stack, receiver); JoinStackPop(stack, receiver);
......
...@@ -12,7 +12,7 @@ namespace array_lastindexof { ...@@ -12,7 +12,7 @@ namespace array_lastindexof {
labels IfHole { labels IfHole {
const elements: FixedArray = UnsafeCast<FixedArray>(elements); const elements: FixedArray = UnsafeCast<FixedArray>(elements);
const element: Object = elements.objects[index]; const element: Object = elements.objects[index];
if (element == Hole) goto IfHole; if (element == TheHole) goto IfHole;
return element; return element;
} }
......
...@@ -132,7 +132,7 @@ namespace array_map { ...@@ -132,7 +132,7 @@ namespace array_map {
elements.floats[i] = Convert<float64>(n); elements.floats[i] = Convert<float64>(n);
} }
case (h: HeapObject): { case (h: HeapObject): {
assert(h == Hole); assert(h == TheHole);
} }
} }
} }
......
...@@ -22,7 +22,7 @@ namespace array { ...@@ -22,7 +22,7 @@ namespace array {
// the hole. The continuation stub will search for the initial non-hole // the hole. The continuation stub will search for the initial non-hole
// element, rightly throwing an exception if not found. // element, rightly throwing an exception if not found.
return ArrayReduceRightLoopContinuation( return ArrayReduceRightLoopContinuation(
jsreceiver, callbackfn, Hole, jsreceiver, 0, numberLength); jsreceiver, callbackfn, TheHole, jsreceiver, 0, numberLength);
} }
transitioning javascript builtin transitioning javascript builtin
...@@ -85,7 +85,7 @@ namespace array { ...@@ -85,7 +85,7 @@ namespace array {
// 8b iii and 9c i. Let kValue be ? Get(O, Pk). // 8b iii and 9c i. Let kValue be ? Get(O, Pk).
const value: Object = GetProperty(o, k); const value: Object = GetProperty(o, k);
if (accumulator == Hole) { if (accumulator == TheHole) {
// 8b iii 1. // 8b iii 1.
accumulator = value; accumulator = value;
} else { } else {
...@@ -102,7 +102,7 @@ namespace array { ...@@ -102,7 +102,7 @@ namespace array {
// 8c. if kPresent is false, throw a TypeError exception. // 8c. if kPresent is false, throw a TypeError exception.
// If the accumulator is discovered with the sentinel hole value, // If the accumulator is discovered with the sentinel hole value,
// this means kPresent is false. // this means kPresent is false.
if (accumulator == Hole) { if (accumulator == TheHole) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight'); ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight');
} }
return accumulator; return accumulator;
...@@ -126,7 +126,7 @@ namespace array { ...@@ -126,7 +126,7 @@ namespace array {
if (k >= fastOW.Get().length) goto Bailout(k, accumulator); if (k >= fastOW.Get().length) goto Bailout(k, accumulator);
const value: Object = fastOW.LoadElementNoHole(k) otherwise continue; const value: Object = fastOW.LoadElementNoHole(k) otherwise continue;
if (accumulator == Hole) { if (accumulator == TheHole) {
accumulator = value; accumulator = value;
} else { } else {
accumulator = Call( accumulator = Call(
...@@ -134,7 +134,7 @@ namespace array { ...@@ -134,7 +134,7 @@ namespace array {
fastOW.Get()); fastOW.Get());
} }
} }
if (accumulator == Hole) { if (accumulator == TheHole) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight'); ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight');
} }
return accumulator; return accumulator;
...@@ -165,7 +165,8 @@ namespace array { ...@@ -165,7 +165,8 @@ namespace array {
// exception. (This case is handled at the end of // exception. (This case is handled at the end of
// ArrayReduceRightLoopContinuation). // ArrayReduceRightLoopContinuation).
const initialValue: Object = arguments.length > 1 ? arguments[1] : Hole; const initialValue: Object =
arguments.length > 1 ? arguments[1] : TheHole;
try { try {
return FastArrayReduceRight(o, len, callbackfn, initialValue) return FastArrayReduceRight(o, len, callbackfn, initialValue)
......
...@@ -22,7 +22,7 @@ namespace array { ...@@ -22,7 +22,7 @@ namespace array {
// the hole. The continuation stub will search for the initial non-hole // the hole. The continuation stub will search for the initial non-hole
// element, rightly throwing an exception if not found. // element, rightly throwing an exception if not found.
return ArrayReduceLoopContinuation( return ArrayReduceLoopContinuation(
jsreceiver, callbackfn, Hole, jsreceiver, 0, numberLength); jsreceiver, callbackfn, TheHole, jsreceiver, 0, numberLength);
} }
transitioning javascript builtin transitioning javascript builtin
...@@ -84,7 +84,7 @@ namespace array { ...@@ -84,7 +84,7 @@ namespace array {
// 6c. i. Let kValue be ? Get(O, Pk). // 6c. i. Let kValue be ? Get(O, Pk).
const value: Object = GetProperty(o, k); const value: Object = GetProperty(o, k);
if (accumulator == Hole) { if (accumulator == TheHole) {
// 8b. // 8b.
accumulator = value; accumulator = value;
} else { } else {
...@@ -101,7 +101,7 @@ namespace array { ...@@ -101,7 +101,7 @@ namespace array {
// 8c. if kPresent is false, throw a TypeError exception. // 8c. if kPresent is false, throw a TypeError exception.
// If the accumulator is discovered with the sentinel hole value, // If the accumulator is discovered with the sentinel hole value,
// this means kPresent is false. // this means kPresent is false.
if (accumulator == Hole) { if (accumulator == TheHole) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce'); ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce');
} }
return accumulator; return accumulator;
...@@ -126,7 +126,7 @@ namespace array { ...@@ -126,7 +126,7 @@ namespace array {
if (k >= fastOW.Get().length) goto Bailout(k, accumulator); if (k >= fastOW.Get().length) goto Bailout(k, accumulator);
const value: Object = fastOW.LoadElementNoHole(k) otherwise continue; const value: Object = fastOW.LoadElementNoHole(k) otherwise continue;
if (accumulator == Hole) { if (accumulator == TheHole) {
accumulator = value; accumulator = value;
} else { } else {
accumulator = Call( accumulator = Call(
...@@ -134,7 +134,7 @@ namespace array { ...@@ -134,7 +134,7 @@ namespace array {
fastOW.Get()); fastOW.Get());
} }
} }
if (accumulator == Hole) { if (accumulator == TheHole) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce'); ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce');
} }
return accumulator; return accumulator;
...@@ -165,7 +165,8 @@ namespace array { ...@@ -165,7 +165,8 @@ namespace array {
// exception. (This case is handled at the end of // exception. (This case is handled at the end of
// ArrayReduceLoopContinuation). // ArrayReduceLoopContinuation).
const initialValue: Object = arguments.length > 1 ? arguments[1] : Hole; const initialValue: Object =
arguments.length > 1 ? arguments[1] : TheHole;
try { try {
return FastArrayReduce(o, len, callbackfn, initialValue) return FastArrayReduce(o, len, callbackfn, initialValue)
......
...@@ -63,7 +63,7 @@ namespace array_slice { ...@@ -63,7 +63,7 @@ namespace array_slice {
for (let current: Smi = start; current < to; ++current) { for (let current: Smi = start; current < to; ++current) {
const e: Object = const e: Object =
sloppyElements.objects[current + kSloppyArgumentsParameterMapStart]; sloppyElements.objects[current + kSloppyArgumentsParameterMapStart];
const newElement: Object = e != Hole ? const newElement: Object = e != TheHole ?
argumentsContext[UnsafeCast<Smi>(e)] : argumentsContext[UnsafeCast<Smi>(e)] :
unmappedElements.objects[current]; unmappedElements.objects[current];
// It is safe to skip the write barrier here because resultElements was // It is safe to skip the write barrier here because resultElements was
......
...@@ -45,7 +45,7 @@ namespace array { ...@@ -45,7 +45,7 @@ namespace array {
macro LoadElementOrUndefined(a: FixedArray, i: Smi): Object { macro LoadElementOrUndefined(a: FixedArray, i: Smi): Object {
const e: Object = a.objects[i]; const e: Object = a.objects[i];
return e == Hole ? Undefined : e; return e == TheHole ? Undefined : e;
} }
macro LoadElementOrUndefined(a: FixedDoubleArray, i: Smi): NumberOrUndefined { macro LoadElementOrUndefined(a: FixedDoubleArray, i: Smi): NumberOrUndefined {
...@@ -63,7 +63,7 @@ namespace array { ...@@ -63,7 +63,7 @@ namespace array {
} }
macro StoreArrayHole(elements: FixedArray, k: Smi): void { macro StoreArrayHole(elements: FixedArray, k: Smi): void {
elements.objects[k] = Hole; elements.objects[k] = TheHole;
} }
extern macro SetPropertyLength(implicit context: Context)(Object, Number); extern macro SetPropertyLength(implicit context: Context)(Object, Number);
......
...@@ -32,6 +32,9 @@ type PositiveSmi extends Smi; ...@@ -32,6 +32,9 @@ type PositiveSmi extends Smi;
// The Smi value zero, which is often used as null for HeapObject types. // The Smi value zero, which is often used as null for HeapObject types.
type Zero extends PositiveSmi; type Zero extends PositiveSmi;
// A value with the size of Tagged which may contain arbitrary data.
type Uninitialized extends Tagged;
@abstract @abstract
extern class HeapObject extends Tagged { extern class HeapObject extends Tagged {
map: Map; map: Map;
...@@ -210,6 +213,8 @@ extern class Map extends HeapObject { ...@@ -210,6 +213,8 @@ extern class Map extends HeapObject {
@ifnot(V8_DOUBLE_FIELDS_UNBOXING) layout_descriptor: void; @ifnot(V8_DOUBLE_FIELDS_UNBOXING) layout_descriptor: void;
dependent_code: DependentCode; dependent_code: DependentCode;
prototype_validity_cell: Smi | Cell; prototype_validity_cell: Smi | Cell;
// TODO(v8:9108): Misusing "weak" keyword; type should be
// Map | Weak<Map> | TransitionArray | PrototypeInfo | Smi.
weak transitions_or_prototype_info: Map | TransitionArray | weak transitions_or_prototype_info: Map | TransitionArray |
PrototypeInfo | Smi; PrototypeInfo | Smi;
} }
...@@ -276,9 +281,8 @@ intrinsic ...@@ -276,9 +281,8 @@ intrinsic
} }
@abstract @abstract
@noVerifier
extern class JSReceiver extends HeapObject { extern class JSReceiver extends HeapObject {
properties_or_hash: FixedArrayBase | Smi; properties_or_hash: FixedArrayBase | PropertyArray | Smi;
} }
type Constructor extends JSReceiver; type Constructor extends JSReceiver;
...@@ -286,7 +290,7 @@ type Constructor extends JSReceiver; ...@@ -286,7 +290,7 @@ type Constructor extends JSReceiver;
@abstract @abstract
@dirtyInstantiatedAbstractClass @dirtyInstantiatedAbstractClass
extern class JSObject extends JSReceiver { extern class JSObject extends JSReceiver {
@noVerifier elements: FixedArrayBase; elements: FixedArrayBase;
} }
macro NewJSObject(implicit context: Context)(): JSObject { macro NewJSObject(implicit context: Context)(): JSObject {
...@@ -332,6 +336,8 @@ extern class JSFunction extends JSObject { ...@@ -332,6 +336,8 @@ extern class JSFunction extends JSObject {
context: Context; context: Context;
feedback_cell: FeedbackCell; feedback_cell: FeedbackCell;
weak code: Code; weak code: Code;
// Space for the following field may or may not be allocated.
@noVerifier weak prototype_or_initial_map: JSReceiver | Map; @noVerifier weak prototype_or_initial_map: JSReceiver | Map;
} }
...@@ -377,6 +383,7 @@ extern class JSSloppyArgumentsObject extends JSArgumentsObjectWithLength { ...@@ -377,6 +383,7 @@ extern class JSSloppyArgumentsObject extends JSArgumentsObjectWithLength {
callee: Object; callee: Object;
} }
// Just a starting shape for JSObject; properties can move after initialization.
@hasSameInstanceTypeAsParent @hasSameInstanceTypeAsParent
@noVerifier @noVerifier
extern class JSStrictArgumentsObject extends JSArgumentsObjectWithLength { extern class JSStrictArgumentsObject extends JSArgumentsObjectWithLength {
...@@ -460,7 +467,7 @@ extern class Module extends Struct { ...@@ -460,7 +467,7 @@ extern class Module extends Struct {
dfs_ancestor_index: Smi; dfs_ancestor_index: Smi;
exception: Object; exception: Object;
script: Script; script: Script;
@noVerifier import_meta: Hole | JSObject; import_meta: TheHole | JSObject;
} }
@abstract @abstract
...@@ -513,6 +520,7 @@ extern class PrototypeInfo extends Struct { ...@@ -513,6 +520,7 @@ extern class PrototypeInfo extends Struct {
prototype_users: WeakArrayList | Zero; prototype_users: WeakArrayList | Zero;
registry_slot: Smi; registry_slot: Smi;
validity_cell: Object; validity_cell: Object;
// TODO(v8:9108): Should be Weak<Map> | Undefined.
@noVerifier object_create_map: Map | Undefined; @noVerifier object_create_map: Map | Undefined;
bit_field: Smi; bit_field: Smi;
} }
...@@ -537,7 +545,7 @@ extern class Script extends Struct { ...@@ -537,7 +545,7 @@ extern class Script extends Struct {
extern class EmbedderDataArray extends HeapObject { length: Smi; } extern class EmbedderDataArray extends HeapObject { length: Smi; }
type ScopeInfo extends Object generates 'TNode<ScopeInfo>'; type ScopeInfo extends HeapObject generates 'TNode<ScopeInfo>';
extern class PreparseData extends HeapObject { extern class PreparseData extends HeapObject {
// TODO(v8:8983): Add declaration for variable-sized region. // TODO(v8:8983): Add declaration for variable-sized region.
...@@ -570,9 +578,12 @@ extern class JSBoundFunction extends JSObject { ...@@ -570,9 +578,12 @@ extern class JSBoundFunction extends JSObject {
bound_arguments: FixedArray; bound_arguments: FixedArray;
} }
// Specialized types. The following two type definitions don't correspond to // Specialized types. The following three type definitions don't correspond to
// actual C++ classes, but have Is... methods that check additional constraints. // actual C++ classes, but have Is... methods that check additional constraints.
// A Foreign object whose raw pointer is not allowed to be null.
type NonNullForeign extends Foreign;
// A function built with InstantiateFunction for the public API. // A function built with InstantiateFunction for the public API.
type CallableApiObject extends HeapObject; type CallableApiObject extends HeapObject;
...@@ -591,7 +602,7 @@ type NumberDictionary extends HeapObject ...@@ -591,7 +602,7 @@ type NumberDictionary extends HeapObject
extern class FreeSpace extends HeapObject { extern class FreeSpace extends HeapObject {
size: Smi; size: Smi;
@noVerifier next: FreeSpace; next: FreeSpace | Uninitialized;
} }
// %RawDownCast should *never* be used anywhere in Torque code except for // %RawDownCast should *never* be used anywhere in Torque code except for
...@@ -773,13 +784,13 @@ const UTF32: ...@@ -773,13 +784,13 @@ const UTF32:
extern class Foreign extends HeapObject { foreign_address: RawPtr; } extern class Foreign extends HeapObject { foreign_address: RawPtr; }
extern class InterceptorInfo extends Struct { extern class InterceptorInfo extends Struct {
@noVerifier getter: Foreign | Zero; getter: NonNullForeign | Zero | Undefined;
@noVerifier setter: Foreign | Zero; setter: NonNullForeign | Zero | Undefined;
@noVerifier query: Foreign | Zero; query: NonNullForeign | Zero | Undefined;
@noVerifier descriptor: Foreign | Zero; descriptor: NonNullForeign | Zero | Undefined;
@noVerifier deleter: Foreign | Zero; deleter: NonNullForeign | Zero | Undefined;
@noVerifier enumerator: Foreign | Zero; enumerator: NonNullForeign | Zero | Undefined;
@noVerifier definer: Foreign | Zero; definer: NonNullForeign | Zero | Undefined;
data: Object; data: Object;
flags: Smi; flags: Smi;
} }
...@@ -803,6 +814,9 @@ extern class Cell extends HeapObject { value: Object; } ...@@ -803,6 +814,9 @@ extern class Cell extends HeapObject { value: Object; }
extern class DataHandler extends Struct { extern class DataHandler extends Struct {
smi_handler: Smi | Code; smi_handler: Smi | Code;
validity_cell: Smi | Cell; validity_cell: Smi | Cell;
// Space for the following fields may or may not be allocated.
// TODO(v8:9108): Misusing "weak" keyword; should be MaybeObject.
@noVerifier weak data_1: Object; @noVerifier weak data_1: Object;
@noVerifier weak data_2: Object; @noVerifier weak data_2: Object;
@noVerifier weak data_3: Object; @noVerifier weak data_3: Object;
...@@ -1078,7 +1092,7 @@ const kExternalPointerForOnHeapArray: constexpr RawPtr ...@@ -1078,7 +1092,7 @@ const kExternalPointerForOnHeapArray: constexpr RawPtr
const kNameDictionaryInitialCapacity: const kNameDictionaryInitialCapacity:
constexpr int32 generates 'NameDictionary::kInitialCapacity'; constexpr int32 generates 'NameDictionary::kInitialCapacity';
type Hole extends Oddball; type TheHole extends Oddball;
type Null extends Oddball; type Null extends Oddball;
type Undefined extends Oddball; type Undefined extends Oddball;
type True extends Oddball; type True extends Oddball;
...@@ -1088,7 +1102,7 @@ type Boolean = True | False; ...@@ -1088,7 +1102,7 @@ type Boolean = True | False;
type NumberOrUndefined = Number | Undefined; type NumberOrUndefined = Number | Undefined;
extern macro TheHoleConstant(): Hole; extern macro TheHoleConstant(): TheHole;
extern macro NullConstant(): Null; extern macro NullConstant(): Null;
extern macro UndefinedConstant(): Undefined; extern macro UndefinedConstant(): Undefined;
extern macro TrueConstant(): True; extern macro TrueConstant(): True;
...@@ -1099,7 +1113,7 @@ extern macro EmptyStringConstant(): EmptyString; ...@@ -1099,7 +1113,7 @@ extern macro EmptyStringConstant(): EmptyString;
extern macro LengthStringConstant(): String; extern macro LengthStringConstant(): String;
extern macro NanConstant(): NaN; extern macro NanConstant(): NaN;
const Hole: Hole = TheHoleConstant(); const TheHole: TheHole = TheHoleConstant();
const Null: Null = NullConstant(); const Null: Null = NullConstant();
const Undefined: Undefined = UndefinedConstant(); const Undefined: Undefined = UndefinedConstant();
const True: True = TrueConstant(); const True: True = TrueConstant();
...@@ -1240,9 +1254,9 @@ extern class AccessorInfo extends Struct { ...@@ -1240,9 +1254,9 @@ extern class AccessorInfo extends Struct {
name: Object; name: Object;
flags: Smi; flags: Smi;
expected_receiver_type: Object; expected_receiver_type: Object;
setter: Foreign | Zero; setter: NonNullForeign | Zero;
getter: Foreign | Zero; getter: NonNullForeign | Zero;
js_getter: Foreign | Zero; js_getter: NonNullForeign | Zero;
data: Object; data: Object;
} }
...@@ -2589,7 +2603,7 @@ LoadElementNoHole<FixedArray>(implicit context: Context)( ...@@ -2589,7 +2603,7 @@ LoadElementNoHole<FixedArray>(implicit context: Context)(
const elements: FixedArray = const elements: FixedArray =
Cast<FixedArray>(a.elements) otherwise Unexpected; Cast<FixedArray>(a.elements) otherwise Unexpected;
const e: Object = elements.objects[index]; const e: Object = elements.objects[index];
if (e == Hole) { if (e == TheHole) {
goto IfHole; goto IfHole;
} }
return e; return e;
...@@ -2650,7 +2664,7 @@ struct FastJSArrayWitness { ...@@ -2650,7 +2664,7 @@ struct FastJSArrayWitness {
} else { } else {
const elements = Cast<FixedArray>(this.unstable.elements) const elements = Cast<FixedArray>(this.unstable.elements)
otherwise unreachable; otherwise unreachable;
StoreFixedArrayElement(elements, k, Hole); StoreFixedArrayElement(elements, k, TheHole);
} }
} }
......
...@@ -19,7 +19,7 @@ namespace typed_array_reduce { ...@@ -19,7 +19,7 @@ namespace typed_array_reduce {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: Object = witness.Load(k);
if (accumulator == Hole) { if (accumulator == TheHole) {
accumulator = value; accumulator = value;
} else { } else {
accumulator = Call( accumulator = Call(
...@@ -27,7 +27,7 @@ namespace typed_array_reduce { ...@@ -27,7 +27,7 @@ namespace typed_array_reduce {
witness.GetStable()); witness.GetStable());
} }
} }
if (accumulator == Hole) { if (accumulator == TheHole) {
ThrowTypeError(kReduceNoInitial, kBuiltinName); ThrowTypeError(kReduceNoInitial, kBuiltinName);
} }
return accumulator; return accumulator;
...@@ -45,7 +45,7 @@ namespace typed_array_reduce { ...@@ -45,7 +45,7 @@ namespace typed_array_reduce {
const uarray = typed_array::EnsureAttached(array) otherwise IsDetached; const uarray = typed_array::EnsureAttached(array) otherwise IsDetached;
const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable; const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable;
const initialValue = arguments.length >= 2 ? arguments[1] : Hole; const initialValue = arguments.length >= 2 ? arguments[1] : TheHole;
return ReduceAllElements(uarray, callbackfn, initialValue); return ReduceAllElements(uarray, callbackfn, initialValue);
} }
label NotCallable deferred { label NotCallable deferred {
......
...@@ -19,7 +19,7 @@ namespace typed_array_reduceright { ...@@ -19,7 +19,7 @@ namespace typed_array_reduceright {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: Object = witness.Load(k);
if (accumulator == Hole) { if (accumulator == TheHole) {
accumulator = value; accumulator = value;
} else { } else {
accumulator = Call( accumulator = Call(
...@@ -27,7 +27,7 @@ namespace typed_array_reduceright { ...@@ -27,7 +27,7 @@ namespace typed_array_reduceright {
witness.GetStable()); witness.GetStable());
} }
} }
if (accumulator == Hole) { if (accumulator == TheHole) {
ThrowTypeError(kReduceNoInitial, kBuiltinName); ThrowTypeError(kReduceNoInitial, kBuiltinName);
} }
return accumulator; return accumulator;
...@@ -45,7 +45,7 @@ namespace typed_array_reduceright { ...@@ -45,7 +45,7 @@ namespace typed_array_reduceright {
const uarray = typed_array::EnsureAttached(array) otherwise IsDetached; const uarray = typed_array::EnsureAttached(array) otherwise IsDetached;
const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable; const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable;
const initialValue = arguments.length >= 2 ? arguments[1] : Hole; const initialValue = arguments.length >= 2 ? arguments[1] : TheHole;
return ReduceRightAllElements(uarray, callbackfn, initialValue); return ReduceRightAllElements(uarray, callbackfn, initialValue);
} }
......
...@@ -127,13 +127,6 @@ void MaybeObject::VerifyMaybeObjectPointer(Isolate* isolate, MaybeObject p) { ...@@ -127,13 +127,6 @@ void MaybeObject::VerifyMaybeObjectPointer(Isolate* isolate, MaybeObject p) {
} }
} }
namespace {
void VerifyForeignPointer(Isolate* isolate, HeapObject host, Object foreign) {
host.VerifyPointer(isolate, foreign);
CHECK(foreign.IsUndefined(isolate) || Foreign::IsNormalized(foreign));
}
} // namespace
void Smi::SmiVerify(Isolate* isolate) { void Smi::SmiVerify(Isolate* isolate) {
CHECK(IsSmi()); CHECK(IsSmi());
CHECK(!IsCallable()); CHECK(!IsCallable());
...@@ -524,6 +517,8 @@ void FeedbackVector::FeedbackVectorVerify(Isolate* isolate) { ...@@ -524,6 +517,8 @@ void FeedbackVector::FeedbackVectorVerify(Isolate* isolate) {
CHECK(code->IsSmi() || code->IsWeakOrCleared()); CHECK(code->IsSmi() || code->IsWeakOrCleared());
} }
USE_TORQUE_VERIFIER(JSReceiver)
bool JSObject::ElementsAreSafeToExamine() const { bool JSObject::ElementsAreSafeToExamine() const {
// If a GC was caused while constructing this object, the elements // If a GC was caused while constructing this object, the elements
// pointer may point to a one pointer filler map. // pointer may point to a one pointer filler map.
...@@ -1569,8 +1564,6 @@ void Module::ModuleVerify(Isolate* isolate) { ...@@ -1569,8 +1564,6 @@ void Module::ModuleVerify(Isolate* isolate) {
CHECK_EQ(requested_modules().length(), info().module_requests().length()); CHECK_EQ(requested_modules().length(), info().module_requests().length());
CHECK(import_meta().IsTheHole(isolate) || import_meta().IsJSObject());
CHECK_NE(hash(), 0); CHECK_NE(hash(), 0);
} }
...@@ -1702,12 +1695,7 @@ void StoreHandler::StoreHandlerVerify(Isolate* isolate) { ...@@ -1702,12 +1695,7 @@ void StoreHandler::StoreHandlerVerify(Isolate* isolate) {
// TODO(ishell): check handler integrity // TODO(ishell): check handler integrity
} }
void AccessorInfo::AccessorInfoVerify(Isolate* isolate) { USE_TORQUE_VERIFIER(AccessorInfo)
TorqueGeneratedClassVerifiers::AccessorInfoVerify(*this, isolate);
VerifyForeignPointer(isolate, *this, getter());
VerifyForeignPointer(isolate, *this, setter());
VerifyForeignPointer(isolate, *this, js_getter());
}
USE_TORQUE_VERIFIER(AccessorPair) USE_TORQUE_VERIFIER(AccessorPair)
...@@ -1722,16 +1710,7 @@ void CallHandlerInfo::CallHandlerInfoVerify(Isolate* isolate) { ...@@ -1722,16 +1710,7 @@ void CallHandlerInfo::CallHandlerInfoVerify(Isolate* isolate) {
.next_call_side_effect_free_call_handler_info_map()); .next_call_side_effect_free_call_handler_info_map());
} }
void InterceptorInfo::InterceptorInfoVerify(Isolate* isolate) { USE_TORQUE_VERIFIER(InterceptorInfo)
TorqueGeneratedClassVerifiers::InterceptorInfoVerify(*this, isolate);
VerifyForeignPointer(isolate, *this, getter());
VerifyForeignPointer(isolate, *this, setter());
VerifyForeignPointer(isolate, *this, query());
VerifyForeignPointer(isolate, *this, descriptor());
VerifyForeignPointer(isolate, *this, deleter());
VerifyForeignPointer(isolate, *this, enumerator());
VerifyForeignPointer(isolate, *this, definer());
}
USE_TORQUE_VERIFIER(TemplateInfo) USE_TORQUE_VERIFIER(TemplateInfo)
......
...@@ -68,6 +68,7 @@ class JSReceiver : public HeapObject { ...@@ -68,6 +68,7 @@ class JSReceiver : public HeapObject {
static void DeleteNormalizedProperty(Handle<JSReceiver> object, int entry); static void DeleteNormalizedProperty(Handle<JSReceiver> object, int entry);
DECL_CAST(JSReceiver) DECL_CAST(JSReceiver)
DECL_VERIFIER(JSReceiver)
// ES6 section 7.1.1 ToPrimitive // ES6 section 7.1.1 ToPrimitive
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ToPrimitive( V8_WARN_UNUSED_RESULT static MaybeHandle<Object> ToPrimitive(
......
...@@ -253,7 +253,8 @@ class ZoneForwardList; ...@@ -253,7 +253,8 @@ class ZoneForwardList;
// represent some specialization in terms of additional constraints. // represent some specialization in terms of additional constraints.
#define HEAP_OBJECT_SPECIALIZED_TYPE_LIST(V) \ #define HEAP_OBJECT_SPECIALIZED_TYPE_LIST(V) \
V(CallableApiObject) \ V(CallableApiObject) \
V(CallableJSProxy) V(CallableJSProxy) \
V(NonNullForeign)
#define HEAP_OBJECT_TYPE_LIST(V) \ #define HEAP_OBJECT_TYPE_LIST(V) \
HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \ HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \
......
...@@ -163,6 +163,10 @@ bool HeapObject::IsCallableApiObject() const { ...@@ -163,6 +163,10 @@ bool HeapObject::IsCallableApiObject() const {
(type == JS_API_OBJECT_TYPE || type == JS_SPECIAL_API_OBJECT_TYPE); (type == JS_API_OBJECT_TYPE || type == JS_SPECIAL_API_OBJECT_TYPE);
} }
bool HeapObject::IsNonNullForeign() const {
return IsForeign() && Foreign::cast(*this).foreign_address() != kNullAddress;
}
bool HeapObject::IsConstructor() const { return map().is_constructor(); } bool HeapObject::IsConstructor() const { return map().is_constructor(); }
bool HeapObject::IsModuleInfo() const { bool HeapObject::IsModuleInfo() const {
......
...@@ -29,6 +29,7 @@ static const char* const HEAP_OBJECT_TYPE_STRING = "HeapObject"; ...@@ -29,6 +29,7 @@ static const char* const HEAP_OBJECT_TYPE_STRING = "HeapObject";
static const char* const JSOBJECT_TYPE_STRING = "JSObject"; static const char* const JSOBJECT_TYPE_STRING = "JSObject";
static const char* const SMI_TYPE_STRING = "Smi"; static const char* const SMI_TYPE_STRING = "Smi";
static const char* const TAGGED_TYPE_STRING = "Tagged"; static const char* const TAGGED_TYPE_STRING = "Tagged";
static const char* const UNINITIALIZED_TYPE_STRING = "Uninitialized";
static const char* const RAWPTR_TYPE_STRING = "RawPtr"; static const char* const RAWPTR_TYPE_STRING = "RawPtr";
static const char* const CONST_STRING_TYPE_STRING = "constexpr string"; static const char* const CONST_STRING_TYPE_STRING = "constexpr string";
static const char* const STRING_TYPE_STRING = "String"; static const char* const STRING_TYPE_STRING = "String";
......
...@@ -3357,8 +3357,10 @@ void GenerateClassFieldVerifier(const std::string& class_name, ...@@ -3357,8 +3357,10 @@ void GenerateClassFieldVerifier(const std::string& class_name,
if (!f.generate_verify) return; if (!f.generate_verify) return;
const Type* field_type = f.name_and_type.type; const Type* field_type = f.name_and_type.type;
// We only verify tagged types, not raw numbers or pointers. // We only verify tagged types, not raw numbers or pointers. Note that this
if (!field_type->IsSubtypeOf(TypeOracle::GetTaggedType())) return; // must check against GetObjectType not GetTaggedType, because Uninitialized
// is a Tagged but should not be verified.
if (!field_type->IsSubtypeOf(TypeOracle::GetObjectType())) return;
if (f.index) { if (f.index) {
if ((*f.index)->name_and_type.type != TypeOracle::GetSmiType()) { if ((*f.index)->name_and_type.type != TypeOracle::GetSmiType()) {
......
...@@ -135,6 +135,10 @@ class TypeOracle : public ContextualClass<TypeOracle> { ...@@ -135,6 +135,10 @@ class TypeOracle : public ContextualClass<TypeOracle> {
return Get().GetBuiltinType(TAGGED_TYPE_STRING); return Get().GetBuiltinType(TAGGED_TYPE_STRING);
} }
static const Type* GetUninitializedType() {
return Get().GetBuiltinType(UNINITIALIZED_TYPE_STRING);
}
static const Type* GetSmiType() { static const Type* GetSmiType() {
return Get().GetBuiltinType(SMI_TYPE_STRING); return Get().GetBuiltinType(SMI_TYPE_STRING);
} }
......
...@@ -57,6 +57,12 @@ const AbstractType* TypeVisitor::ComputeType(AbstractTypeDeclaration* decl) { ...@@ -57,6 +57,12 @@ const AbstractType* TypeVisitor::ComputeType(AbstractTypeDeclaration* decl) {
const Type* parent_type = nullptr; const Type* parent_type = nullptr;
if (decl->extends) { if (decl->extends) {
parent_type = Declarations::LookupType(*decl->extends); parent_type = Declarations::LookupType(*decl->extends);
if (parent_type->IsUnionType()) {
// UnionType::IsSupertypeOf requires that types can only extend from non-
// union types in order to work correctly.
ReportError("type \"", decl->name->value,
"\" cannot extend a type union");
}
} }
if (generates == "" && parent_type) { if (generates == "" && parent_type) {
......
...@@ -156,7 +156,7 @@ bool ContainsUpperCase(const std::string& s) { ...@@ -156,7 +156,7 @@ bool ContainsUpperCase(const std::string& s) {
// keywords, e.g.: 'True', 'Undefined', etc. // keywords, e.g.: 'True', 'Undefined', etc.
// These do not need to follow the default naming convention for constants. // These do not need to follow the default naming convention for constants.
bool IsKeywordLikeName(const std::string& s) { bool IsKeywordLikeName(const std::string& s) {
static const char* const keyword_like_constants[]{"True", "False", "Hole", static const char* const keyword_like_constants[]{"True", "False", "TheHole",
"Null", "Undefined"}; "Null", "Undefined"};
return std::find(std::begin(keyword_like_constants), return std::find(std::begin(keyword_like_constants),
......
...@@ -867,7 +867,7 @@ namespace test { ...@@ -867,7 +867,7 @@ namespace test {
struct TestIterator { struct TestIterator {
Next(): Object labels NoMore { Next(): Object labels NoMore {
if (this.count-- == 0) goto NoMore; if (this.count-- == 0) goto NoMore;
return Hole; return TheHole;
} }
count: Smi; count: Smi;
} }
...@@ -947,8 +947,8 @@ namespace test { ...@@ -947,8 +947,8 @@ namespace test {
macro TestRedundantArrayElementCheck(implicit context: Context)(): Smi { macro TestRedundantArrayElementCheck(implicit context: Context)(): Smi {
const a = kEmptyFixedArray; const a = kEmptyFixedArray;
for (let i: Smi = 0; i < a.length; i++) { for (let i: Smi = 0; i < a.length; i++) {
if (a.objects[i] == Hole) { if (a.objects[i] == TheHole) {
if (a.objects[i] == Hole) { if (a.objects[i] == TheHole) {
return -1; return -1;
} else { } else {
StaticAssert(false); StaticAssert(false);
......
...@@ -160,12 +160,10 @@ TEST(Torque, TypeDeclarationOrder) { ...@@ -160,12 +160,10 @@ TEST(Torque, TypeDeclarationOrder) {
type Baztype = Foo | FooType; type Baztype = Foo | FooType;
@abstract @abstract
@noVerifier
extern class Foo extends HeapObject { extern class Foo extends HeapObject {
fooField: FooType; fooField: FooType;
} }
@noVerifier
extern class Bar extends Foo { extern class Bar extends Foo {
barField: Bartype; barField: Bartype;
bazfield: Baztype; bazfield: Baztype;
...@@ -181,7 +179,6 @@ TEST(Torque, ConditionalFields) { ...@@ -181,7 +179,6 @@ TEST(Torque, ConditionalFields) {
// This class should throw alignment errors if @if decorators aren't // This class should throw alignment errors if @if decorators aren't
// working. // working.
ExpectSuccessfulCompilation(R"( ExpectSuccessfulCompilation(R"(
@noVerifier
extern class PreprocessingTest extends HeapObject { extern class PreprocessingTest extends HeapObject {
@if(FALSE_FOR_TESTING) a: int8; @if(FALSE_FOR_TESTING) a: int8;
@if(TRUE_FOR_TESTING) a: int16; @if(TRUE_FOR_TESTING) a: int16;
...@@ -194,7 +191,6 @@ TEST(Torque, ConditionalFields) { ...@@ -194,7 +191,6 @@ TEST(Torque, ConditionalFields) {
} }
)"); )");
ExpectFailingCompilation(R"( ExpectFailingCompilation(R"(
@noVerifier
extern class PreprocessingTest extends HeapObject { extern class PreprocessingTest extends HeapObject {
@if(TRUE_FOR_TESTING) a: int8; @if(TRUE_FOR_TESTING) a: int8;
@if(FALSE_FOR_TESTING) a: int16; @if(FALSE_FOR_TESTING) a: int16;
......
...@@ -230,7 +230,7 @@ namespace array { ...@@ -230,7 +230,7 @@ namespace array {
transitioning builtin Load<ElementsAccessor: type>( transitioning builtin Load<ElementsAccessor: type>(
context: Context, sortState: SortState, index: Smi): Object { context: Context, sortState: SortState, index: Smi): Object {
const receiver = sortState.receiver; const receiver = sortState.receiver;
if (!HasProperty_Inline(receiver, index)) return Hole; if (!HasProperty_Inline(receiver, index)) return TheHole;
return GetProperty(receiver, index); return GetProperty(receiver, index);
} }
...@@ -257,7 +257,7 @@ namespace array { ...@@ -257,7 +257,7 @@ namespace array {
return AllocateHeapNumberWithValue(value); return AllocateHeapNumberWithValue(value);
} }
label IfHole { label IfHole {
return Hole; return TheHole;
} }
} }
...@@ -308,7 +308,7 @@ namespace array { ...@@ -308,7 +308,7 @@ namespace array {
const object = UnsafeCast<JSObject>(sortState.receiver); const object = UnsafeCast<JSObject>(sortState.receiver);
const elements = UnsafeCast<FixedArray>(object.elements); const elements = UnsafeCast<FixedArray>(object.elements);
elements.objects[index] = Hole; elements.objects[index] = TheHole;
return kSuccess; return kSuccess;
} }
...@@ -318,7 +318,7 @@ namespace array { ...@@ -318,7 +318,7 @@ namespace array {
const object = UnsafeCast<JSObject>(sortState.receiver); const object = UnsafeCast<JSObject>(sortState.receiver);
const elements = UnsafeCast<FixedArray>(object.elements); const elements = UnsafeCast<FixedArray>(object.elements);
elements.objects[index] = Hole; elements.objects[index] = TheHole;
return kSuccess; return kSuccess;
} }
...@@ -1297,7 +1297,7 @@ namespace array { ...@@ -1297,7 +1297,7 @@ namespace array {
for (let i: Smi = 0; i < receiverLength; ++i) { for (let i: Smi = 0; i < receiverLength; ++i) {
const element: Object = loadFn(context, sortState, i); const element: Object = loadFn(context, sortState, i);
if (element == Hole) { if (element == TheHole) {
// Do nothing for holes. The result is that elements are // Do nothing for holes. The result is that elements are
// compacted at the front of the work array. // compacted at the front of the work array.
} else if (element == Undefined) { } else if (element == Undefined) {
...@@ -1330,7 +1330,7 @@ namespace array { ...@@ -1330,7 +1330,7 @@ namespace array {
// 1. Copy the sorted elements from the workarray to the receiver. // 1. Copy the sorted elements from the workarray to the receiver.
// 2. Add {nOfUndefined} undefineds to the receiver. // 2. Add {nOfUndefined} undefineds to the receiver.
// 3. Depending on the backing store either delete properties or // 3. Depending on the backing store either delete properties or
// set them to the Hole up to {sortState.sortLength}. // set them to the TheHole up to {sortState.sortLength}.
let index: Smi = 0; let index: Smi = 0;
for (; index < numberOfNonUndefined; ++index) { for (; index < numberOfNonUndefined; ++index) {
storeFn(context, sortState, index, workArray.objects[index]); storeFn(context, sortState, index, workArray.objects[index]);
......
...@@ -20,7 +20,7 @@ syn region torqueComment start="/\*" end="\*/" contains=@Spell ...@@ -20,7 +20,7 @@ syn region torqueComment start="/\*" end="\*/" contains=@Spell
syn region torqueStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ syn region torqueStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+
syn keyword torqueAssert assert check debug unreachable syn keyword torqueAssert assert check debug unreachable
syn keyword torqueAtom True False Undefined Hole Null syn keyword torqueAtom True False Undefined TheHole Null
syn keyword torqueBoolean true false syn keyword torqueBoolean true false
syn keyword torqueBranch break continue goto syn keyword torqueBranch break continue goto
syn keyword torqueConditional if else typeswitch otherwise syn keyword torqueConditional if else typeswitch otherwise
......
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