From 4685349480b0ffb3456ab0cc372e8f9bcb1f8040 Mon Sep 17 00:00:00 2001 From: Daniel Clifford Date: Wed, 21 Nov 2018 16:27:59 +0000 Subject: [PATCH] Revert "[torque] Implement intrinsics support" This reverts commit 74a0ad7ddacc9b16233ff7d6f3d7972a4e48b149. Reason for revert: Presubmit tests fail Original change's description: > [torque] Implement intrinsics support > > Also add the first intrinsic and usage of it: %RawCast > > Bug: v8:7793 > Change-Id: Id1e3288e8bab6adb510731076a39590e8fd156be > Reviewed-on: https://chromium-review.googlesource.com/c/1344152 > Commit-Queue: Daniel Clifford > Reviewed-by: Tobias Tebbi > Cr-Commit-Position: refs/heads/master@{#57692} TBR=danno@chromium.org,tebbi@chromium.org Change-Id: Ief78187f2edaf80c715dea676cbd40edd747ad21 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/1346500 Reviewed-by: Daniel Clifford Commit-Queue: Daniel Clifford Cr-Commit-Position: refs/heads/master@{#57694} --- src/builtins/base.tq | 22 ++-- src/code-stub-assembler.h | 17 +++ src/compiler/code-assembler.h | 1 - src/objects.h | 2 - src/torque/ast.h | 26 +---- src/torque/csa-generator.cc | 105 ++++++------------ src/torque/csa-generator.h | 5 - src/torque/declarable.h | 19 +--- src/torque/declaration-visitor.cc | 21 +--- src/torque/declaration-visitor.h | 4 +- src/torque/declarations.cc | 14 --- src/torque/declarations.h | 6 - src/torque/implementation-visitor.cc | 16 --- src/torque/implementation-visitor.h | 1 - src/torque/instructions.cc | 21 +--- src/torque/instructions.h | 12 -- src/torque/torque-parser.cc | 55 --------- src/torque/types.cc | 4 +- tools/torque/format-torque.py | 1 - tools/torque/vim-torque/syntax/torque.vim | 2 +- .../syntaxes/torque.tmLanguage.json | 2 +- 21 files changed, 75 insertions(+), 281 deletions(-) diff --git a/src/builtins/base.tq b/src/builtins/base.tq index 9a2cf2420c..14d1e1f3b9 100644 --- a/src/builtins/base.tq +++ b/src/builtins/base.tq @@ -62,11 +62,6 @@ type SloppyArgumentsElements extends FixedArray type NumberDictionary extends HeapObject generates 'TNode'; -// RawCasts should *never* be used anywhere in Torque code except for -// in Torque-based UnsafeCast operators preceeded by an appropriate -// type assert() -intrinsic %RawCast(o: Object): A; - type NativeContextSlot generates 'TNode' constexpr 'int32_t'; const ARRAY_JOIN_STACK_INDEX: constexpr NativeContextSlot generates 'Context::ARRAY_JOIN_STACK_INDEX'; @@ -840,6 +835,15 @@ UnsafeCast(o: Object): String { return UnsafeCastObjectToString(o); } +// RawCasts should *never* be used anywhere in Torque code except for +// in Torque-based UnsafeCast operators preceeded by an appropriate +// type check(). +extern macro RawCastObjectToJSFunction(Object): JSFunction; +extern macro RawCastObjectToJSArgumentsObjectWithLength(Object): + JSArgumentsObjectWithLength; +extern macro RawCastObjectToFastJSArray(Object): FastJSArray; +extern macro RawCastObjectToFastJSArrayForCopy(Object): FastJSArrayForCopy; + macro BranchIfJSArgumentsObjectWithLength(implicit context: Context)(o: Object): never labels True, False { @@ -855,7 +859,7 @@ macro BranchIfJSArgumentsObjectWithLength(implicit context: Context)(o: Object): UnsafeCast(implicit context: Context)(o: Object): JSArgumentsObjectWithLength { assert(BranchIfJSArgumentsObjectWithLength(o)); - return %RawCast(o); + return RawCastObjectToJSArgumentsObjectWithLength(o); } Cast(implicit context: Context)(o: Object): @@ -870,7 +874,7 @@ Cast(implicit context: Context)(o: Object): UnsafeCast(implicit context: Context)(o: Object): FastJSArray { assert(BranchIfFastJSArray(o, context)); - return %RawCast(o); + return RawCastObjectToFastJSArray(o); } Cast(implicit context: Context)(o: Object): FastJSArray @@ -894,7 +898,7 @@ Cast(implicit context: Context)(ho: HeapObject): FastJSArray UnsafeCast(implicit context: Context)(o: Object): FastJSArrayForCopy { assert(BranchIfFastJSArrayForCopy(o, context)); - return %RawCast(o); + return RawCastObjectToFastJSArrayForCopy(o); } Cast(implicit context: Context)(o: Object): @@ -909,7 +913,7 @@ Cast(implicit context: Context)(o: Object): UnsafeCast(implicit context: Context)(o: Object): JSFunction { assert(IsJSFunction(Cast(o) otherwise unreachable)); - return %RawCast(o); + return RawCastObjectToJSFunction(o); } Cast(implicit context: Context)(o: Object): JSFunction diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h index f5bf251257..89941fb415 100644 --- a/src/code-stub-assembler.h +++ b/src/code-stub-assembler.h @@ -403,6 +403,23 @@ class V8_EXPORT_PRIVATE CodeStubAssembler return CAST(p_o); } + TNode RawCastObjectToJSArgumentsObjectWithLength( + TNode p_o) { + return TNode::UncheckedCast(p_o); + } + + TNode RawCastObjectToFastJSArray(TNode p_o) { + return TNode::UncheckedCast(p_o); + } + + TNode RawCastObjectToFastJSArrayForCopy(TNode p_o) { + return TNode::UncheckedCast(p_o); + } + + TNode RawCastObjectToJSFunction(TNode p_o) { + return TNode::UncheckedCast(p_o); + } + Node* MatchesParameterMode(Node* value, ParameterMode mode); #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName) \ diff --git a/src/compiler/code-assembler.h b/src/compiler/code-assembler.h index b0c7d21752..a01e850206 100644 --- a/src/compiler/code-assembler.h +++ b/src/compiler/code-assembler.h @@ -18,7 +18,6 @@ #include "src/heap/heap.h" #include "src/machine-type.h" #include "src/objects.h" -#include "src/objects/arguments.h" #include "src/objects/data-handler.h" #include "src/objects/map.h" #include "src/objects/maybe-object.h" diff --git a/src/objects.h b/src/objects.h index 2e983674af..e7e9a190c1 100644 --- a/src/objects.h +++ b/src/objects.h @@ -757,7 +757,6 @@ class ZoneForwardList; V(HeapNumber) \ V(InternalizedString) \ V(JSArgumentsObject) \ - V(JSArgumentsObjectWithLength) \ V(JSArray) \ V(JSArrayBuffer) \ V(JSArrayBufferView) \ @@ -928,7 +927,6 @@ class ZoneForwardList; V(GlobalDictionary, GLOBAL_DICTIONARY_TYPE) \ V(HeapNumber, HEAP_NUMBER_TYPE) \ V(JSArgumentsObject, JS_ARGUMENTS_TYPE) \ - V(JSArgumentsObjectWithLength, JS_ARGUMENTS_TYPE) \ V(JSArray, JS_ARRAY_TYPE) \ V(JSArrayBuffer, JS_ARRAY_BUFFER_TYPE) \ V(JSArrayIterator, JS_ARRAY_ITERATOR_TYPE) \ diff --git a/src/torque/ast.h b/src/torque/ast.h index 93a6cfa29b..f00057163d 100644 --- a/src/torque/ast.h +++ b/src/torque/ast.h @@ -19,7 +19,6 @@ namespace torque { #define AST_EXPRESSION_NODE_KIND_LIST(V) \ V(CallExpression) \ - V(IntrinsicCallExpression) \ V(StructExpression) \ V(LogicalOrExpression) \ V(LogicalAndExpression) \ @@ -72,8 +71,7 @@ namespace torque { V(TorqueBuiltinDeclaration) \ V(ExternalMacroDeclaration) \ V(ExternalBuiltinDeclaration) \ - V(ExternalRuntimeDeclaration) \ - V(IntrinsicDeclaration) + V(ExternalRuntimeDeclaration) #define AST_NODE_KIND_LIST(V) \ AST_EXPRESSION_NODE_KIND_LIST(V) \ @@ -203,20 +201,6 @@ struct IdentifierExpression : LocationExpression { std::vector generic_arguments; }; -struct IntrinsicCallExpression : Expression { - DEFINE_AST_NODE_LEAF_BOILERPLATE(IntrinsicCallExpression) - IntrinsicCallExpression(SourcePosition pos, std::string name, - std::vector generic_arguments, - std::vector arguments) - : Expression(kKind, pos), - name(std::move(name)), - generic_arguments(std::move(generic_arguments)), - arguments(std::move(arguments)) {} - std::string name; - std::vector generic_arguments; - std::vector arguments; -}; - struct CallExpression : Expression { DEFINE_AST_NODE_LEAF_BOILERPLATE(CallExpression) CallExpression(SourcePosition pos, IdentifierExpression* callee, @@ -682,14 +666,6 @@ struct ExternalMacroDeclaration : MacroDeclaration { std::string external_assembler_name; }; -struct IntrinsicDeclaration : CallableNode { - DEFINE_AST_NODE_LEAF_BOILERPLATE(IntrinsicDeclaration) - IntrinsicDeclaration(SourcePosition pos, std::string name, - ParameterList parameters, TypeExpression* return_type) - : CallableNode(kKind, pos, false, std::move(name), std::move(parameters), - return_type, {}) {} -}; - struct TorqueMacroDeclaration : MacroDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(TorqueMacroDeclaration) TorqueMacroDeclaration(SourcePosition pos, bool transitioning, diff --git a/src/torque/csa-generator.cc b/src/torque/csa-generator.cc index 162b5a1e2f..903a32c232 100644 --- a/src/torque/csa-generator.cc +++ b/src/torque/csa-generator.cc @@ -128,77 +128,6 @@ void CSAGenerator::EmitInstruction( } } -void CSAGenerator::ProcessArgumentsCommon( - const TypeVector& parameter_types, std::vector* args, - std::vector* constexpr_arguments, Stack* stack) { - for (auto it = parameter_types.rbegin(); it != parameter_types.rend(); ++it) { - const Type* type = *it; - VisitResult arg; - if (type->IsConstexpr()) { - args->push_back(std::move(constexpr_arguments->back())); - constexpr_arguments->pop_back(); - } else { - std::stringstream s; - size_t slot_count = LoweredSlotCount(type); - VisitResult arg = VisitResult(type, stack->TopRange(slot_count)); - EmitCSAValue(arg, *stack, s); - args->push_back(s.str()); - stack->PopMany(slot_count); - } - } - std::reverse(args->begin(), args->end()); -} - -void CSAGenerator::EmitInstruction(const CallIntrinsicInstruction& instruction, - Stack* stack) { - std::vector constexpr_arguments = - instruction.constexpr_arguments; - std::vector args; - TypeVector parameter_types = - instruction.intrinsic->signature().parameter_types.types; - ProcessArgumentsCommon(parameter_types, &args, &constexpr_arguments, stack); - - Stack pre_call_stack = *stack; - const Type* return_type = instruction.intrinsic->signature().return_type; - std::vector results; - for (const Type* type : LowerType(return_type)) { - results.push_back(FreshNodeName()); - stack->Push(results.back()); - out_ << " compiler::TNode<" << type->GetGeneratedTNodeTypeName() << "> " - << stack->Top() << ";\n"; - out_ << " USE(" << stack->Top() << ");\n"; - } - out_ << " "; - - if (return_type->IsStructType()) { - out_ << "std::tie("; - PrintCommaSeparatedList(out_, results); - out_ << ") = "; - } else { - if (results.size() == 1) { - out_ << results[0] << " = "; - } - } - - if (instruction.intrinsic->ExternalName() == "%RawCast") { - if (!return_type->IsSubtypeOf(TypeOracle::GetObjectType())) { - ReportError("%RawCast must cast to subtype of Object"); - } - out_ << "TORQUE_CAST"; - } else { - ReportError("no built in intrinsic with name " + - instruction.intrinsic->ExternalName()); - } - - out_ << "("; - PrintCommaSeparatedList(out_, args); - if (return_type->IsStructType()) { - out_ << ").Flatten();\n"; - } else { - out_ << ");\n"; - } -} - void CSAGenerator::EmitInstruction(const CallCsaMacroInstruction& instruction, Stack* stack) { std::vector constexpr_arguments = @@ -206,7 +135,22 @@ void CSAGenerator::EmitInstruction(const CallCsaMacroInstruction& instruction, std::vector args; TypeVector parameter_types = instruction.macro->signature().parameter_types.types; - ProcessArgumentsCommon(parameter_types, &args, &constexpr_arguments, stack); + for (auto it = parameter_types.rbegin(); it != parameter_types.rend(); ++it) { + const Type* type = *it; + VisitResult arg; + if (type->IsConstexpr()) { + args.push_back(std::move(constexpr_arguments.back())); + constexpr_arguments.pop_back(); + } else { + std::stringstream s; + size_t slot_count = LoweredSlotCount(type); + VisitResult arg = VisitResult(type, stack->TopRange(slot_count)); + EmitCSAValue(arg, *stack, s); + args.push_back(s.str()); + stack->PopMany(slot_count); + } + } + std::reverse(args.begin(), args.end()); Stack pre_call_stack = *stack; const Type* return_type = instruction.macro->signature().return_type; @@ -252,7 +196,22 @@ void CSAGenerator::EmitInstruction( std::vector args; TypeVector parameter_types = instruction.macro->signature().parameter_types.types; - ProcessArgumentsCommon(parameter_types, &args, &constexpr_arguments, stack); + for (auto it = parameter_types.rbegin(); it != parameter_types.rend(); ++it) { + const Type* type = *it; + VisitResult arg; + if (type->IsConstexpr()) { + args.push_back(std::move(constexpr_arguments.back())); + constexpr_arguments.pop_back(); + } else { + std::stringstream s; + size_t slot_count = LoweredSlotCount(type); + VisitResult arg = VisitResult(type, stack->TopRange(slot_count)); + EmitCSAValue(arg, *stack, s); + args.push_back(s.str()); + stack->PopMany(slot_count); + } + } + std::reverse(args.begin(), args.end()); Stack pre_call_stack = *stack; std::vector results; diff --git a/src/torque/csa-generator.h b/src/torque/csa-generator.h index e3fbacdecf..5d72feb398 100644 --- a/src/torque/csa-generator.h +++ b/src/torque/csa-generator.h @@ -45,11 +45,6 @@ class CSAGenerator { return "block" + std::to_string(block->id()); } - void ProcessArgumentsCommon(const TypeVector& parameter_types, - std::vector* args, - std::vector* constexpr_arguments, - Stack* stack); - Stack EmitBlock(const Block* block); void EmitInstruction(const Instruction& instruction, Stack* stack); diff --git a/src/torque/declarable.h b/src/torque/declarable.h index 8783c46a42..85b33e0ba1 100644 --- a/src/torque/declarable.h +++ b/src/torque/declarable.h @@ -45,7 +45,6 @@ class Declarable { kMacro, kBuiltin, kRuntimeFunction, - kIntrinsic, kGeneric, kTypeAlias, kExternConstant, @@ -54,7 +53,6 @@ class Declarable { Kind kind() const { return kind_; } bool IsNamespace() const { return kind() == kNamespace; } bool IsMacro() const { return kind() == kMacro; } - bool IsIntrinsic() const { return kind() == kIntrinsic; } bool IsBuiltin() const { return kind() == kBuiltin; } bool IsRuntimeFunction() const { return kind() == kRuntimeFunction; } bool IsGeneric() const { return kind() == kGeneric; } @@ -64,7 +62,7 @@ class Declarable { bool IsValue() const { return IsExternConstant() || IsNamespaceConstant(); } bool IsScope() const { return IsNamespace() || IsCallable(); } bool IsCallable() const { - return IsMacro() || IsBuiltin() || IsRuntimeFunction() || IsIntrinsic(); + return IsMacro() || IsBuiltin() || IsRuntimeFunction(); } virtual const char* type_name() const { return "<>"; } Scope* ParentScope() const { return parent_scope_; } @@ -331,21 +329,6 @@ class RuntimeFunction : public Callable { transitioning, base::nullopt) {} }; -class Intrinsic : public Callable { - public: - DECLARE_DECLARABLE_BOILERPLATE(Intrinsic, intrinsic); - - private: - friend class Declarations; - Intrinsic(std::string name, const Signature& signature) - : Callable(Declarable::kIntrinsic, name, name, signature, false, - base::nullopt) { - if (signature.parameter_types.var_args) { - ReportError("Varargs are not supported for intrinsics."); - } - } -}; - class Generic : public Declarable { public: DECLARE_DECLARABLE_BOILERPLATE(Generic, generic); diff --git a/src/torque/declaration-visitor.cc b/src/torque/declaration-visitor.cc index 5e7bcf4581..9556930020 100644 --- a/src/torque/declaration-visitor.cc +++ b/src/torque/declaration-visitor.cc @@ -142,12 +142,6 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl, decl->transitioning, body, decl->op); } -void DeclarationVisitor::Visit(IntrinsicDeclaration* decl, - const Signature& signature, - base::Optional body) { - Declarations::DeclareIntrinsic(decl->name, signature); -} - void DeclarationVisitor::Visit(ConstDeclaration* decl) { Declarations::DeclareNamespaceConstant( decl->name, Declarations::GetType(decl->type), decl->expression); @@ -296,9 +290,7 @@ Signature DeclarationVisitor::MakeSpecializedSignature( } Callable* DeclarationVisitor::SpecializeImplicit(const SpecializationKey& key) { - if (!key.generic->declaration()->body && - IntrinsicDeclaration::DynamicCast(key.generic->declaration()->callable) == - nullptr) { + if (!key.generic->declaration()->body) { ReportError("missing specialization of ", key.generic->name(), " with types <", key.specialized_types, "> declared at ", key.generic->pos()); @@ -306,7 +298,7 @@ Callable* DeclarationVisitor::SpecializeImplicit(const SpecializationKey& key) { CurrentScope::Scope generic_scope(key.generic->ParentScope()); Callable* result = Specialize(key, key.generic->declaration()->callable, base::nullopt, - key.generic->declaration()->body); + *key.generic->declaration()->body); CurrentScope::Scope callable_scope(result); DeclareSpecializedTypes(key); return result; @@ -314,8 +306,7 @@ Callable* DeclarationVisitor::SpecializeImplicit(const SpecializationKey& key) { Callable* DeclarationVisitor::Specialize( const SpecializationKey& key, CallableNode* declaration, - base::Optional signature, - base::Optional body) { + base::Optional signature, Statement* body) { // TODO(tebbi): The error should point to the source position where the // instantiation was requested. CurrentSourcePosition::Scope pos_scope(key.generic->declaration()->pos); @@ -353,13 +344,11 @@ Callable* DeclarationVisitor::Specialize( if (MacroDeclaration::DynamicCast(declaration) != nullptr) { callable = Declarations::CreateMacro(generated_name, readable_name.str(), base::nullopt, type_signature, - declaration->transitioning, *body); - } else if (IntrinsicDeclaration::DynamicCast(declaration) != nullptr) { - callable = Declarations::CreateIntrinsic(declaration->name, type_signature); + declaration->transitioning, body); } else { BuiltinDeclaration* builtin = BuiltinDeclaration::cast(declaration); callable = CreateBuiltin(builtin, generated_name, readable_name.str(), - type_signature, *body); + type_signature, body); } key.generic->AddSpecialization(key.specialized_types, callable); return callable; diff --git a/src/torque/declaration-visitor.h b/src/torque/declaration-visitor.h index 9961581e53..332d4c66ec 100644 --- a/src/torque/declaration-visitor.h +++ b/src/torque/declaration-visitor.h @@ -69,8 +69,6 @@ class DeclarationVisitor : public FileVisitor { base::Optional body); void Visit(TorqueMacroDeclaration* decl, const Signature& signature, base::Optional body); - void Visit(IntrinsicDeclaration* decl, const Signature& signature, - base::Optional body); void Visit(CallableNode* decl, const Signature& signature, base::Optional body); @@ -86,7 +84,7 @@ class DeclarationVisitor : public FileVisitor { Callable* SpecializeImplicit(const SpecializationKey& key); Callable* Specialize(const SpecializationKey& key, CallableNode* declaration, base::Optional signature, - base::Optional body); + Statement* body); private: void DeclareSpecializedTypes(const SpecializationKey& key); diff --git a/src/torque/declarations.cc b/src/torque/declarations.cc index 7c0f79d6d4..a115e700b5 100644 --- a/src/torque/declarations.cc +++ b/src/torque/declarations.cc @@ -208,20 +208,6 @@ Macro* Declarations::DeclareMacro( return macro; } -Intrinsic* Declarations::CreateIntrinsic(const std::string& name, - const Signature& signature) { - Intrinsic* result = RegisterDeclarable(std::unique_ptr( - new Intrinsic(std::move(name), std::move(signature)))); - return result; -} - -Intrinsic* Declarations::DeclareIntrinsic(const std::string& name, - const Signature& signature) { - Intrinsic* result = CreateIntrinsic(std::move(name), std::move(signature)); - Declare(name, result); - return result; -} - Builtin* Declarations::CreateBuiltin(std::string external_name, std::string readable_name, Builtin::Kind kind, Signature signature, diff --git a/src/torque/declarations.h b/src/torque/declarations.h index 764926223f..c12483e89a 100644 --- a/src/torque/declarations.h +++ b/src/torque/declarations.h @@ -97,12 +97,6 @@ class Declarations { const Signature& signature, bool transitioning, base::Optional body, base::Optional op = {}); - static Intrinsic* CreateIntrinsic(const std::string& name, - const Signature& signature); - - static Intrinsic* DeclareIntrinsic(const std::string& name, - const Signature& signature); - static Builtin* CreateBuiltin(std::string external_name, std::string readable_name, Builtin::Kind kind, Signature signature, bool transitioning, diff --git a/src/torque/implementation-visitor.cc b/src/torque/implementation-visitor.cc index 67230f42b8..b15bc20a3c 100644 --- a/src/torque/implementation-visitor.cc +++ b/src/torque/implementation-visitor.cc @@ -1809,11 +1809,6 @@ VisitResult ImplementationVisitor::GenerateCall( // we should assert slot_count == 1 here. return VisitResult(return_type, assembler().TopRange(slot_count)); } - } else if (auto* intrinsic = Intrinsic::DynamicCast(callable)) { - assembler().Emit(CallIntrinsicInstruction{intrinsic, constexpr_arguments}); - size_t return_slot_count = - LoweredSlotCount(intrinsic->signature().return_type); - return VisitResult(return_type, assembler().TopRange(return_slot_count)); } else { UNREACHABLE(); } @@ -1842,16 +1837,6 @@ VisitResult ImplementationVisitor::Visit(CallExpression* expr, } } -VisitResult ImplementationVisitor::Visit(IntrinsicCallExpression* expr) { - StackScope scope(this); - Arguments arguments; - TypeVector specialization_types = GetTypeVector(expr->generic_arguments); - for (Expression* arg : expr->arguments) - arguments.parameters.push_back(Visit(arg)); - return scope.Yield( - GenerateCall(expr->name, arguments, specialization_types, false)); -} - void ImplementationVisitor::GenerateBranch(const VisitResult& condition, Block* true_block, Block* false_block) { @@ -2028,7 +2013,6 @@ void ImplementationVisitor::Visit(Declarable* declarable) { case Declarable::kNamespaceConstant: return Visit(NamespaceConstant::cast(declarable)); case Declarable::kRuntimeFunction: - case Declarable::kIntrinsic: case Declarable::kExternConstant: case Declarable::kNamespace: case Declarable::kGeneric: diff --git a/src/torque/implementation-visitor.h b/src/torque/implementation-visitor.h index a55a761491..89212e1c0f 100644 --- a/src/torque/implementation-visitor.h +++ b/src/torque/implementation-visitor.h @@ -233,7 +233,6 @@ class ImplementationVisitor : public FileVisitor { void Visit(NamespaceConstant* decl); VisitResult Visit(CallExpression* expr, bool is_tail = false); - VisitResult Visit(IntrinsicCallExpression* intrinsic); const Type* Visit(TailCallStatement* stmt); VisitResult Visit(ConditionalExpression* expr); diff --git a/src/torque/instructions.cc b/src/torque/instructions.cc index e3ac131188..7a236758c6 100644 --- a/src/torque/instructions.cc +++ b/src/torque/instructions.cc @@ -85,25 +85,6 @@ void InstructionBase::InvalidateTransientTypes( } } -void CallIntrinsicInstruction::TypeInstruction(Stack* stack, - ControlFlowGraph* cfg) const { - std::vector parameter_types = - LowerParameterTypes(intrinsic->signature().parameter_types); - for (intptr_t i = parameter_types.size() - 1; i >= 0; --i) { - const Type* arg_type = stack->Pop(); - const Type* parameter_type = parameter_types.back(); - parameter_types.pop_back(); - if (arg_type != parameter_type) { - ReportError("parameter ", i, ": expected type ", *parameter_type, - " but found type ", *arg_type); - } - } - if (intrinsic->IsTransitioning()) { - InvalidateTransientTypes(stack); - } - stack->PushMany(LowerType(intrinsic->signature().return_type)); -} - void CallCsaMacroInstruction::TypeInstruction(Stack* stack, ControlFlowGraph* cfg) const { std::vector parameter_types = @@ -117,6 +98,7 @@ void CallCsaMacroInstruction::TypeInstruction(Stack* stack, " but found type ", *arg_type); } } + if (!parameter_types.empty()) ReportError("missing arguments"); if (macro->IsTransitioning()) { InvalidateTransientTypes(stack); @@ -144,6 +126,7 @@ void CallCsaMacroAndBranchInstruction::TypeInstruction( " but found type ", *arg_type); } } + if (!parameter_types.empty()) ReportError("missing arguments"); if (label_blocks.size() != macro->signature().labels.size()) { ReportError("wrong number of labels"); diff --git a/src/torque/instructions.h b/src/torque/instructions.h index 3e0feed15d..08059a61f3 100644 --- a/src/torque/instructions.h +++ b/src/torque/instructions.h @@ -19,7 +19,6 @@ namespace torque { class Block; class Builtin; class ControlFlowGraph; -class Intrinsic; class Macro; class NamespaceConstant; class RuntimeFunction; @@ -31,7 +30,6 @@ class RuntimeFunction; V(PushUninitializedInstruction) \ V(PushCodePointerInstruction) \ V(CallCsaMacroInstruction) \ - V(CallIntrinsicInstruction) \ V(NamespaceConstantInstruction) \ V(CallCsaMacroAndBranchInstruction) \ V(CallBuiltinInstruction) \ @@ -189,16 +187,6 @@ struct NamespaceConstantInstruction : InstructionBase { NamespaceConstant* constant; }; -struct CallIntrinsicInstruction : InstructionBase { - TORQUE_INSTRUCTION_BOILERPLATE() - CallIntrinsicInstruction(Intrinsic* intrinsic, - std::vector constexpr_arguments) - : intrinsic(intrinsic), constexpr_arguments(constexpr_arguments) {} - - Intrinsic* intrinsic; - std::vector constexpr_arguments; -}; - struct CallCsaMacroInstruction : InstructionBase { TORQUE_INSTRUCTION_BOILERPLATE() CallCsaMacroInstruction(Macro* macro, diff --git a/src/torque/torque-parser.cc b/src/torque/torque-parser.cc index ffaa0e5fd2..045cfcfe1e 100644 --- a/src/torque/torque-parser.cc +++ b/src/torque/torque-parser.cc @@ -269,17 +269,6 @@ base::Optional MakeBinaryOperator( std::vector{})}; } -base::Optional MakeIntrinsicDeclarationCallExpression( - ParseResultIterator* child_results) { - auto callee = child_results->NextAs(); - auto generic_arguments = - child_results->NextAs>(); - auto args = child_results->NextAs>(); - Expression* result = - MakeNode(callee, generic_arguments, args); - return ParseResult{result}; -} - base::Optional MakeUnaryOperator( ParseResultIterator* child_results) { auto op = child_results->NextAs(); @@ -393,25 +382,6 @@ base::Optional MakeExternalMacro( return ParseResult{result}; } -base::Optional MakeIntrinsicDeclaration( - ParseResultIterator* child_results) { - auto name = child_results->NextAs(); - auto generic_parameters = child_results->NextAs(); - LintGenericParameters(generic_parameters); - - auto args = child_results->NextAs(); - auto return_type = child_results->NextAs(); - IntrinsicDeclaration* macro = - MakeNode(name, args, return_type); - Declaration* result; - if (generic_parameters.empty()) { - result = MakeNode(macro, base::nullopt); - } else { - result = MakeNode(macro, generic_parameters); - } - return ParseResult{result}; -} - base::Optional MakeTorqueMacroDeclaration( ParseResultIterator* child_results) { auto transitioning = child_results->NextAs(); @@ -1055,16 +1025,6 @@ struct TorqueGrammar : Grammar { return true; } - static bool MatchIntrinsicName(InputPosition* pos) { - InputPosition current = *pos; - if (!MatchString("%", ¤t)) return false; - if (!MatchChar(std::isalpha, ¤t)) return false; - while (MatchChar(std::isalnum, ¤t) || MatchString("_", pos)) { - } - *pos = current; - return true; - } - static bool MatchStringLiteral(InputPosition* pos) { InputPosition current = *pos; if (MatchString("\"", ¤t)) { @@ -1128,10 +1088,6 @@ struct TorqueGrammar : Grammar { // Result: std::string Symbol identifier = {Rule({Pattern(MatchIdentifier)}, YieldMatchedInput)}; - // Result: std::string - Symbol intrinsicName = { - Rule({Pattern(MatchIntrinsicName)}, YieldMatchedInput)}; - // Result: std::string Symbol stringLiteral = { Rule({Pattern(MatchStringLiteral)}, YieldMatchedInput)}; @@ -1281,16 +1237,9 @@ struct TorqueGrammar : Grammar { Symbol callExpression = {Rule( {&identifierExpression, &argumentList, optionalOtherwise}, MakeCall)}; - // Result: Expression* - Symbol IntrinsicCallExpression = {Rule( - {&intrinsicName, TryOrDefault(&genericSpecializationTypeList), - &argumentList}, - MakeIntrinsicDeclarationCallExpression)}; - // Result: Expression* Symbol primaryExpression = { Rule({&callExpression}), - Rule({&IntrinsicCallExpression}), Rule({&locationExpression}, CastParseResult), Rule({&decimalLiteral}, MakeNumberLiteralExpression), @@ -1482,10 +1431,6 @@ struct TorqueGrammar : Grammar { MakeTypeDeclaration), Rule({Token("type"), &identifier, Token("="), &type, Token(";")}, MakeTypeAliasDeclaration), - Rule({Token("intrinsic"), &intrinsicName, - TryOrDefault(&genericParameters), - ¶meterListNoVararg, &optionalReturnType, Token(";")}, - MakeIntrinsicDeclaration), Rule({Token("extern"), CheckIf(Token("transitioning")), Optional( Sequence({Token("operator"), &externalString})), diff --git a/src/torque/types.cc b/src/torque/types.cc index f0a67a02ef..e19e6a232b 100644 --- a/src/torque/types.cc +++ b/src/torque/types.cc @@ -204,9 +204,7 @@ void PrintSignature(std::ostream& os, const Signature& sig, bool with_names) { if (i > 0) os << ", "; } if (with_names && !sig.parameter_names.empty()) { - if (i < sig.parameter_names.size()) { - os << sig.parameter_names[i] << ": "; - } + os << sig.parameter_names[i] << ": "; } os << *sig.parameter_types.types[i]; } diff --git a/tools/torque/format-torque.py b/tools/torque/format-torque.py index 6012366ddf..1981c3a3c7 100755 --- a/tools/torque/format-torque.py +++ b/tools/torque/format-torque.py @@ -47,7 +47,6 @@ def preprocess(input): return input def postprocess(output): - output = re.sub(r'% RawCast', r'%RawCast', output) output = re.sub(r'\/\*COxp\*\/', r'constexpr', output) output = re.sub(r'(\S+)\s*: type([,>])', r'\1: type\2', output) output = re.sub(r'(\n\s*)labels( [A-Z])', r'\1 labels\2', output) diff --git a/tools/torque/vim-torque/syntax/torque.vim b/tools/torque/vim-torque/syntax/torque.vim index 5864a63526..0caeba39cc 100644 --- a/tools/torque/vim-torque/syntax/torque.vim +++ b/tools/torque/vim-torque/syntax/torque.vim @@ -26,7 +26,7 @@ syn keyword torqueBranch break continue goto syn keyword torqueConditional if else typeswitch otherwise syn match torqueConstant /\v<[A-Z][A-Z0-9_]+>/ syn match torqueConstant /\v/ -syn keyword torqueFunction macro builtin runtime intrinsic +syn keyword torqueFunction macro builtin runtime syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast syn keyword torqueLabel case syn keyword torqueMatching try label catch diff --git a/tools/torque/vscode-torque/syntaxes/torque.tmLanguage.json b/tools/torque/vscode-torque/syntaxes/torque.tmLanguage.json index 630ce37f8d..96c1cd7a84 100644 --- a/tools/torque/vscode-torque/syntaxes/torque.tmLanguage.json +++ b/tools/torque/vscode-torque/syntaxes/torque.tmLanguage.json @@ -65,7 +65,7 @@ }, { "name": "keyword.other.torque", - "match": "\\b(constexpr|module|macro|builtin|runtime|intrinsic|javascript|implicit|deferred|label|labels|tail|let|generates|type|extends|extern|const|typeswitch|case|transient|transitioning)\\b" + "match": "\\b(constexpr|module|macro|builtin|runtime|javascript|implicit|deferred|label|labels|tail|let|generates|type|extends|extern|const|typeswitch|case|transient|transitioning)\\b" }, { "name": "keyword.operator.torque",