[torque] split base.tq

This creates a .tq file in src/objects for each src/objects/*.h file
with Torque-defined classes and moves the object definitions and
corresponding helpers/macros there.
In addition, we create files convert.tq and cast.tq in src/builtins
to move the casts and conversions to.

Since Torque-generated .cc files end up as .o files in the same
directory, there cannot be two .tq files of the same name. Thus it
was necessary to rename src/builtins/arguments.tq and
src/builtins/string.tq to not clash with the new files in src/objects.

This is a mechanical change that only moves code.

Design doc: http://doc/1fh4OUMjQMnQdJm3aiAPXQUNdgbQugkRGdJzDh8hmyzk

Bug: v8:9861 v8:9810 v8:7793
Change-Id: I9c54cb50f32b9ae0fb41752199515133eb59ea5c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1910100
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64892}
This commit is contained in:
Tobias Tebbi 2019-11-11 15:13:20 +01:00 committed by Commit Bot
parent b98a304686
commit 5bf81318f8
59 changed files with 2943 additions and 2720 deletions

View File

@ -920,7 +920,6 @@ action("postmortem-metadata") {
}
torque_files = [
"src/builtins/arguments.tq",
"src/builtins/array-copywithin.tq",
"src/builtins/array-every.tq",
"src/builtins/array-filter.tq",
@ -944,10 +943,14 @@ torque_files = [
"src/builtins/base.tq",
"src/builtins/bigint.tq",
"src/builtins/boolean.tq",
"src/builtins/builtins-string.tq",
"src/builtins/collections.tq",
"src/builtins/cast.tq",
"src/builtins/convert.tq",
"src/builtins/console.tq",
"src/builtins/data-view.tq",
"src/builtins/frames.tq",
"src/builtins/frame-arguments.tq",
"src/builtins/growable-fixed-array.tq",
"src/builtins/internal-coverage.tq",
"src/builtins/iterator.tq",
@ -978,7 +981,6 @@ torque_files = [
"src/builtins/regexp-split.tq",
"src/builtins/regexp-test.tq",
"src/builtins/regexp.tq",
"src/builtins/string.tq",
"src/builtins/string-endswith.tq",
"src/builtins/string-html.tq",
"src/builtins/string-iterator.tq",
@ -1006,7 +1008,59 @@ torque_files = [
"src/builtins/typed-array-some.tq",
"src/builtins/typed-array-subarray.tq",
"src/builtins/typed-array.tq",
"src/ic/handler-configuration.tq",
"src/objects/allocation-site.tq",
"src/objects/api-callbacks.tq",
"src/objects/arguments.tq",
"src/objects/cell.tq",
"src/objects/code.tq",
"src/objects/contexts.tq",
"src/objects/data-handler.tq",
"src/objects/debug-objects.tq",
"src/objects/descriptor-array.tq",
"src/objects/embedder-data-array.tq",
"src/objects/feedback-cell.tq",
"src/objects/feedback-vector.tq",
"src/objects/fixed-array.tq",
"src/objects/foreign.tq",
"src/objects/free-space.tq",
"src/objects/heap-number.tq",
"src/objects/heap-object.tq",
"src/objects/intl-objects.tq",
"src/objects/js-array-buffer.tq",
"src/objects/js-array.tq",
"src/objects/js-collection-iterator.tq",
"src/objects/js-collection.tq",
"src/objects/js-generator.tq",
"src/objects/js-objects.tq",
"src/objects/js-promise.tq",
"src/objects/js-proxy.tq",
"src/objects/js-regexp-string-iterator.tq",
"src/objects/js-regexp.tq",
"src/objects/js-weak-refs.tq",
"src/objects/literal-objects.tq",
"src/objects/map.tq",
"src/objects/microtask.tq",
"src/objects/module.tq",
"src/objects/name.tq",
"src/objects/oddball.tq",
"src/objects/ordered-hash-table.tq",
"src/objects/primitive-heap-object.tq",
"src/objects/promise.tq",
"src/objects/property-array.tq",
"src/objects/property-cell.tq",
"src/objects/prototype-info.tq",
"src/objects/regexp-match-info.tq",
"src/objects/script.tq",
"src/objects/shared-function-info.tq",
"src/objects/source-text-module.tq",
"src/objects/stack-frame-info.tq",
"src/objects/string.tq",
"src/objects/struct.tq",
"src/objects/synthetic-module.tq",
"src/objects/template-objects.tq",
"src/objects/template.tq",
"src/wasm/wasm-objects.tq",
"test/torque/test-torque.tq",
"third_party/v8/builtins/array-sort.tq",
]

File diff suppressed because it is too large Load Diff

679
src/builtins/cast.tq Normal file
View File

@ -0,0 +1,679 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern macro IsCallable(HeapObject): bool;
extern macro IsConstructor(HeapObject): bool;
extern macro IsFeedbackVector(HeapObject): bool;
extern macro IsJSArray(HeapObject): bool;
extern macro IsJSProxy(HeapObject): bool;
extern macro IsJSRegExp(HeapObject): bool;
extern macro IsJSRegExpStringIterator(HeapObject): bool;
extern macro IsMap(HeapObject): bool;
extern macro IsJSFunction(HeapObject): bool;
extern macro IsJSBoundFunction(HeapObject): bool;
extern macro IsJSObject(HeapObject): bool;
extern macro IsJSPromise(HeapObject): bool;
extern macro IsJSTypedArray(HeapObject): bool;
extern macro IsNumberDictionary(HeapObject): bool;
extern macro IsContext(HeapObject): bool;
extern macro IsNativeContext(HeapObject): bool;
extern macro IsJSReceiver(HeapObject): bool;
extern macro TaggedIsCallable(Object): bool;
extern macro IsDetachedBuffer(JSArrayBuffer): bool;
extern macro IsHeapNumber(HeapObject): bool;
extern macro IsBigInt(HeapObject): bool;
extern macro IsFixedArray(HeapObject): bool;
extern macro IsName(HeapObject): bool;
extern macro IsPrivateSymbol(HeapObject): bool;
extern macro IsNumber(Object): bool;
extern macro IsNumberNormalized(Number): bool;
extern macro IsSafeInteger(Object): bool;
extern macro IsOddball(HeapObject): bool;
extern macro IsSymbol(HeapObject): bool;
extern macro IsJSArrayMap(Map): bool;
extern macro IsExtensibleMap(Map): bool;
extern macro IsJSPrimitiveWrapper(HeapObject): bool;
extern macro IsPromiseCapability(HeapObject): bool;
extern macro IsPromiseReaction(HeapObject): bool;
extern macro IsPromiseRejectReactionJobTask(HeapObject): bool;
extern macro IsPromiseFulfillReactionJobTask(HeapObject): bool;
extern macro IsSharedFunctionInfo(HeapObject): bool;
extern macro IsCustomElementsReceiverInstanceType(int32): bool;
extern macro HeapObjectToJSDataView(HeapObject): JSDataView
labels CastError;
extern macro HeapObjectToJSProxy(HeapObject): JSProxy
labels CastError;
extern macro HeapObjectToJSStringIterator(HeapObject): JSStringIterator
labels CastError;
extern macro HeapObjectToJSArrayBuffer(HeapObject): JSArrayBuffer
labels CastError;
extern macro TaggedToHeapObject(Object): HeapObject
labels CastError;
extern macro TaggedToSmi(Object): Smi
labels CastError;
extern macro TaggedToPositiveSmi(Object): PositiveSmi
labels CastError;
extern macro TaggedToDirectString(Object): DirectString
labels CastError;
extern macro HeapObjectToJSArray(HeapObject): JSArray
labels CastError;
extern macro HeapObjectToCallable(HeapObject): Callable
labels CastError;
extern macro HeapObjectToFixedArray(HeapObject): FixedArray
labels CastError;
extern macro HeapObjectToFixedDoubleArray(HeapObject): FixedDoubleArray
labels CastError;
extern macro HeapObjectToString(HeapObject): String
labels CastError;
extern macro HeapObjectToConstructor(HeapObject): Constructor
labels CastError;
extern macro HeapObjectToHeapNumber(HeapObject): HeapNumber
labels CastError;
extern macro HeapObjectToSloppyArgumentsElements(HeapObject):
SloppyArgumentsElements
labels CastError;
extern macro HeapObjectToRegExpMatchInfo(HeapObject):
RegExpMatchInfo labels CastError;
extern macro TaggedToNumber(Object): Number
labels CastError;
macro Cast<A : type extends WeakHeapObject>(o: A|Object): A labels CastError {
if (!IsWeakOrCleared(o)) goto CastError;
return %RawDownCast<A>(o);
}
macro Cast<A: type>(o: MaybeObject): A labels CastError;
Cast<Undefined>(o: MaybeObject): Undefined labels CastError {
if (TaggedNotEqual(o, Undefined)) goto CastError;
return %RawDownCast<Undefined>(o);
}
macro Cast<A : type extends Object>(implicit context: Context)(o: Object): A
labels CastError {
return Cast<A>(TaggedToHeapObject(o) otherwise CastError)
otherwise CastError;
}
Cast<Smi>(o: Object): Smi
labels CastError {
return TaggedToSmi(o) otherwise CastError;
}
Cast<PositiveSmi>(o: Object): PositiveSmi
labels CastError {
return TaggedToPositiveSmi(o) otherwise CastError;
}
Cast<Zero>(o: Object): Zero labels CastError {
if (TaggedEqual(o, SmiConstant(0))) return %RawDownCast<Zero>(o);
goto CastError;
}
Cast<Number>(o: Object): Number
labels CastError {
return TaggedToNumber(o) otherwise CastError;
}
Cast<Undefined>(o: Object): Undefined
labels CastError {
const o: MaybeObject = o;
return Cast<Undefined>(o) otherwise CastError;
}
Cast<Numeric>(o: Object): Numeric labels CastError {
typeswitch (o) {
case (o: Number): {
return o;
}
case (o: BigInt): {
return o;
}
case (HeapObject): {
goto CastError;
}
}
}
Cast<TheHole>(o: Object): TheHole labels CastError {
if (o == TheHole) return %RawDownCast<TheHole>(o);
goto CastError;
}
Cast<TheHole>(o: HeapObject): TheHole labels CastError {
const o: Object = o;
return Cast<TheHole>(o) otherwise CastError;
}
Cast<True>(o: Object): True labels CastError {
if (o == True) return %RawDownCast<True>(o);
goto CastError;
}
Cast<True>(o: HeapObject): True labels CastError {
const o: Object = o;
return Cast<True>(o) otherwise CastError;
}
Cast<False>(o: Object): False labels CastError {
if (o == False) return %RawDownCast<False>(o);
goto CastError;
}
Cast<False>(o: HeapObject): False labels CastError {
const o: Object = o;
return Cast<False>(o) otherwise CastError;
}
Cast<Boolean>(o: Object): Boolean labels CastError {
typeswitch (o) {
case (o: True): {
return o;
}
case (o: False): {
return o;
}
case (Object): {
goto CastError;
}
}
}
Cast<Boolean>(o: HeapObject): Boolean labels CastError {
const o: Object = o;
return Cast<Boolean>(o) otherwise CastError;
}
// TODO(tebbi): These trivial casts for union types should be generated
// automatically.
Cast<JSPrimitive>(o: Object): JSPrimitive labels CastError {
typeswitch (o) {
case (o: Numeric): {
return o;
}
case (o: String): {
return o;
}
case (o: Symbol): {
return o;
}
case (o: Boolean): {
return o;
}
case (o: Undefined): {
return o;
}
case (o: Null): {
return o;
}
case (Object): {
goto CastError;
}
}
}
Cast<JSAny>(o: Object): JSAny labels CastError {
typeswitch (o) {
case (o: JSPrimitive): {
return o;
}
case (o: JSReceiver): {
return o;
}
case (Object): {
goto CastError;
}
}
}
Cast<JSAny|TheHole>(o: Object): JSAny|TheHole labels CastError {
typeswitch (o) {
case (o: JSAny): {
return o;
}
case (o: TheHole): {
return o;
}
case (Object): {
goto CastError;
}
}
}
Cast<Number|TheHole>(o: Object): Number|TheHole labels CastError {
typeswitch (o) {
case (o: Number): {
return o;
}
case (o: TheHole): {
return o;
}
case (Object): {
goto CastError;
}
}
}
macro Cast<A : type extends HeapObject>(o: HeapObject): A
labels CastError;
Cast<HeapObject>(o: HeapObject): HeapObject
labels _CastError {
return o;
}
Cast<Null>(o: HeapObject): Null
labels CastError {
if (o != Null) goto CastError;
return %RawDownCast<Null>(o);
}
Cast<Undefined>(o: HeapObject): Undefined
labels CastError {
const o: MaybeObject = o;
return Cast<Undefined>(o) otherwise CastError;
}
Cast<FixedArray>(o: HeapObject): FixedArray
labels CastError {
return HeapObjectToFixedArray(o) otherwise CastError;
}
Cast<FixedDoubleArray>(o: HeapObject): FixedDoubleArray
labels CastError {
return HeapObjectToFixedDoubleArray(o) otherwise CastError;
}
Cast<SloppyArgumentsElements>(o: HeapObject): SloppyArgumentsElements
labels CastError {
return HeapObjectToSloppyArgumentsElements(o) otherwise CastError;
}
Cast<JSDataView>(o: HeapObject): JSDataView
labels CastError {
return HeapObjectToJSDataView(o) otherwise CastError;
}
Cast<JSProxy>(o: HeapObject): JSProxy
labels CastError {
return HeapObjectToJSProxy(o) otherwise CastError;
}
Cast<JSStringIterator>(o: HeapObject): JSStringIterator
labels CastError {
return HeapObjectToJSStringIterator(o) otherwise CastError;
}
Cast<JSRegExpStringIterator>(o: HeapObject): JSRegExpStringIterator
labels CastError {
if (IsJSRegExpStringIterator(o)) {
return %RawDownCast<JSRegExpStringIterator>(o);
}
goto CastError;
}
Cast<JSTypedArray>(o: HeapObject): JSTypedArray
labels CastError {
if (IsJSTypedArray(o)) return %RawDownCast<JSTypedArray>(o);
goto CastError;
}
Cast<JSTypedArray>(implicit context: Context)(o: Object): JSTypedArray
labels CastError {
const heapObject = Cast<HeapObject>(o) otherwise CastError;
return Cast<JSTypedArray>(heapObject) otherwise CastError;
}
Cast<Callable>(o: HeapObject): Callable
labels CastError {
return HeapObjectToCallable(o) otherwise CastError;
}
Cast<Undefined|Callable>(o: HeapObject): Undefined|Callable
labels CastError {
if (o == Undefined) return Undefined;
return HeapObjectToCallable(o) otherwise CastError;
}
Cast<JSArray>(o: HeapObject): JSArray
labels CastError {
return HeapObjectToJSArray(o) otherwise CastError;
}
Cast<JSArrayBuffer>(o: HeapObject): JSArrayBuffer
labels CastError {
return HeapObjectToJSArrayBuffer(o) otherwise CastError;
}
Cast<Context>(o: HeapObject): Context
labels CastError {
if (IsContext(o)) return %RawDownCast<Context>(o);
goto CastError;
}
Cast<NativeContext>(o: HeapObject): NativeContext
labels CastError {
if (IsNativeContext(o)) return %RawDownCast<NativeContext>(o);
goto CastError;
}
Cast<JSObject>(o: HeapObject): JSObject
labels CastError {
if (IsJSObject(o)) return %RawDownCast<JSObject>(o);
goto CastError;
}
Cast<NumberDictionary>(o: HeapObject): NumberDictionary
labels CastError {
if (IsNumberDictionary(o)) return %RawDownCast<NumberDictionary>(o);
goto CastError;
}
Cast<String>(o: HeapObject): String
labels CastError {
return HeapObjectToString(o) otherwise CastError;
}
Cast<Oddball>(o: HeapObject): Oddball
labels CastError {
if (IsOddball(o)) return %RawDownCast<Oddball>(o);
goto CastError;
}
Cast<Symbol>(o: HeapObject): Symbol
labels CastError {
if (IsSymbol(o)) return %RawDownCast<Symbol>(o);
goto CastError;
}
macro Cast<T : type extends Symbol>(o: Symbol): T labels CastError;
Cast<PublicSymbol>(o: Symbol): PublicSymbol labels CastError {
if (IsPrivateSymbol(o)) goto CastError;
return %RawDownCast<PublicSymbol>(o);
}
Cast<PrivateSymbol>(o: Symbol): PrivateSymbol labels CastError {
if (IsPrivateSymbol(o)) {
return %RawDownCast<PrivateSymbol>(o);
}
goto CastError;
}
Cast<PublicSymbol>(o: HeapObject): PublicSymbol labels CastError {
const o = Cast<Symbol>(o) otherwise CastError;
return Cast<PublicSymbol>(o) otherwise CastError;
}
Cast<PrivateSymbol>(o: HeapObject): PrivateSymbol labels CastError {
const o = Cast<Symbol>(o) otherwise CastError;
return Cast<PrivateSymbol>(o) otherwise CastError;
}
Cast<DirectString>(o: HeapObject): DirectString
labels CastError {
return TaggedToDirectString(o) otherwise CastError;
}
Cast<Constructor>(o: HeapObject): Constructor
labels CastError {
return HeapObjectToConstructor(o) otherwise CastError;
}
Cast<HeapNumber>(o: HeapObject): HeapNumber
labels CastError {
if (IsHeapNumber(o)) return %RawDownCast<HeapNumber>(o);
goto CastError;
}
Cast<BigInt>(o: HeapObject): BigInt labels CastError {
if (IsBigInt(o)) return %RawDownCast<BigInt>(o);
goto CastError;
}
Cast<JSRegExp>(o: HeapObject): JSRegExp
labels CastError {
if (IsJSRegExp(o)) return %RawDownCast<JSRegExp>(o);
goto CastError;
}
Cast<FastJSRegExpResult>(implicit context: Context)(o: HeapObject):
FastJSRegExpResult
labels CastError {
if (regexp::IsFastRegExpResult(o)) return %RawDownCast<FastJSRegExpResult>(o);
goto CastError;
}
Cast<Map>(implicit context: Context)(o: HeapObject): Map
labels CastError {
if (IsMap(o)) return %RawDownCast<Map>(o);
goto CastError;
}
Cast<FeedbackVector>(implicit context: Context)(o: HeapObject): FeedbackVector
labels CastError {
if (IsFeedbackVector(o)) return %RawDownCast<FeedbackVector>(o);
goto CastError;
}
Cast<JSPrimitiveWrapper>(o: HeapObject): JSPrimitiveWrapper
labels CastError {
if (IsJSPrimitiveWrapper(o)) return %RawDownCast<JSPrimitiveWrapper>(o);
goto CastError;
}
Cast<JSArgumentsObjectWithLength>(implicit context: Context)(o: HeapObject):
JSArgumentsObjectWithLength
labels CastError {
const map: Map = o.map;
try {
if (IsFastAliasedArgumentsMap(map)) goto True;
if (IsSloppyArgumentsMap(map)) goto True;
if (IsStrictArgumentsMap(map)) goto True;
if (IsSlowAliasedArgumentsMap(map)) goto True;
goto CastError;
}
label True {
return %RawDownCast<JSArgumentsObjectWithLength>(o);
}
}
Cast<FastJSRegExp>(implicit context: Context)(o: HeapObject): FastJSRegExp
labels CastError {
// TODO(jgruber): Remove or redesign this. There is no single 'fast' regexp,
// the conditions to make a regexp object fast differ based on the callsite.
// For now, run the strict variant since replace (the only current callsite)
// accesses flag getters.
if (regexp::IsFastRegExpStrict(o)) {
return %RawDownCast<FastJSRegExp>(o);
}
goto CastError;
}
Cast<FastJSArray>(implicit context: Context)(o: HeapObject): FastJSArray
labels CastError {
if (IsForceSlowPath()) goto CastError;
const map: Map = o.map;
if (!IsJSArrayMap(map)) goto CastError;
// Bailout if receiver has slow elements.
const elementsKind: ElementsKind = LoadMapElementsKind(map);
if (!IsFastElementsKind(elementsKind)) goto CastError;
// Verify that our prototype is the initial array prototype.
if (!IsPrototypeInitialArrayPrototype(map)) goto CastError;
if (IsNoElementsProtectorCellInvalid()) goto CastError;
return %RawDownCast<FastJSArray>(o);
}
Cast<FastJSArrayForRead>(implicit context: Context)(o: HeapObject):
FastJSArrayForRead
labels CastError {
const map: Map = o.map;
if (!IsJSArrayMap(map)) goto CastError;
// Bailout if receiver has slow elements.
const elementsKind: ElementsKind = LoadMapElementsKind(map);
if (!IsElementsKindLessThanOrEqual(
elementsKind, LAST_ANY_NONEXTENSIBLE_ELEMENTS_KIND))
goto CastError;
// Verify that our prototype is the initial array prototype.
if (!IsPrototypeInitialArrayPrototype(map)) goto CastError;
if (IsNoElementsProtectorCellInvalid()) goto CastError;
return %RawDownCast<FastJSArrayForRead>(o);
}
Cast<FastJSArrayForCopy>(implicit context: Context)(o: HeapObject):
FastJSArrayForCopy
labels CastError {
if (IsArraySpeciesProtectorCellInvalid()) goto CastError;
const a = Cast<FastJSArray>(o) otherwise CastError;
return %RawDownCast<FastJSArrayForCopy>(a);
}
Cast<FastJSArrayWithNoCustomIteration>(implicit context: Context)(
o: HeapObject): FastJSArrayWithNoCustomIteration
labels CastError {
if (IsArrayIteratorProtectorCellInvalid()) goto CastError;
const a = Cast<FastJSArray>(o) otherwise CastError;
return %RawDownCast<FastJSArrayWithNoCustomIteration>(a);
}
Cast<FastJSArrayForReadWithNoCustomIteration>(implicit context: Context)(
o: HeapObject): FastJSArrayForReadWithNoCustomIteration
labels CastError {
if (IsArrayIteratorProtectorCellInvalid()) goto CastError;
const a = Cast<FastJSArrayForRead>(o) otherwise CastError;
return %RawDownCast<FastJSArrayForReadWithNoCustomIteration>(a);
}
Cast<JSReceiver>(o: HeapObject): JSReceiver
labels CastError {
if (IsJSReceiver(o)) return %RawDownCast<JSReceiver>(o);
goto CastError;
}
Cast<JSFunction>(implicit context: Context)(o: HeapObject): JSFunction
labels CastError {
if (IsJSFunction(o)) return %RawDownCast<JSFunction>(o);
goto CastError;
}
extern macro IsDebugInfo(HeapObject): bool;
Cast<DebugInfo>(implicit context: Context)(o: HeapObject): DebugInfo
labels CastError {
if (IsDebugInfo(o)) return %RawDownCast<DebugInfo>(o);
goto CastError;
}
extern macro IsCoverageInfo(HeapObject): bool;
Cast<CoverageInfo>(implicit context: Context)(o: HeapObject): CoverageInfo
labels CastError {
// TODO(jgruber): Assign an instance type.
if (IsFixedArray(o)) return %RawDownCast<CoverageInfo>(o);
goto CastError;
}
Cast<JSReceiver|Null>(o: HeapObject): JSReceiver|Null
labels CastError {
typeswitch (o) {
case (o: Null): {
return o;
}
case (o: JSReceiver): {
return o;
}
case (HeapObject): {
goto CastError;
}
}
}
Cast<PromiseFulfillReactionJobTask>(o: HeapObject):
PromiseFulfillReactionJobTask labels CastError {
if (IsPromiseFulfillReactionJobTask(o)) {
return %RawDownCast<PromiseFulfillReactionJobTask>(o);
}
goto CastError;
}
Cast<PromiseRejectReactionJobTask>(o: HeapObject):
PromiseRejectReactionJobTask labels CastError {
if (IsPromiseRejectReactionJobTask(o)) {
return %RawDownCast<PromiseRejectReactionJobTask>(o);
}
goto CastError;
}
Cast<PromiseReaction>(o: HeapObject): PromiseReaction labels CastError {
if (IsPromiseReaction(o)) return %RawDownCast<PromiseReaction>(o);
goto CastError;
}
Cast<Smi|PromiseReaction>(o: Object): Smi|PromiseReaction labels CastError {
typeswitch (o) {
case (o: Smi): {
return o;
}
case (o: PromiseReaction): {
return o;
}
case (Object): {
goto CastError;
}
}
}
Cast<String|Callable>(implicit context: Context)(o: Object): String|
Callable labels CastError {
typeswitch (o) {
case (o: String): {
return o;
}
case (o: Callable): {
return o;
}
case (Object): {
goto CastError;
}
}
}
Cast<Zero|PromiseReaction>(implicit context: Context)(o: Object): Zero|
PromiseReaction labels CastError {
typeswitch (o) {
case (o: Zero): {
return o;
}
case (o: PromiseReaction): {
return o;
}
case (Object): {
goto CastError;
}
}
}
Cast<JSBoundFunction>(o: HeapObject): JSBoundFunction labels CastError {
if (IsJSBoundFunction(o)) return %RawDownCast<JSBoundFunction>(o);
goto CastError;
}
Cast<PromiseCapability>(o: HeapObject): PromiseCapability labels CastError {
if (IsPromiseCapability(o)) return %RawDownCast<PromiseCapability>(o);
goto CastError;
}
Cast<SharedFunctionInfo>(o: HeapObject): SharedFunctionInfo labels CastError {
if (IsSharedFunctionInfo(o)) return %RawDownCast<SharedFunctionInfo>(o);
goto CastError;
}
Cast<JSPromise>(o: HeapObject): JSPromise labels CastError {
if (IsJSPromise(o)) return %RawDownCast<JSPromise>(o);
goto CastError;
}

233
src/builtins/convert.tq Normal file
View File

@ -0,0 +1,233 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
intrinsic %FromConstexpr<To: type, From: type>(b: From): To;
macro FromConstexpr<To: type, From: type>(o: From): To;
FromConstexpr<int31, constexpr int31>(i: constexpr int31): int31 {
return %FromConstexpr<int31>(i);
}
FromConstexpr<int32, constexpr int31>(i: constexpr int31): int32 {
return %FromConstexpr<int32>(i);
}
FromConstexpr<int32, constexpr int32>(i: constexpr int32): int32 {
return %FromConstexpr<int32>(i);
}
FromConstexpr<intptr, constexpr int31>(i: constexpr int31): intptr {
return %FromConstexpr<intptr>(i);
}
FromConstexpr<intptr, constexpr int32>(i: constexpr int32): intptr {
return %FromConstexpr<intptr>(i);
}
FromConstexpr<intptr, constexpr intptr>(i: constexpr intptr): intptr {
return %FromConstexpr<intptr>(i);
}
FromConstexpr<uintptr, constexpr uintptr>(i: constexpr uintptr): uintptr {
return %FromConstexpr<uintptr>(i);
}
FromConstexpr<Smi, constexpr int31>(i: constexpr int31): Smi {
return %FromConstexpr<Smi>(i);
}
FromConstexpr<PositiveSmi, constexpr int31>(i: constexpr int31): PositiveSmi {
assert(i >= 0);
return %FromConstexpr<PositiveSmi>(i);
}
FromConstexpr<String, constexpr string>(s: constexpr string): String {
return %FromConstexpr<String>(s);
}
FromConstexpr<Number, constexpr uint32>(i: constexpr uint32): Number {
return %FromConstexpr<Number>(i);
}
FromConstexpr<Number, constexpr int32>(i: constexpr int32): Number {
return %FromConstexpr<Number>(i);
}
FromConstexpr<Number, constexpr float64>(f: constexpr float64): Number {
return %FromConstexpr<Number>(f);
}
FromConstexpr<Number, constexpr int31>(i: constexpr int31): Number {
return %FromConstexpr<Number>(i);
}
FromConstexpr<Number, constexpr Smi>(s: constexpr Smi): Number {
return SmiConstant(s);
}
FromConstexpr<Smi, constexpr Smi>(s: constexpr Smi): Smi {
return SmiConstant(s);
}
FromConstexpr<uint32, constexpr int31>(i: constexpr int31): uint32 {
return Unsigned(Int32Constant(i));
}
FromConstexpr<uintptr, constexpr int31>(i: constexpr int31): uintptr {
return ChangeUint32ToWord(i);
}
FromConstexpr<float64, constexpr int31>(i: constexpr int31): float64 {
return Float64Constant(i);
}
FromConstexpr<float64, constexpr float64>(i: constexpr float64): float64 {
return Float64Constant(i);
}
FromConstexpr<bool, constexpr bool>(b: constexpr bool): bool {
return BoolConstant(b);
}
FromConstexpr<LanguageMode, constexpr LanguageMode>(m: constexpr LanguageMode):
LanguageMode {
return %RawDownCast<LanguageMode>(%FromConstexpr<Smi>(m));
}
FromConstexpr<ElementsKind, constexpr ElementsKind>(e: constexpr ElementsKind):
ElementsKind {
return Int32Constant(e);
}
FromConstexpr<Object, constexpr string>(s: constexpr string): Object {
return StringConstant(s);
}
FromConstexpr<JSAny, constexpr string>(s: constexpr string): JSAny {
return StringConstant(s);
}
FromConstexpr<NativeContextSlot, constexpr NativeContextSlot>(
c: constexpr NativeContextSlot): NativeContextSlot {
return IntPtrConstant(c);
}
FromConstexpr<ContextSlot, constexpr ContextSlot>(c: constexpr ContextSlot):
ContextSlot {
return IntPtrConstant(c);
}
FromConstexpr<PromiseState, constexpr PromiseState>(s: constexpr PromiseState):
PromiseState {
return %FromConstexpr<PromiseState>(s);
}
macro Convert<To: type, From: type>(i: From): To {
return i;
}
macro Convert<To: type, From: type>(i: From): To labels Overflow {
return i;
}
extern macro ConvertElementsKindToInt(ElementsKind): int32;
Convert<int32, ElementsKind>(elementsKind: ElementsKind): int32 {
return ConvertElementsKindToInt(elementsKind);
}
Convert<Number, int32>(i: int32): Number {
return ChangeInt32ToTagged(i);
}
Convert<intptr, int32>(i: int32): intptr {
return ChangeInt32ToIntPtr(i);
}
Convert<intptr, uint32>(i: uint32): intptr {
return Signed(ChangeUint32ToWord(i));
}
Convert<Smi, int32>(i: int32): Smi {
return SmiFromInt32(i);
}
Convert<Number, uint32>(ui: uint32): Number {
return ChangeUint32ToTagged(ui);
}
Convert<Smi, uint32>(ui: uint32): Smi {
return SmiFromUint32(ui);
}
Convert<uintptr, uint32>(ui: uint32): uintptr {
return ChangeUint32ToWord(ui);
}
Convert<int32, uint8>(i: uint8): int32 {
return Signed(Convert<uint32>(i));
}
Convert<int32, uint16>(i: uint16): int32 {
return Signed(Convert<uint32>(i));
}
Convert<int32, uint31>(i: uint31): int32 {
return Signed(Convert<uint32>(i));
}
Convert<int32, intptr>(i: intptr): int32 {
return TruncateIntPtrToInt32(i);
}
Convert<Smi, intptr>(i: intptr): Smi {
return SmiTag(i);
}
Convert<uint32, uintptr>(ui: uintptr): uint32 {
return Unsigned(TruncateIntPtrToInt32(Signed(ui)));
}
Convert<intptr, Smi>(s: Smi): intptr {
return SmiUntag(s);
}
Convert<uintptr, PositiveSmi>(ps: PositiveSmi): uintptr {
return Unsigned(SmiUntag(ps));
}
Convert<intptr, uintptr>(ui: uintptr): intptr {
const i = Signed(ui);
assert(i >= 0);
return i;
}
Convert<PositiveSmi, intptr>(i: intptr): PositiveSmi {
assert(IsValidPositiveSmi(i));
return %RawDownCast<PositiveSmi>(SmiTag(i));
}
Convert<PositiveSmi, uintptr>(ui: uintptr): PositiveSmi labels IfOverflow {
if (ui > kSmiMaxValue) deferred {
goto IfOverflow;
}
return %RawDownCast<PositiveSmi>(SmiTag(Signed(ui)));
}
Convert<PositiveSmi, intptr>(i: intptr): PositiveSmi labels IfOverflow {
if (IsValidPositiveSmi(i)) {
return %RawDownCast<PositiveSmi>(SmiTag(i));
} else
deferred {
goto IfOverflow;
}
}
Convert<int32, Smi>(s: Smi): int32 {
return SmiToInt32(s);
}
Convert<float64, HeapNumber>(h: HeapNumber): float64 {
return LoadHeapNumberValue(h);
}
Convert<float64, Number>(n: Number): float64 {
return ChangeNumberToFloat64(n);
}
Convert<uintptr, Number>(n: Number): uintptr {
return ChangeUintPtrNumberToUintPtr(n);
}
Convert<float64, float32>(f: float32): float64 {
return ChangeFloat32ToFloat64(f);
}
Convert<float32, float64>(f: float64): float32 {
return TruncateFloat64ToFloat32(f);
}
Convert<float32, Number>(n: Number): float32 {
return Convert<float32>(ChangeNumberToFloat64(n));
}
Convert<Number, float64>(d: float64): Number {
return AllocateHeapNumberWithValue(d);
}
Convert<float64, uintptr>(ui: uintptr): float64 {
return ChangeUintPtrToFloat64(ui);
}
Convert<Number, uintptr>(ui: uintptr): Number {
return ChangeUintPtrToTagged(ui);
}
Convert<uintptr, float64>(d: float64): uintptr {
return ChangeFloat64ToUintPtr(d);
}
Convert<uintptr, intptr>(i: intptr): uintptr {
return Unsigned(i);
}
Convert<uintptr, RawPtr>(r: RawPtr): uintptr {
return Unsigned(r);
}
Convert<intptr, RawPtr>(r: RawPtr): intptr {
return Signed(r);
}
Convert<bint, int32>(v: int32): bint {
return IntPtrToBInt(Convert<intptr>(v));
}
extern macro IntPtrToBInt(intptr): bint;
Convert<bint, intptr>(v: intptr): bint {
return IntPtrToBInt(v);
}
extern macro SmiToBInt(Smi): bint;
Convert<bint, Smi>(v: Smi): bint {
return SmiToBInt(v);
}
Convert<PromiseState, int32>(s: int32): PromiseState {
return %RawDownCast<PromiseState>(s);
}

View File

@ -108,3 +108,45 @@ namespace torque_internal {
}
} // namespace torque_internal
// These intrinsics should never be called from Torque code. They're used
// internally by the 'new' operator and only declared here because it's simpler
// than building the definition from C++.
intrinsic %GetAllocationBaseSize<Class : type extends HeapObject>(map: Map):
intptr;
intrinsic %Allocate<Class : type extends HeapObject>(size: intptr): Class;
intrinsic %GetStructMap(instanceKind: constexpr InstanceType): Map;
intrinsic %AddIndexedFieldSizeToObjectSize<T: type>(
baseSize: intptr, indexSize: T, fieldSize: int32): intptr {
const convertedIndexSize = Convert<int32>(indexSize);
const variableSize: int32 =
TryInt32Mul(convertedIndexSize, fieldSize) otherwise unreachable;
const convertedVariableSize = Convert<intptr>(variableSize);
return TryIntPtrAdd(baseSize, convertedVariableSize) otherwise unreachable;
}
intrinsic
%InitializeFieldsFromIterator<Container: type, Index: type, Iterator: type>(
c: Container, length: Index, i: Iterator) {
try {
let mutableIterator = i;
let current: Index = 0;
while (current < length) {
// TODO(danno): The indexed accessor on the container requires that the
// '[]=' operator be defined explicitly for the Container
// (e.g. FixedArray). We should change this to use slice references
// once they are implemented.
c[current++] = mutableIterator.Next() otherwise NoMore;
}
}
label NoMore deferred {
unreachable;
}
}
// %RawDownCast should *never* be used anywhere in Torque code except for
// in Torque-based UnsafeCast operators preceeded by an appropriate
// type assert()
intrinsic %RawDownCast<To: type, From: type>(x: From): To;
intrinsic %RawConstexprCast<To: type, From: type>(f: From): To;

View File

@ -0,0 +1,6 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class LoadHandler extends DataHandler;
extern class StoreHandler extends DataHandler;

View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class AllocationSite extends Struct;
extern class AllocationMemento extends Struct {
allocation_site: AllocationSite;
}

View File

@ -0,0 +1,41 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class CallHandlerInfo extends Struct {
callback: NonNullForeign|Undefined|Zero;
js_callback: NonNullForeign|Undefined|Zero;
data: Object;
}
@generateCppClass
extern class InterceptorInfo extends Struct {
getter: NonNullForeign|Zero|Undefined;
setter: NonNullForeign|Zero|Undefined;
query: NonNullForeign|Zero|Undefined;
descriptor: NonNullForeign|Zero|Undefined;
deleter: NonNullForeign|Zero|Undefined;
enumerator: NonNullForeign|Zero|Undefined;
definer: NonNullForeign|Zero|Undefined;
data: Object;
flags: Smi;
}
@generateCppClass
extern class AccessCheckInfo extends Struct {
callback: Foreign|Zero|Undefined;
named_interceptor: InterceptorInfo|Zero|Undefined;
indexed_interceptor: InterceptorInfo|Zero|Undefined;
data: Object;
}
extern class AccessorInfo extends Struct {
name: Object;
flags: Smi;
expected_receiver_type: Object;
setter: NonNullForeign|Zero;
getter: NonNullForeign|Zero;
js_getter: NonNullForeign|Zero;
data: Object;
}

33
src/objects/arguments.tq Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class JSArgumentsObject extends JSObject {
}
// Just a starting shape for JSObject; properties can move after initialization.
@noVerifier
@hasSameInstanceTypeAsParent
extern class JSArgumentsObjectWithLength extends JSArgumentsObject {
length: JSAny;
}
// Just a starting shape for JSObject; properties can move after initialization.
@hasSameInstanceTypeAsParent
extern class JSSloppyArgumentsObject extends JSArgumentsObjectWithLength {
callee: JSAny;
}
// Just a starting shape for JSObject; properties can move after initialization.
@hasSameInstanceTypeAsParent
@noVerifier
extern class JSStrictArgumentsObject extends JSArgumentsObjectWithLength {
}
type SloppyArgumentsElements extends FixedArray;
@generateCppClass
extern class AliasedArgumentsEntry extends Struct {
aliased_context_slot: Smi;
}

8
src/objects/cell.tq Normal file
View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class Cell extends HeapObject {
value: Object;
}

26
src/objects/code.tq Normal file
View File

@ -0,0 +1,26 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generatePrint
@generateCppClass
extern class SourcePositionTableWithFrameCache extends Struct {
source_position_table: ByteArray;
stack_frame_cache: Object;
}
type DependentCode extends WeakFixedArray;
extern class BytecodeArray extends FixedArrayBase {
// TODO(v8:8983): bytecode array object sizes vary based on their contents.
constant_pool: FixedArray;
handler_table: ByteArray;
source_position_table: Undefined|ByteArray|SourcePositionTableWithFrameCache;
frame_size: int32;
parameter_size: int32;
incoming_new_target_or_generator_register: int32;
osr_nesting_level: int8;
bytecode_age: int8;
}
extern class CodeDataContainer extends HeapObject;

65
src/objects/contexts.tq Normal file
View File

@ -0,0 +1,65 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
extern class Context extends HeapObject {
length: Smi;
scope_info: ScopeInfo;
previous: Object;
}
extern class AwaitContext extends Context generates 'TNode<Context>';
extern class BlockContext extends Context generates 'TNode<Context>';
extern class CatchContext extends Context generates 'TNode<Context>';
extern class DebugEvaluateContext extends Context
generates 'TNode<Context>';
extern class EvalContext extends Context generates 'TNode<Context>';
extern class FunctionContext extends Context generates 'TNode<Context>';
extern class ModuleContext extends Context generates 'TNode<Context>';
extern class NativeContext extends Context;
extern class ScriptContext extends Context generates 'TNode<Context>';
extern class WithContext extends Context generates 'TNode<Context>';
type NativeContextSlot generates 'TNode<IntPtrT>' constexpr 'int32_t';
const ARRAY_BUFFER_FUN_INDEX: constexpr NativeContextSlot
generates 'Context::ARRAY_BUFFER_FUN_INDEX';
const ARRAY_BUFFER_NOINIT_FUN_INDEX: constexpr NativeContextSlot
generates 'Context::ARRAY_BUFFER_NOINIT_FUN_INDEX';
const ARRAY_BUFFER_MAP_INDEX: constexpr NativeContextSlot
generates 'Context::ARRAY_BUFFER_MAP_INDEX';
const ARRAY_JOIN_STACK_INDEX: constexpr NativeContextSlot
generates 'Context::ARRAY_JOIN_STACK_INDEX';
const OBJECT_FUNCTION_INDEX: constexpr NativeContextSlot
generates 'Context::OBJECT_FUNCTION_INDEX';
const ITERATOR_RESULT_MAP_INDEX: constexpr NativeContextSlot
generates 'Context::ITERATOR_RESULT_MAP_INDEX';
const JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX: constexpr NativeContextSlot
generates 'Context::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX';
const JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX: constexpr NativeContextSlot
generates 'Context::JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX';
const PROXY_REVOCABLE_RESULT_MAP_INDEX: constexpr NativeContextSlot
generates 'Context::PROXY_REVOCABLE_RESULT_MAP_INDEX';
const REFLECT_APPLY_INDEX: constexpr NativeContextSlot
generates 'Context::REFLECT_APPLY_INDEX';
const REGEXP_FUNCTION_INDEX: constexpr NativeContextSlot
generates 'Context::REGEXP_FUNCTION_INDEX';
const REGEXP_LAST_MATCH_INFO_INDEX: constexpr NativeContextSlot
generates 'Context::REGEXP_LAST_MATCH_INFO_INDEX';
const INITIAL_STRING_ITERATOR_MAP_INDEX: constexpr NativeContextSlot
generates 'Context::INITIAL_STRING_ITERATOR_MAP_INDEX';
const SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP: constexpr NativeContextSlot
generates 'Context::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP';
extern operator '[]' macro LoadContextElement(
NativeContext, NativeContextSlot): Object;
extern operator '[]=' macro StoreContextElement(
NativeContext, NativeContextSlot, Object): void;
type ContextSlot generates 'TNode<IntPtrT>' constexpr 'int32_t';
const PROXY_SLOT: constexpr ContextSlot
generates 'Context::MIN_CONTEXT_SLOTS';
extern operator '[]' macro LoadContextElement(Context, ContextSlot): Object;
extern operator '[]=' macro StoreContextElement(
Context, ContextSlot, Object): void;
extern operator '[]' macro LoadContextElement(Context, intptr): Object;
extern operator '[]' macro LoadContextElement(Context, Smi): Object;

View File

@ -0,0 +1,14 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
extern class DataHandler extends Struct {
smi_handler: Smi|Code;
validity_cell: Smi|Cell;
// Space for the following fields may or may not be allocated.
@noVerifier data_1: MaybeObject;
@noVerifier data_2: MaybeObject;
@noVerifier data_3: MaybeObject;
}

View File

@ -0,0 +1,29 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@hasSameInstanceTypeAsParent
extern class BreakPoint extends Tuple2 {
}
@hasSameInstanceTypeAsParent
extern class BreakPointInfo extends Tuple2 {
}
type CoverageInfo extends FixedArray;
@generateCppClass
extern class DebugInfo extends Struct {
shared: SharedFunctionInfo;
debugger_hints: Smi;
// Script field from shared function info.
script: Undefined|Script;
// The original uninstrumented bytecode array for functions with break
// points - the instrumented bytecode is held in the shared function info.
original_bytecode_array: Undefined|BytecodeArray;
// The debug instrumented bytecode array for functions with break points
// - also pointed to by the shared function info.
debug_bytecode_array: Undefined|BytecodeArray;
// Fixed array holding status information for each active break point.
break_points: FixedArray;
flags: Smi;
coverage_info: CoverageInfo|Undefined;
}

View File

@ -0,0 +1,24 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generatePrint
@generateCppClass
extern class EnumCache extends Struct {
keys: FixedArray;
indices: FixedArray;
}
// We make this class abstract because it is missing the variable-sized part,
// which is still impossible to express in Torque.
@abstract
@dirtyInstantiatedAbstractClass
extern class DescriptorArray extends HeapObject {
number_of_all_descriptors: uint16;
number_of_descriptors: uint16;
raw_number_of_marked_descriptors: uint16;
filler16_bits: uint16;
enum_cache: EnumCache;
// DescriptorEntry needs to be a struct with three fields.
// desriptors : DescriptorEntry[number_of_all_descriptors]
}

View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class EmbedderDataArray extends HeapObject {
length: Smi;
}

View File

@ -0,0 +1,9 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class FeedbackCell extends Struct {
value: Undefined|FeedbackVector|FixedArray;
interrupt_budget: int32;
}

View File

@ -0,0 +1,18 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class FeedbackVector extends HeapObject {
shared_function_info: SharedFunctionInfo;
optimized_code_weak_or_smi: Weak<Code>|Smi;
closure_feedback_cell_array: FixedArray;
length: int32;
invocation_count: int32;
profiler_ticks: int32;
// TODO(v8:9287) The padding is not necessary on platforms with 4 bytes
// tagged pointers, we should make it conditional; however, platform-specific
// interacts badly with GCMole, so we need to address that first.
padding: uint32;
}
extern class FeedbackMetadata extends HeapObject;

125
src/objects/fixed-array.tq Normal file
View File

@ -0,0 +1,125 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
extern class FixedArrayBase extends HeapObject {
length: Smi;
}
@abstract
@dirtyInstantiatedAbstractClass
extern class FixedArray extends FixedArrayBase {
objects[length]: Object;
}
type EmptyFixedArray extends FixedArray;
extern class FixedDoubleArray extends FixedArrayBase {
floats[length]: float64;
}
@abstract
@dirtyInstantiatedAbstractClass
extern class WeakFixedArray extends HeapObject {
length: Smi;
}
extern class ByteArray extends FixedArrayBase {}
@hasSameInstanceTypeAsParent
extern class ArrayList extends FixedArray {
}
@hasSameInstanceTypeAsParent
@noVerifier
extern class TemplateList extends FixedArray {
}
extern class WeakArrayList extends HeapObject {
capacity: Smi;
length: Smi;
objects[length]: MaybeObject;
}
extern operator '.length_intptr' macro LoadAndUntagFixedArrayBaseLength(
FixedArrayBase): intptr;
extern operator '.objects[]' macro LoadFixedArrayElement(
FixedArray, intptr): Object;
extern operator '.objects[]' macro LoadFixedArrayElement(
FixedArray, Smi): Object;
extern operator '.objects[]' macro LoadFixedArrayElement(
FixedArray, constexpr int31): Object;
extern operator '.objects[]=' macro StoreFixedArrayElement(
FixedArray, intptr, Smi): void;
extern operator '.objects[]=' macro StoreFixedArrayElement(
FixedArray, Smi, Smi): void;
extern operator '.objects[]=' macro StoreFixedArrayElement(
FixedArray, intptr, HeapObject): void;
extern operator '.objects[]=' macro StoreFixedArrayElement(
FixedArray, intptr, Object): void;
extern operator '.objects[]=' macro StoreFixedArrayElement(
FixedArray, constexpr int31, Smi): void;
extern operator '.objects[]=' macro StoreFixedArrayElement(
FixedArray, constexpr int31, HeapObject): void;
extern operator '.objects[]=' macro StoreFixedArrayElement(
FixedArray, Smi, Object): void;
extern macro StoreFixedArrayElement(
FixedArray, Smi, Object, constexpr WriteBarrierMode): void;
extern macro StoreFixedArrayElement(
FixedArray, Smi, Smi, constexpr WriteBarrierMode): void;
extern macro StoreFixedArrayElement(
FixedArray, constexpr int31, Object, constexpr WriteBarrierMode): void;
extern macro StoreFixedArrayElement(
FixedArray, constexpr int31, Smi, constexpr WriteBarrierMode): void;
extern macro StoreFixedArrayElement(
FixedArray, intptr, Object, constexpr WriteBarrierMode): void;
extern macro StoreFixedArrayElement(
FixedArray, intptr, Smi, constexpr WriteBarrierMode): void;
extern operator '.floats[]=' macro StoreFixedDoubleArrayElement(
FixedDoubleArray, intptr, float64): void;
extern operator '.floats[]=' macro StoreFixedDoubleArrayElementSmi(
FixedDoubleArray, Smi, float64): void;
extern operator '.floats[]' macro LoadFixedDoubleArrayElement(
FixedDoubleArray, intptr): float64;
operator '[]=' macro StoreFixedDoubleArrayDirect(
a: FixedDoubleArray, i: Smi, v: Number) {
a.floats[i] = Convert<float64>(v);
}
operator '[]=' macro StoreFixedArrayDirect(a: FixedArray, i: Smi, v: Object) {
a.objects[i] = v;
}
extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, Smi): float64
labels IfHole;
extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, intptr): float64
labels IfHole;
extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, uintptr): float64
labels IfHole;
extern macro StoreFixedDoubleArrayHoleSmi(FixedDoubleArray, Smi): void;
extern macro AllocateZeroedFixedArray(intptr): FixedArray;
extern macro AllocateZeroedFixedDoubleArray(intptr): FixedDoubleArray;
extern macro CalculateNewElementsCapacity(Smi): Smi;
extern macro CalculateNewElementsCapacity(intptr): intptr;
extern macro AllocateFixedArrayWithHoles(
intptr, constexpr AllocationFlags): FixedArray;
extern macro AllocateFixedDoubleArrayWithHoles(
intptr, constexpr AllocationFlags): FixedDoubleArray;
extern macro CopyFixedArrayElements(
constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray,
intptr, intptr, intptr): void;
extern macro CopyFixedArrayElements(
constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray, Smi,
Smi, Smi): void;
extern macro ExtractFixedArray(FixedArrayBase, Smi, Smi, Smi): FixedArrayBase;
extern macro ExtractFixedArray(
FixedArrayBase, Smi, Smi, Smi,
constexpr ExtractFixedArrayFlags): FixedArrayBase;
extern macro ExtractFixedArray(
FixedArray, intptr, intptr, intptr,
constexpr ExtractFixedArrayFlags): FixedArray;

8
src/objects/foreign.tq Normal file
View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@apiExposedInstanceTypeValue(0x46)
extern class Foreign extends HeapObject {
foreign_address: RawPtr;
}

View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class FreeSpace extends HeapObject {
size: Smi;
next: FreeSpace|Uninitialized;
}

View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class HeapNumber extends PrimitiveHeapObject { value: float64; }
// The HeapNumber value NaN
type NaN extends HeapNumber;

View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
extern class HeapObject extends StrongTagged {
map: Map;
}

View File

@ -0,0 +1,23 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class JSArrayBuffer extends JSObject {
byte_length: uintptr;
backing_store: RawPtr;
}
@abstract
extern class JSArrayBufferView extends JSObject {
buffer: JSArrayBuffer;
byte_offset: uintptr;
byte_length: uintptr;
}
extern class JSTypedArray extends JSArrayBufferView {
length: uintptr;
external_pointer: RawPtr;
base_pointer: ByteArray|Smi;
}
extern class JSDataView extends JSArrayBufferView { data_pointer: RawPtr; }

301
src/objects/js-array.tq Normal file
View File

@ -0,0 +1,301 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class JSArrayIterator extends JSObject {
iterated_object: JSReceiver;
next_index: Number;
kind: Smi;
}
extern class JSArray extends JSObject {
IsEmpty(): bool {
return this.length == 0;
}
length: Number;
}
macro NewJSArray(implicit context: Context)(
map: Map, elements: FixedArrayBase): JSArray {
return new JSArray{
map,
properties_or_hash: kEmptyFixedArray,
elements,
length: elements.length
};
}
macro NewJSArray(implicit context: Context)(): JSArray {
return new JSArray{
map: GetFastPackedSmiElementsJSArrayMap(),
properties_or_hash: kEmptyFixedArray,
elements: kEmptyFixedArray,
length: 0
};
}
// A HeapObject with a JSArray map, and either fast packed elements, or fast
// holey elements when the global NoElementsProtector is not invalidated.
transient type FastJSArray extends JSArray;
// A HeapObject with a JSArray map, and either fast packed elements, or fast
// holey elements or frozen, sealed elements when the global NoElementsProtector
// is not invalidated.
transient type FastJSArrayForRead extends JSArray;
// A FastJSArray when the global ArraySpeciesProtector is not invalidated.
transient type FastJSArrayForCopy extends FastJSArray;
// A FastJSArray when the global ArrayIteratorProtector is not invalidated.
transient type FastJSArrayWithNoCustomIteration extends FastJSArray;
// A FastJSArrayForRead when the global ArrayIteratorProtector is not
// invalidated.
transient type FastJSArrayForReadWithNoCustomIteration extends
FastJSArrayForRead;
extern macro AllocateJSArray(
constexpr ElementsKind, Map, intptr, Smi,
constexpr AllocationFlags): JSArray;
extern macro AllocateJSArray(constexpr ElementsKind, Map, intptr, Smi): JSArray;
extern macro AllocateJSArray(constexpr ElementsKind, Map, Smi, Smi): JSArray;
extern macro AllocateJSArray(Map, FixedArrayBase, Smi): JSArray;
macro LoadElementNoHole<T : type extends FixedArrayBase>(
a: JSArray, index: Smi): JSAny
labels IfHole;
LoadElementNoHole<FixedArray>(implicit context: Context)(
a: JSArray, index: Smi): JSAny
labels IfHole {
try {
const elements: FixedArray =
Cast<FixedArray>(a.elements) otherwise Unexpected;
const e = UnsafeCast<(JSAny | TheHole)>(elements.objects[index]);
typeswitch (e) {
case (TheHole): {
goto IfHole;
}
case (e: JSAny): {
return e;
}
}
}
label Unexpected {
unreachable;
}
}
LoadElementNoHole<FixedDoubleArray>(implicit context: Context)(
a: JSArray, index: Smi): JSAny
labels IfHole {
try {
const elements: FixedDoubleArray =
Cast<FixedDoubleArray>(a.elements) otherwise Unexpected;
const e: float64 =
LoadDoubleWithHoleCheck(elements, index) otherwise IfHole;
return AllocateHeapNumberWithValue(e);
}
label Unexpected {
unreachable;
}
}
extern builtin ExtractFastJSArray(Context, JSArray, Smi, Smi): JSArray;
extern macro MoveElements(
constexpr ElementsKind, FixedArrayBase, intptr, intptr, intptr): void;
macro TorqueMoveElementsSmi(
elements: FixedArray, dstIndex: intptr, srcIndex: intptr,
count: intptr): void {
MoveElements(HOLEY_SMI_ELEMENTS, elements, dstIndex, srcIndex, count);
}
macro TorqueMoveElements(
elements: FixedArray, dstIndex: intptr, srcIndex: intptr,
count: intptr): void {
MoveElements(HOLEY_ELEMENTS, elements, dstIndex, srcIndex, count);
}
macro TorqueMoveElements(
elements: FixedDoubleArray, dstIndex: intptr, srcIndex: intptr,
count: intptr): void {
MoveElements(HOLEY_DOUBLE_ELEMENTS, elements, dstIndex, srcIndex, count);
}
extern macro CopyElements(
constexpr ElementsKind, FixedArrayBase, intptr, FixedArrayBase, intptr,
intptr): void;
macro TorqueCopyElements(
dstElements: FixedArray, dstIndex: intptr, srcElements: FixedArray,
srcIndex: intptr, count: intptr): void {
CopyElements(
HOLEY_ELEMENTS, dstElements, dstIndex, srcElements, srcIndex, count);
}
macro TorqueCopyElements(
dstElements: FixedDoubleArray, dstIndex: intptr,
srcElements: FixedDoubleArray, srcIndex: intptr, count: intptr): void {
CopyElements(
HOLEY_DOUBLE_ELEMENTS, dstElements, dstIndex, srcElements, srcIndex,
count);
}
extern builtin CloneFastJSArray(Context, FastJSArrayForCopy): JSArray;
struct FastJSArrayWitness {
Get(): FastJSArray {
return this.unstable;
}
Recheck() labels CastError {
if (this.stable.map != this.map) goto CastError;
// We don't need to check elements kind or whether the prototype
// has changed away from the default JSArray prototype, because
// if the map remains the same then those properties hold.
//
// However, we have to make sure there are no elements in the
// prototype chain.
if (IsNoElementsProtectorCellInvalid()) goto CastError;
this.unstable = %RawDownCast<FastJSArray>(this.stable);
}
LoadElementNoHole(implicit context: Context)(k: Smi): JSAny
labels FoundHole {
if (this.hasDoubles) {
return LoadElementNoHole<FixedDoubleArray>(this.unstable, k)
otherwise FoundHole;
} else {
return LoadElementNoHole<FixedArray>(this.unstable, k)
otherwise FoundHole;
}
}
StoreHole(k: Smi) {
if (this.hasDoubles) {
const elements = Cast<FixedDoubleArray>(this.unstable.elements)
otherwise unreachable;
StoreFixedDoubleArrayHoleSmi(elements, k);
} else {
const elements = Cast<FixedArray>(this.unstable.elements)
otherwise unreachable;
StoreFixedArrayElement(elements, k, TheHole);
}
}
LoadElementOrUndefined(implicit context: Context)(k: Smi): JSAny {
try {
return this.LoadElementNoHole(k) otherwise FoundHole;
}
label FoundHole {
return Undefined;
}
}
EnsureArrayPushable(implicit context: Context)() labels Failed {
EnsureArrayPushable(this.map) otherwise Failed;
array::EnsureWriteableFastElements(this.unstable);
this.arrayIsPushable = true;
}
ChangeLength(newLength: Smi) {
assert(this.arrayIsPushable);
this.unstable.length = newLength;
}
Push(value: JSAny) labels Failed {
assert(this.arrayIsPushable);
if (this.hasDoubles) {
BuildAppendJSArray(HOLEY_DOUBLE_ELEMENTS, this.unstable, value)
otherwise Failed;
} else if (this.hasSmis) {
BuildAppendJSArray(HOLEY_SMI_ELEMENTS, this.unstable, value)
otherwise Failed;
} else {
assert(
this.map.elements_kind == HOLEY_ELEMENTS ||
this.map.elements_kind == PACKED_ELEMENTS);
BuildAppendJSArray(HOLEY_ELEMENTS, this.unstable, value)
otherwise Failed;
}
}
MoveElements(dst: intptr, src: intptr, length: intptr) {
assert(this.arrayIsPushable);
if (this.hasDoubles) {
const elements: FixedDoubleArray =
Cast<FixedDoubleArray>(this.unstable.elements)
otherwise unreachable;
TorqueMoveElements(elements, dst, src, length);
} else {
const elements: FixedArray = Cast<FixedArray>(this.unstable.elements)
otherwise unreachable;
if (this.hasSmis) {
TorqueMoveElementsSmi(elements, dst, src, length);
} else {
TorqueMoveElements(elements, dst, src, length);
}
}
}
const stable: JSArray;
unstable: FastJSArray;
const map: Map;
const hasDoubles: bool;
const hasSmis: bool;
arrayIsPushable: bool;
}
macro NewFastJSArrayWitness(array: FastJSArray): FastJSArrayWitness {
const kind = array.map.elements_kind;
return FastJSArrayWitness{
stable: array,
unstable: array,
map: array.map,
hasDoubles: IsDoubleElementsKind(kind),
hasSmis: IsElementsKindLessThanOrEqual(kind, HOLEY_SMI_ELEMENTS),
arrayIsPushable: false
};
}
struct FastJSArrayForReadWitness {
Get(): FastJSArrayForRead {
return this.unstable;
}
Recheck() labels CastError {
if (this.stable.map != this.map) goto CastError;
// We don't need to check elements kind or whether the prototype
// has changed away from the default JSArray prototype, because
// if the map remains the same then those properties hold.
//
// However, we have to make sure there are no elements in the
// prototype chain.
if (IsNoElementsProtectorCellInvalid()) goto CastError;
this.unstable = %RawDownCast<FastJSArrayForRead>(this.stable);
}
LoadElementNoHole(implicit context: Context)(k: Smi): JSAny
labels FoundHole {
if (this.hasDoubles) {
return LoadElementNoHole<FixedDoubleArray>(this.unstable, k)
otherwise FoundHole;
} else {
return LoadElementNoHole<FixedArray>(this.unstable, k)
otherwise FoundHole;
}
}
const stable: JSArray;
unstable: FastJSArrayForRead;
const map: Map;
const hasDoubles: bool;
}
macro NewFastJSArrayForReadWitness(array: FastJSArrayForRead):
FastJSArrayForReadWitness {
const kind = array.map.elements_kind;
return FastJSArrayForReadWitness{
stable: array,
unstable: array,
map: array.map,
hasDoubles: IsDoubleElementsKind(kind)
};
}

View File

@ -0,0 +1,12 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
@abstract
extern class JSCollectionIterator extends JSObject {
// The backing hash table mapping keys to values.
table: Object;
// The index into the data table.
index: Object;
}

View File

@ -0,0 +1,43 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
@generateCppClass
extern class JSCollection extends JSObject {
// The backing hash table.
table: Object;
}
@generateCppClass
extern class JSSet extends JSCollection {
}
@generateCppClass
extern class JSMap extends JSCollection {
}
@abstract
@generateCppClass
extern class JSWeakCollection extends JSObject {
// The backing hash table mapping keys to values.
table: Object;
}
@generateCppClass
extern class JSWeakSet extends JSWeakCollection {
}
@generateCppClass
extern class JSWeakMap extends JSWeakCollection {
}
@abstract extern class JSMapIterator extends JSCollectionIterator;
extern class JSMapKeyIterator extends JSMapIterator
generates 'TNode<JSMapIterator>';
extern class JSMapKeyValueIterator extends JSMapIterator
generates 'TNode<JSMapIterator>';
extern class JSMapValueIterator extends JSMapIterator
generates 'TNode<JSMapIterator>';
@abstract extern class JSSetIterator extends JSCollectionIterator;
extern class JSSetKeyValueIterator extends JSSetIterator
generates 'TNode<JSSetIterator>';
extern class JSSetValueIterator extends JSSetIterator
generates 'TNode<JSSetIterator>';

View File

@ -0,0 +1,45 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
@dirtyInstantiatedAbstractClass
@generateCppClass
extern class JSGeneratorObject extends JSObject {
function: JSFunction;
context: Context;
receiver: JSAny;
// For executing generators: the most recent input value.
// For suspended generators: debug information (bytecode offset).
// There is currently no need to remember the most recent input value for a
// suspended generator.
input_or_debug_pos: Object;
resume_mode: Smi;
continuation: Smi;
// Saved interpreter register file.
parameters_and_registers: FixedArray;
}
@generateCppClass
extern class JSAsyncFunctionObject extends JSGeneratorObject {
promise: JSPromise;
}
@generateCppClass
extern class JSAsyncGeneratorObject extends JSGeneratorObject {
// Pointer to the head of a singly linked list of AsyncGeneratorRequest, or
// undefined.
queue: HeapObject;
is_awaiting: Smi;
}
@generateCppClass
extern class AsyncGeneratorRequest extends Struct {
next: AsyncGeneratorRequest|Undefined;
resume_mode: Smi;
value: Object;
promise: JSPromise;
}

199
src/objects/js-objects.tq Normal file
View File

@ -0,0 +1,199 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// JSReceiver corresponds to objects in the JS sense.
@abstract
@highestInstanceTypeWithinParentClassRange
extern class JSReceiver extends HeapObject {
properties_or_hash: FixedArrayBase|PropertyArray|Smi;
}
type Constructor extends JSReceiver;
@abstract
@dirtyInstantiatedAbstractClass
@generateCppClass
@apiExposedInstanceTypeValue(0x421)
@highestInstanceTypeWithinParentClassRange
extern class JSObject extends JSReceiver {
// [elements]: The elements (properties with names that are integers).
//
// Elements can be in two general modes: fast and slow. Each mode
// corresponds to a set of object representations of elements that
// have something in common.
//
// In the fast mode elements is a FixedArray and so each element can be
// quickly accessed. The elements array can have one of several maps in this
// mode: fixed_array_map, fixed_double_array_map,
// sloppy_arguments_elements_map or fixed_cow_array_map (for copy-on-write
// arrays). In the latter case the elements array may be shared by a few
// objects and so before writing to any element the array must be copied. Use
// EnsureWritableFastElements in this case.
//
// In the slow mode the elements is either a NumberDictionary or a
// FixedArray parameter map for a (sloppy) arguments object.
elements: FixedArrayBase;
}
macro NewJSObject(implicit context: Context)(): JSObject {
const objectFunction: JSFunction = GetObjectFunction();
const map: Map = Cast<Map>(objectFunction.prototype_or_initial_map)
otherwise unreachable;
return new JSObject{
map,
properties_or_hash: kEmptyFixedArray,
elements: kEmptyFixedArray
};
}
@abstract
@generateCppClass
@lowestInstanceTypeWithinParentClassRange
extern class JSCustomElementsObject extends JSObject {
}
@abstract
@generateCppClass
@lowestInstanceTypeWithinParentClassRange
extern class JSSpecialObject extends JSCustomElementsObject {
}
@highestInstanceTypeWithinParentClassRange
extern class JSFunction extends JSFunctionOrBoundFunction {
shared_function_info: SharedFunctionInfo;
context: Context;
feedback_cell: FeedbackCell;
weak code: Code;
// Space for the following field may or may not be allocated.
@noVerifier weak prototype_or_initial_map: JSReceiver|Map;
}
extern macro HasPrototypeSlot(JSFunction): bool;
macro GetDerivedMap(implicit context: Context)(
target: JSFunction, newTarget: JSReceiver): Map {
try {
const constructor = Cast<JSFunction>(newTarget) otherwise SlowPath;
if (!HasPrototypeSlot(constructor)) {
goto SlowPath;
}
assert(IsConstructor(constructor));
const map =
Cast<Map>(constructor.prototype_or_initial_map) otherwise SlowPath;
if (LoadConstructorOrBackPointer(map) != target) {
goto SlowPath;
}
return map;
}
label SlowPath {
return runtime::GetDerivedMap(context, target, newTarget);
}
}
macro AllocateFastOrSlowJSObjectFromMap(implicit context: Context)(map: Map):
JSObject {
let properties: EmptyFixedArray|NameDictionary = kEmptyFixedArray;
if (IsDictionaryMap(map)) {
properties = AllocateNameDictionary(kNameDictionaryInitialCapacity);
}
return AllocateJSObjectFromMap(
map, properties, kEmptyFixedArray, kNone, kWithSlackTracking);
}
@generateCppClass
extern class JSGlobalProxy extends JSSpecialObject {
// [native_context]: the owner native context of this global proxy object.
// It is null value if this object is not used by any context.
native_context: Object;
}
extern class JSGlobalObject extends JSSpecialObject {
native_context: NativeContext;
global_proxy: JSGlobalProxy;
}
@generateCppClass
extern class JSPrimitiveWrapper extends JSCustomElementsObject {
value: JSAny;
}
extern class JSMessageObject extends JSObject {
// Tagged fields.
message_type: Smi;
arguments: Object;
script: Script;
stack_frames: Object;
shared_info: SharedFunctionInfo|Undefined;
// Raw data fields.
// TODO(ishell): store as int32 instead of Smi.
bytecode_offset: Smi;
start_position: Smi;
end_position: Smi;
error_level: Smi;
}
@abstract
@generateCppClass
@highestInstanceTypeWithinParentClassRange
extern class JSFunctionOrBoundFunction extends JSObject {
}
@generateCppClass
extern class JSBoundFunction extends JSFunctionOrBoundFunction {
// The wrapped function object.
bound_target_function: Callable;
// The value that is always passed as the this value when calling the wrapped
// function.
bound_this: JSAny|SourceTextModule;
// A list of values whose elements are used as the first arguments to any call
// to the wrapped function.
bound_arguments: FixedArray;
}
@generateCppClass
extern class JSDate extends JSObject {
// If one component is NaN, all of them are, indicating a NaN time value.
// The time value.
value: NumberOrUndefined;
// Cached values:
year: Undefined|Smi|NaN;
month: Undefined|Smi|NaN;
day: Undefined|Smi|NaN;
weekday: Undefined|Smi|NaN;
hour: Undefined|Smi|NaN;
min: Undefined|Smi|NaN;
sec: Undefined|Smi|NaN;
// Sample of the date cache stamp at the moment when chached fields were
// cached.
cache_stamp: Undefined|Smi|NaN;
}
@generateCppClass
extern class JSAsyncFromSyncIterator extends JSObject {
sync_iterator: JSReceiver;
// The "next" method is loaded during GetIterator, and is not reloaded for
// subsequent "next" invocations.
next: Object;
}
@generateCppClass
extern class JSStringIterator extends JSObject {
// The [[IteratedString]] inobject property.
string: String;
// The [[StringIteratorNextIndex]] inobject property.
index: Smi;
}
extern macro AllocateJSObjectFromMap(Map): JSObject;
extern macro AllocateJSObjectFromMap(
Map, NameDictionary | EmptyFixedArray | PropertyArray): JSObject;
extern macro AllocateJSObjectFromMap(
Map, NameDictionary | EmptyFixedArray | PropertyArray, FixedArray,
constexpr AllocationFlags, constexpr SlackTrackingMode): JSObject;

37
src/objects/js-promise.tq Normal file
View File

@ -0,0 +1,37 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// JSPromise constants
const kJSPromiseStatusMask: constexpr int31
generates 'JSPromise::kStatusMask';
const kJSPromiseStatusShift: constexpr int31
generates 'JSPromise::kStatusShift';
const kJSPromiseHasHandlerMask: constexpr int31
generates 'JSPromise::kHasHandlerMask';
@generateCppClass
extern class JSPromise extends JSObject {
Status(): PromiseState {
StaticAssert(kJSPromiseStatusShift == 0);
const status: int32 = Convert<int32>(this.flags) & kJSPromiseStatusMask;
return Convert<PromiseState>(status);
}
SetStatus(status: constexpr PromiseState): void {
assert(this.Status() == kPromisePending);
assert(status != kPromisePending);
const mask: Smi = SmiConstant(status);
this.flags = this.flags | mask;
}
HasHandler(): bool {
return (this.flags & kJSPromiseHasHandlerMask) != 0;
}
// Smi 0 terminated list of PromiseReaction objects in case the JSPromise was
// not settled yet, otherwise the result.
reactions_or_result: Zero|PromiseReaction|JSAny;
flags: Smi;
}

28
src/objects/js-proxy.tq Normal file
View File

@ -0,0 +1,28 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class JSProxy extends JSReceiver {
target: JSReceiver|Null;
handler: JSReceiver|Null;
}
// Just a starting shape for JSObject; properties can move after initialization.
@noVerifier
@hasSameInstanceTypeAsParent
extern class JSProxyRevocableResult extends JSObject {
proxy: JSAny;
revoke: JSAny;
}
macro NewJSProxyRevocableResult(implicit context: Context)(
proxy: JSProxy, revoke: JSFunction): JSProxyRevocableResult {
return new JSProxyRevocableResult{
map: GetProxyRevocableResultMap(),
properties_or_hash: kEmptyFixedArray,
elements: kEmptyFixedArray,
proxy,
revoke
};
}

View File

@ -0,0 +1,12 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class JSRegExpStringIterator extends JSObject {
// The [[IteratingRegExp]] internal property.
iterating_reg_exp: JSReceiver;
// The [[IteratedString]] internal property.
iterated_string: String;
flags: Smi;
}

47
src/objects/js-regexp.tq Normal file
View File

@ -0,0 +1,47 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class JSRegExp extends JSObject {
data: FixedArray|Undefined;
source: String|Undefined;
flags: Smi|Undefined;
}
// Note: Although a condition for a FastJSRegExp is having a positive smi
// lastIndex (see RegExpBuiltinsAssembler::BranchIfFastRegExp), it is possible
// for this to change without transitioning the transient type. As a precaution,
// validate the lastIndex is positive smi when used in fast paths.
transient type FastJSRegExp extends JSRegExp;
extern operator '.global' macro
RegExpBuiltinsAssembler::FastFlagGetterGlobal(FastJSRegExp): bool;
extern operator '.unicode' macro
RegExpBuiltinsAssembler::FastFlagGetterUnicode(FastJSRegExp): bool;
extern operator '.lastIndex' macro
RegExpBuiltinsAssembler::FastLoadLastIndex(FastJSRegExp): Smi;
extern operator '.lastIndex=' macro
RegExpBuiltinsAssembler::FastStoreLastIndex(FastJSRegExp, Smi): void;
@hasSameInstanceTypeAsParent
extern class JSRegExpResult extends JSArray {
// In-object properties:
// The below fields are externally exposed.
index: JSAny;
input: JSAny;
groups: JSAny;
// The below fields are for internal use only.
cached_indices_or_match_info: JSRegExpResultIndices|RegExpMatchInfo;
names: FixedArray|Undefined;
}
@hasSameInstanceTypeAsParent
extern class JSRegExpResultIndices extends JSArray {
// In-object properties:
// The groups field is externally exposed.
groups: JSAny;
}
transient type FastJSRegExpResult extends JSRegExpResult;

View File

@ -0,0 +1,43 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class JSFinalizationGroup extends JSObject {
native_context: NativeContext;
cleanup: Object;
active_cells: Undefined|WeakCell;
cleared_cells: Undefined|WeakCell;
key_map: Object;
next: Undefined|JSFinalizationGroup;
flags: Smi;
}
@generateCppClass
extern class JSFinalizationGroupCleanupIterator extends JSObject {
finalization_group: JSFinalizationGroup;
}
@generateCppClass
extern class WeakCell extends HeapObject {
finalization_group: Undefined|JSFinalizationGroup;
target: Undefined|JSReceiver;
holdings: Object;
// For storing doubly linked lists of WeakCells in JSFinalizationGroup's
// "active_cells" and "cleared_cells" lists.
prev: Undefined|WeakCell;
next: Undefined|WeakCell;
// For storing doubly linked lists of WeakCells per key in
// JSFinalizationGroup's key-based hashmap. WeakCell also needs to know its
// key, so that we can remove the key from the key_map when we remove the last
// WeakCell associated with it.
key: Object;
key_list_prev: Undefined|WeakCell;
key_list_next: Undefined|WeakCell;
}
@generateCppClass
extern class JSWeakRef extends JSObject {
target: Undefined|JSReceiver;
}

View File

@ -0,0 +1,9 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class ArrayBoilerplateDescription extends Struct {
flags: Smi;
constant_elements: FixedArrayBase;
}

49
src/objects/map.tq Normal file
View File

@ -0,0 +1,49 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class Map extends HeapObject {
PrototypeInfo(): PrototypeInfo labels HasNoPrototypeInfo {
typeswitch (this.transitions_or_prototype_info) {
case (Weak<Map>): {
goto HasNoPrototypeInfo;
}
case (Smi): {
goto HasNoPrototypeInfo;
}
case (info: PrototypeInfo): {
return info;
}
case (Map | TransitionArray): {
goto HasNoPrototypeInfo;
}
}
}
instance_size_in_words: uint8;
in_object_properties_start_or_constructor_function_index: uint8;
used_or_unused_instance_size_in_words: uint8;
visitor_id: uint8;
instance_type: InstanceType;
bit_field: uint8;
bit_field2: uint8;
bit_field3: uint32;
@if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
@ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void;
prototype: JSReceiver|Null;
constructor_or_back_pointer_or_native_context: Object;
instance_descriptors: DescriptorArray;
@if(V8_DOUBLE_FIELDS_UNBOXING) layout_descriptor: LayoutDescriptor;
@ifnot(V8_DOUBLE_FIELDS_UNBOXING) layout_descriptor: void;
dependent_code: DependentCode;
prototype_validity_cell: Smi|Cell;
weak transitions_or_prototype_info: Map|Weak<Map>|TransitionArray|
PrototypeInfo|Smi;
}
@export
macro LoadMapPrototypeInfo(m: Map): PrototypeInfo labels HasNoPrototypeInfo {
return m.PrototypeInfo() otherwise HasNoPrototypeInfo;
}

20
src/objects/microtask.tq Normal file
View File

@ -0,0 +1,20 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
@generateCppClass
extern class Microtask extends Struct {
}
@generateCppClass
extern class CallbackTask extends Microtask {
callback: Foreign;
data: Foreign;
}
@generateCppClass
extern class CallableTask extends Microtask {
callable: JSReceiver;
context: Context;
}

19
src/objects/module.tq Normal file
View File

@ -0,0 +1,19 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
extern class Module extends HeapObject {
exports: ObjectHashTable;
hash: Smi;
status: Smi;
module_namespace: JSModuleNamespace|Undefined;
exception: Object;
}
@abstract
@generateCppClass
@dirtyInstantiatedAbstractClass
extern class JSModuleNamespace extends JSSpecialObject {
module: Module;
}

21
src/objects/name.tq Normal file
View File

@ -0,0 +1,21 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
@generateCppClass
extern class Name extends PrimitiveHeapObject {
hash_field: uint32;
}
// This is the same as Name, but with the information that there are no other
// kinds of names.
type AnyName = PrivateSymbol|PublicSymbol|String;
@generateCppClass
extern class Symbol extends Name {
flags: int32;
description: String|Undefined;
}
type PublicSymbol extends Symbol;
type PrivateSymbol extends Symbol;

14
src/objects/oddball.tq Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
@apiExposedInstanceTypeValue(0x43)
@highestInstanceTypeWithinParentClassRange
extern class Oddball extends PrimitiveHeapObject {
to_number_raw: float64;
to_string: String;
to_number: Number;
type_of: String;
kind: Smi;
}

View File

@ -0,0 +1,10 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
extern class SmallOrderedHashTable extends HeapObject
generates 'TNode<HeapObject>';
extern class SmallOrderedHashMap extends SmallOrderedHashTable;
extern class SmallOrderedHashSet extends SmallOrderedHashTable;
extern class SmallOrderedNameDictionary extends SmallOrderedHashTable;

View File

@ -0,0 +1,8 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
@abstract
extern class PrimitiveHeapObject extends HeapObject {
}

68
src/objects/promise.tq Normal file
View File

@ -0,0 +1,68 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class PromiseCapability extends Struct {
promise: JSReceiver|Undefined;
resolve: Object;
reject: Object;
}
// PromiseReaction constants
type PromiseReactionType extends int31 constexpr 'PromiseReaction::Type';
const kPromiseReactionFulfill: constexpr PromiseReactionType
generates 'PromiseReaction::kFulfill';
const kPromiseReactionReject: constexpr PromiseReactionType
generates 'PromiseReaction::kReject';
const kPromiseReactionSize:
constexpr int31 generates 'PromiseReaction::kSize';
const kPromiseReactionFulfillHandlerOffset: constexpr int31
generates 'PromiseReaction::kFulfillHandlerOffset';
const kPromiseReactionPromiseOrCapabilityOffset: constexpr int31
generates 'PromiseReaction::kPromiseOrCapabilityOffset';
@generateCppClass
extern class PromiseReaction extends Struct {
next: PromiseReaction|Zero;
reject_handler: Callable|Undefined;
fulfill_handler: Callable|Undefined;
// Either a JSPromise (in case of native promises), a PromiseCapability
// (general case), or undefined (in case of await).
promise_or_capability: JSPromise|PromiseCapability|Undefined;
}
// PromiseReactionJobTask constants
const kPromiseReactionJobTaskSizeOfAllPromiseReactionJobTasks: constexpr int31
generates 'PromiseReactionJobTask::kSizeOfAllPromiseReactionJobTasks';
const kPromiseReactionJobTaskHandlerOffset: constexpr int31
generates 'PromiseReactionJobTask::kHandlerOffset';
const kPromiseReactionJobTaskPromiseOrCapabilityOffset: constexpr int31
generates 'PromiseReactionJobTask::kPromiseOrCapabilityOffset';
@abstract
@generateCppClass
extern class PromiseReactionJobTask extends Microtask {
argument: Object;
context: Context;
handler: Callable|Undefined;
// Either a JSPromise (in case of native promises), a PromiseCapability
// (general case), or undefined (in case of await).
promise_or_capability: JSPromise|PromiseCapability|Undefined;
}
@generateCppClass
extern class PromiseFulfillReactionJobTask extends PromiseReactionJobTask {
}
@generateCppClass
extern class PromiseRejectReactionJobTask extends PromiseReactionJobTask {
}
@generateCppClass
extern class PromiseResolveThenableJobTask extends Microtask {
context: Context;
promise_to_resolve: JSPromise;
then: JSReceiver;
thenable: JSReceiver;
}

View File

@ -0,0 +1,5 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class PropertyArray extends HeapObject { length_and_hash: Smi; }

View File

@ -0,0 +1,10 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class PropertyCell extends HeapObject {
name: AnyName;
property_details_raw: Smi;
value: Object;
dependent_code: DependentCode;
}

View File

@ -0,0 +1,20 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class PrototypeInfo extends Struct {
js_module_namespace: JSModuleNamespace|Undefined;
prototype_users: WeakArrayList|Zero;
registry_slot: Smi;
validity_cell: Object;
object_create_map: Weak<Map>|Undefined;
bit_field: Smi;
}
extern macro PrototypeInfoMapConstant(): Map;
const kPrototypeInfoMap: Map = PrototypeInfoMapConstant();
Cast<PrototypeInfo>(o: HeapObject): PrototypeInfo labels CastError {
if (o.map != kPrototypeInfoMap) goto CastError;
return %RawDownCast<PrototypeInfo>(o);
}

View File

@ -0,0 +1,29 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@hasSameInstanceTypeAsParent
extern class RegExpMatchInfo extends FixedArray {
GetStartOfCapture(implicit context: Context)(captureIndex: constexpr int31):
Smi {
const index: constexpr int31 = GetStartOfCaptureIndex(captureIndex);
return UnsafeCast<Smi>(this.objects[index]);
}
GetEndOfCapture(implicit context: Context)(captureIndex: constexpr int31):
Smi {
const index: constexpr int31 = GetStartOfCaptureIndex(captureIndex) + 1;
return UnsafeCast<Smi>(this.objects[index]);
}
NumberOfCaptures(implicit context: Context)(): Smi {
return UnsafeCast<Smi>(this.objects[kRegExpMatchInfoNumberOfCapturesIndex]);
}
}
const kRegExpMatchInfoFirstCaptureIndex:
constexpr int31 generates 'RegExpMatchInfo::kFirstCaptureIndex';
const kRegExpMatchInfoNumberOfCapturesIndex:
constexpr int31 generates 'RegExpMatchInfo::kNumberOfCapturesIndex';
macro GetStartOfCaptureIndex(captureIndex: constexpr int31): constexpr int31 {
return kRegExpMatchInfoFirstCaptureIndex + (captureIndex * 2);
}

21
src/objects/script.tq Normal file
View File

@ -0,0 +1,21 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class Script extends Struct {
source: Object;
name: Object;
line_offset: Smi;
column_offset: Smi;
context: Object;
script_type: Smi;
line_ends: Object;
id: Smi;
eval_from_shared_or_wrapped_arguments: Object;
eval_from_position: Smi|Foreign; // Smi or Managed<wasm::NativeModule>
shared_function_infos: Object;
flags: Smi;
source_url: Object;
source_mapping_url: Object;
host_defined_options: Object;
}

View File

@ -0,0 +1,47 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class PreparseData extends HeapObject {
// TODO(v8:8983): Add declaration for variable-sized region.
data_length: int32;
children_length: int32;
}
extern class InterpreterData extends Struct {
bytecode_array: BytecodeArray;
interpreter_trampoline: Code;
}
extern class SharedFunctionInfo extends HeapObject {
weak function_data: Object;
name_or_scope_info: String|NoSharedNameSentinel|ScopeInfo;
outer_scope_info_or_feedback_metadata: HeapObject;
script_or_debug_info: Script|DebugInfo|Undefined;
length: int16;
formal_parameter_count: uint16;
// Currently set to uint16, can be set to uint8 to save space.
expected_nof_properties: uint16;
function_token_offset: int16;
flags: int32;
function_literal_id: int32;
@if(V8_SFI_HAS_UNIQUE_ID) unique_id: int32;
}
@abstract
@generateCppClass
extern class UncompiledData extends HeapObject {
inferred_name: String;
start_position: int32;
end_position: int32;
}
@generateCppClass
extern class UncompiledDataWithoutPreparseData extends UncompiledData {
}
@generateCppClass
extern class UncompiledDataWithPreparseData extends UncompiledData {
preparse_data: PreparseData;
}

View File

@ -0,0 +1,48 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
type SourceTextModuleInfo extends FixedArray;
@generateCppClass
extern class SourceTextModule extends Module {
// The code representing this module, or an abstraction thereof.
code: SharedFunctionInfo|JSFunction|JSGeneratorObject|SourceTextModuleInfo;
// Arrays of cells corresponding to regular exports and regular imports.
// A cell's position in the array is determined by the cell index of the
// associated module entry (which coincides with the variable index of the
// associated variable).
regular_exports: FixedArray;
regular_imports: FixedArray;
// Modules imported or re-exported by this module.
// Corresponds 1-to-1 to the module specifier strings in
// SourceTextModuleInfo::module_requests.
requested_modules: FixedArray;
// Script from which the module originates.
script: Script;
// The value of import.meta inside of this module.
// Lazily initialized on first access. It's the hole before first access and
// a JSObject afterwards.
import_meta: TheHole|JSObject;
async_parent_modules: ArrayList;
top_level_capability: JSPromise|Undefined;
dfs_index: Smi;
dfs_ancestor_index: Smi;
pending_async_dependencies: Smi;
flags: Smi;
}
@generateCppClass
extern class SourceTextModuleInfoEntry extends Struct {
export_name: String|Undefined;
local_name: String|Undefined;
import_name: String|Undefined;
module_request: Smi;
cell_index: Smi;
beg_pos: Smi;
end_pos: Smi;
}

View File

@ -0,0 +1,28 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class StackFrameInfo extends Struct {
line_number: Smi;
column_number: Smi;
promise_all_index: Smi;
script_id: Smi;
wasm_function_index: Smi;
script_name: String|Null|Undefined;
script_name_or_source_url: String|Null|Undefined;
function_name: String|Null|Undefined;
method_name: String|Null|Undefined;
type_name: String|Null|Undefined;
eval_origin: String|Null|Undefined;
wasm_module_name: String|Null|Undefined;
wasm_instance: WasmInstanceObject|Null|Undefined;
flag: Smi;
}
@generateCppClass
extern class StackTraceFrame extends Struct {
frame_array: FrameArray|Undefined;
frame_index: Smi;
frame_info: StackFrameInfo|Undefined;
id: Smi;
}

58
src/objects/string.tq Normal file
View File

@ -0,0 +1,58 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
@generateCppClass
@reserveBitsInInstanceType(6)
extern class String extends Name {
length: int32;
}
@generateCppClass
extern class ConsString extends String {
first: String;
second: String;
}
@abstract
extern class ExternalString extends String {
resource: RawPtr;
resource_data: RawPtr;
}
extern class ExternalOneByteString extends ExternalString {}
extern class ExternalTwoByteString extends ExternalString {}
@generateCppClass
extern class InternalizedString extends String {
}
// TODO(v8:8983): Add declaration for variable-sized region.
@abstract
@generateCppClass
extern class SeqString extends String {
}
@generateCppClass
extern class SeqOneByteString extends SeqString {
chars[length]: char8;
}
@generateCppClass
extern class SeqTwoByteString extends SeqString {
chars[length]: char16;
}
@generateCppClass
extern class SlicedString extends String {
parent: String;
offset: Smi;
}
@generateCppClass
extern class ThinString extends String {
actual: String;
}
// A direct string can be accessed directly through CSA without going into the
// C++ runtime. See also: ToDirectStringAssembler.
type DirectString extends String;

40
src/objects/struct.tq Normal file
View File

@ -0,0 +1,40 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
@generatePrint
@generateCppClass
extern class Struct extends HeapObject {
}
@abstract
@dirtyInstantiatedAbstractClass
@generatePrint
@generateCppClass
extern class Tuple2 extends Struct {
value1: Object;
value2: Object;
}
@abstract
@dirtyInstantiatedAbstractClass
@generatePrint
@generateCppClass
extern class Tuple3 extends Struct {
value1: Object;
value2: Object;
value3: Object;
}
@generateCppClass
extern class ClassPositions extends Struct {
start: Smi;
end: Smi;
}
@generateCppClass
extern class AccessorPair extends Struct {
getter: Object;
setter: Object;
}

View File

@ -0,0 +1,10 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class SyntheticModule extends Module {
name: String;
export_names: FixedArray;
evaluation_steps: Foreign;
}

View File

@ -0,0 +1,10 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generatePrint
@generateCppClass
extern class TemplateObjectDescription extends Struct {
raw_strings: FixedArray;
cooked_strings: FixedArray;
}

56
src/objects/template.tq Normal file
View File

@ -0,0 +1,56 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@abstract
@generateCppClass
extern class TemplateInfo extends Struct {
tag: Object;
serial_number: Object;
number_of_properties: Smi;
property_list: Object;
property_accessors: Object;
}
@generateCppClass
extern class FunctionTemplateRareData extends Struct {
// See DECL_RARE_ACCESSORS in FunctionTemplateInfo.
prototype_template: Object;
prototype_provider_template: Object;
parent_template: Object;
named_property_handler: Object;
indexed_property_handler: Object;
instance_template: Object;
instance_call_handler: Object;
access_check_info: Object;
}
@generateCppClass
extern class FunctionTemplateInfo extends TemplateInfo {
// Handler invoked when calling an instance of this FunctionTemplateInfo.
// Either CallHandlerInfo or Undefined.
call_code: Object;
class_name: Object;
// If the signature is a FunctionTemplateInfo it is used to check whether the
// receiver calling the associated JSFunction is a compatible receiver, i.e.
// it is an instance of the signature FunctionTemplateInfo or any of the
// receiver's prototypes are.
signature: Object;
// If any of the setters declared by DECL_RARE_ACCESSORS are used then a
// FunctionTemplateRareData will be stored here. Until then this contains
// undefined.
rare_data: HeapObject;
shared_function_info: Object;
flag: Smi;
length: Smi;
// Either the_hole or a private symbol. Used to cache the result on
// the receiver under the the cached_property_name when this
// FunctionTemplateInfo is used as a getter.
cached_property_name: Object;
}
@generateCppClass
extern class ObjectTemplateInfo extends TemplateInfo {
constructor: Object;
data: Object;
}

97
src/wasm/wasm-objects.tq Normal file
View File

@ -0,0 +1,97 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class WasmInstanceObject extends JSObject;
extern class WasmExportedFunctionData extends Struct {
wrapper_code: Code;
instance: WasmInstanceObject;
jump_table_offset: Smi;
function_index: Smi;
// The remaining fields are for fast calling from C++. The contract is
// that they are lazily populated, and either all will be present or none.
c_wrapper_code: Object;
wasm_call_target: Smi|Foreign;
packed_args_size: Smi;
}
extern class WasmJSFunctionData extends Struct {
callable: JSReceiver;
wrapper_code: Code;
serialized_return_count: Smi;
serialized_parameter_count: Smi;
serialized_signature: ByteArray; // PodArray<wasm::ValueType>
}
extern class WasmCapiFunctionData extends Struct {
call_target: RawPtr;
embedder_data: Foreign; // Managed<wasm::FuncData>
wrapper_code: Code;
serialized_signature: ByteArray; // PodArray<wasm::ValueType>
}
extern class WasmIndirectFunctionTable extends Struct {
size: uint32;
@if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
@ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void;
sig_ids: RawPtr;
targets: RawPtr;
managed_native_allocations: Foreign|Undefined;
refs: FixedArray;
}
extern class WasmDebugInfo extends Struct {
instance: WasmInstanceObject;
interpreter_handle: Foreign|Undefined;
interpreter_reference_stack: Cell;
locals_names: FixedArray|Undefined;
c_wasm_entries: FixedArray|Undefined;
c_wasm_entry_map: Foreign|Undefined; // Managed<wasm::SignatureMap>
}
@generateCppClass
extern class WasmExceptionTag extends Struct {
index: Smi;
}
extern class WasmModuleObject extends JSObject {
native_module: Foreign;
export_wrappers: FixedArray;
script: Script;
asm_js_offset_table: ByteArray|Undefined;
}
extern class WasmTableObject extends JSObject {
entries: FixedArray;
maximum_length: Smi|HeapNumber|Undefined;
dispatch_tables: FixedArray;
raw_type: Smi;
}
extern class WasmMemoryObject extends JSObject {
array_buffer: JSArrayBuffer;
maximum_pages: Smi;
instances: WeakArrayList|Undefined;
}
extern class WasmGlobalObject extends JSObject {
untagged_buffer: JSArrayBuffer|Undefined;
tagged_buffer: FixedArray|Undefined;
offset: Smi;
flags: Smi;
}
extern class WasmExceptionObject extends JSObject {
serialized_signature: ByteArray; // PodArray<wasm::ValueType>
exception_tag: HeapObject;
}
type WasmExportedFunction extends JSFunction;
extern class AsmWasmData extends Struct {
managed_native_module: Foreign; // Managed<wasm::NativeModule>
export_wrappers: FixedArray;
asm_js_offset_table: ByteArray;
uses_bitset: HeapNumber;
}