Commit 29557523 authored by Georg Schmid's avatar Georg Schmid Committed by Commit Bot

Add StaticAssert in Torque

R=tebbi@chromium.org

Change-Id: I3f34eeaf4ab9a198ffc68a8c974f0bf35a0582e9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1622117
Commit-Queue: Georg Schmid <gsps@google.com>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61704}
parent cdd3c7cb
......@@ -1331,6 +1331,7 @@ extern macro SelectBooleanConstant(bool): Boolean;
extern macro Print(constexpr string);
extern macro Print(constexpr string, Object);
extern macro Comment(constexpr string);
extern macro StaticAssert(bool);
extern macro Print(Object);
extern macro DebugBreak();
extern transitioning macro ToInteger_Inline(Context, Object): Number;
......
......@@ -425,6 +425,10 @@ void CodeAssembler::Comment(std::string str) {
raw_assembler()->Comment(str);
}
void CodeAssembler::StaticAssert(TNode<BoolT> value) {
raw_assembler()->StaticAssert(value);
}
void CodeAssembler::SetSourcePosition(const char* file, int line) {
raw_assembler()->SetSourcePosition(file, line);
}
......
......@@ -877,6 +877,8 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Comment(s.str());
}
void StaticAssert(TNode<BoolT> value);
void SetSourcePosition(const char* file, int line);
void Bind(Label* label);
......
......@@ -575,6 +575,10 @@ void RawMachineAssembler::Comment(const std::string& msg) {
AddNode(machine()->Comment(zone_buffer));
}
void RawMachineAssembler::StaticAssert(Node* value) {
AddNode(common()->StaticAssert(), value);
}
Node* RawMachineAssembler::CallN(CallDescriptor* call_descriptor,
int input_count, Node* const* inputs) {
DCHECK(!call_descriptor->NeedsFrameState());
......
......@@ -994,6 +994,7 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
void DebugBreak();
void Unreachable();
void Comment(const std::string& msg);
void StaticAssert(Node* value);
#if DEBUG
void Bind(RawMachineLabel* label, AssemblerDebugInfo info);
......
......@@ -604,6 +604,14 @@ TEST(TestCodeAssemblerCodeComment) {
CHECK(found_comment);
}
TEST(StaticAssert) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
m.StaticAssert(m.ReinterpretCast<BoolT>(m.Int32Constant(1)));
USE(asm_tester.GenerateCode());
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -486,6 +486,20 @@ TEST(TestReferences) {
ft.Call();
}
TEST(TestStaticAssert) {
CcTest::InitializeVM();
Isolate* isolate(CcTest::i_isolate());
i::HandleScope scope(isolate);
CodeAssemblerTester asm_tester(isolate);
TestTorqueAssembler m(asm_tester.state());
{
m.TestStaticAssert();
m.Return(m.UndefinedConstant());
}
FunctionTester ft(asm_tester.GenerateCode(), 0);
ft.Call();
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -974,4 +974,9 @@ namespace test {
type FooType = Smi | Bar;
@export
macro TestStaticAssert() {
StaticAssert(1 + 2 == 3);
}
}
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