Commit cbc1fefe authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] create constexpr versions for class types

This enables defining abstract type subtypes of classes
with constexpr version, which in turn is useful to model
custom C++ subclasses.

Bug: v8:7793
Change-Id: I07dcb62121afdddfbe2c78ecc870afcb11800c19
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2412180
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69982}
parent 2b60b8d4
...@@ -965,8 +965,17 @@ base::Optional<ParseResult> MakeClassDeclaration( ...@@ -965,8 +965,17 @@ base::Optional<ParseResult> MakeClassDeclaration(
std::vector<Declaration*> result; std::vector<Declaration*> result;
result.push_back(MakeNode<ClassDeclaration>( result.push_back(MakeNode<ClassDeclaration>(
name, flags, std::move(extends), std::move(generates), std::move(methods), name, flags, extends, std::move(generates), std::move(methods), fields,
fields, MakeInstanceTypeConstraints(annotations))); MakeInstanceTypeConstraints(annotations)));
Identifier* constexpr_name =
MakeNode<Identifier>(CONSTEXPR_TYPE_PREFIX + name->value);
constexpr_name->pos = name->pos;
TypeExpression* constexpr_extends = AddConstexpr(extends);
TypeDeclaration* constexpr_decl = MakeNode<AbstractTypeDeclaration>(
constexpr_name, transient, constexpr_extends, name->value);
constexpr_decl->pos = name->pos;
result.push_back(constexpr_decl);
if ((flags & ClassFlag::kDoNotGenerateCast) == 0 && if ((flags & ClassFlag::kDoNotGenerateCast) == 0 &&
(flags & ClassFlag::kIsShape) == 0) { (flags & ClassFlag::kIsShape) == 0) {
......
...@@ -74,10 +74,7 @@ std::string Type::SimpleName() const { ...@@ -74,10 +74,7 @@ std::string Type::SimpleName() const {
std::string Type::HandlifiedCppTypeName() const { std::string Type::HandlifiedCppTypeName() const {
if (IsSubtypeOf(TypeOracle::GetSmiType())) return "int"; if (IsSubtypeOf(TypeOracle::GetSmiType())) return "int";
if (IsSubtypeOf(TypeOracle::GetTaggedType())) { if (IsSubtypeOf(TypeOracle::GetTaggedType())) {
base::Optional<const ClassType*> class_type = ClassSupertype(); return "Handle<" + ConstexprVersion()->GetGeneratedTypeName() + ">";
std::string type =
class_type ? (*class_type)->GetGeneratedTNodeTypeName() : "Object";
return "Handle<" + type + ">";
} else { } else {
return ConstexprVersion()->GetGeneratedTypeName(); return ConstexprVersion()->GetGeneratedTypeName();
} }
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
type PodArrayOfWasmValueType extends ByteArray
constexpr 'PodArray<wasm::ValueType>';
type ManagedWasmNativeModule extends Foreign
constexpr 'Managed<wasm::NativeModule>';
type WasmValueType extends uint8 constexpr 'wasm::ValueType::Kind';
extern class WasmInstanceObject extends JSObject; extern class WasmInstanceObject extends JSObject;
extern class WasmExportedFunctionData extends Struct { extern class WasmExportedFunctionData extends Struct {
...@@ -22,14 +28,14 @@ extern class WasmJSFunctionData extends Struct { ...@@ -22,14 +28,14 @@ extern class WasmJSFunctionData extends Struct {
wrapper_code: Code; wrapper_code: Code;
serialized_return_count: Smi; serialized_return_count: Smi;
serialized_parameter_count: Smi; serialized_parameter_count: Smi;
serialized_signature: ByteArray; // PodArray<wasm::ValueType> serialized_signature: PodArrayOfWasmValueType;
} }
extern class WasmCapiFunctionData extends Struct { extern class WasmCapiFunctionData extends Struct {
call_target: RawPtr; call_target: RawPtr;
embedder_data: Foreign; // Managed<wasm::FuncData> embedder_data: Foreign; // Managed<wasm::FuncData>
wrapper_code: Code; wrapper_code: Code;
serialized_signature: ByteArray; // PodArray<wasm::ValueType> serialized_signature: PodArrayOfWasmValueType;
} }
extern class WasmIndirectFunctionTable extends Struct { extern class WasmIndirectFunctionTable extends Struct {
...@@ -51,7 +57,7 @@ extern class WasmExceptionTag extends Struct { ...@@ -51,7 +57,7 @@ extern class WasmExceptionTag extends Struct {
} }
extern class WasmModuleObject extends JSObject { extern class WasmModuleObject extends JSObject {
native_module: Foreign; native_module: ManagedWasmNativeModule;
export_wrappers: FixedArray; export_wrappers: FixedArray;
script: Script; script: Script;
} }
...@@ -70,8 +76,6 @@ extern class WasmMemoryObject extends JSObject { ...@@ -70,8 +76,6 @@ extern class WasmMemoryObject extends JSObject {
instances: WeakArrayList|Undefined; instances: WeakArrayList|Undefined;
} }
type WasmValueType extends uint8 constexpr 'wasm::ValueType::Kind';
extern class WasmGlobalObject extends JSObject { extern class WasmGlobalObject extends JSObject {
instance: WasmInstanceObject|Undefined; instance: WasmInstanceObject|Undefined;
untagged_buffer: JSArrayBuffer|Undefined; untagged_buffer: JSArrayBuffer|Undefined;
...@@ -82,14 +86,14 @@ extern class WasmGlobalObject extends JSObject { ...@@ -82,14 +86,14 @@ extern class WasmGlobalObject extends JSObject {
} }
extern class WasmExceptionObject extends JSObject { extern class WasmExceptionObject extends JSObject {
serialized_signature: ByteArray; // PodArray<wasm::ValueType> serialized_signature: PodArrayOfWasmValueType;
exception_tag: HeapObject; exception_tag: HeapObject;
} }
type WasmExportedFunction extends JSFunction; type WasmExportedFunction extends JSFunction;
extern class AsmWasmData extends Struct { extern class AsmWasmData extends Struct {
managed_native_module: Foreign; // Managed<wasm::NativeModule> managed_native_module: ManagedWasmNativeModule;
export_wrappers: FixedArray; export_wrappers: FixedArray;
uses_bitset: HeapNumber; uses_bitset: HeapNumber;
} }
......
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