e6238be3cb
Change-Id: I37ed9115c099f3d17f23a26348a1bbf5f773ee32 Reviewed-on: https://chromium-review.googlesource.com/1056668 Reviewed-by: Daniel Clifford <danno@chromium.org> Commit-Queue: Peter Wong <peter.wm.wong@gmail.com> Cr-Commit-Position: refs/heads/master@{#53136}
86 lines
1.9 KiB
Plaintext
86 lines
1.9 KiB
Plaintext
// Copyright 2018 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.
|
|
|
|
module test {
|
|
|
|
macro ElementsKindTestHelper1(kind: constexpr ElementsKind): bool {
|
|
if constexpr ((kind == UINT8_ELEMENTS) || (kind == UINT16_ELEMENTS)) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
macro ElementsKindTestHelper2(kind: constexpr ElementsKind): bool {
|
|
return ((kind == UINT8_ELEMENTS) || (kind == UINT16_ELEMENTS));
|
|
}
|
|
|
|
macro ElementsKindTestHelper3(kind: constexpr ElementsKind): constexpr bool {
|
|
return ((kind == UINT8_ELEMENTS) || (kind == UINT16_ELEMENTS));
|
|
}
|
|
|
|
macro LabelTestHelper1(): never
|
|
labels Label1 {
|
|
goto Label1;
|
|
}
|
|
|
|
macro LabelTestHelper2(): never
|
|
labels Label2(Smi) {
|
|
goto Label2(42);
|
|
}
|
|
|
|
macro LabelTestHelper3(): never
|
|
labels Label3(String, Smi) {
|
|
goto Label3('foo', 7);
|
|
}
|
|
|
|
macro TestConstexpr1() {
|
|
assert(convert<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS)));
|
|
}
|
|
|
|
macro TestConstexprIf() {
|
|
assert(ElementsKindTestHelper1(UINT8_ELEMENTS));
|
|
assert(ElementsKindTestHelper1(UINT16_ELEMENTS));
|
|
assert(!ElementsKindTestHelper1(UINT32_ELEMENTS));
|
|
}
|
|
|
|
macro TestConstexprReturn() {
|
|
assert(convert<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS)));
|
|
assert(convert<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS)));
|
|
assert(!convert<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS)));
|
|
assert(convert<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS)));
|
|
}
|
|
|
|
macro TestGotoLabel(): Boolean {
|
|
try {
|
|
LabelTestHelper1() otherwise Label1;
|
|
}
|
|
label Label1 {
|
|
return True;
|
|
}
|
|
}
|
|
|
|
macro TestGotoLabelWithOneParameter(): Boolean {
|
|
try {
|
|
LabelTestHelper2() otherwise Label2;
|
|
}
|
|
label Label2(smi: Smi) {
|
|
assert(smi == 42);
|
|
return True;
|
|
}
|
|
}
|
|
|
|
macro TestGotoLabelWithTwoParameters(): Boolean {
|
|
try {
|
|
LabelTestHelper3() otherwise Label3;
|
|
}
|
|
label Label3(str: String, smi: Smi) {
|
|
assert(str == 'foo');
|
|
assert(smi == 7);
|
|
return True;
|
|
}
|
|
}
|
|
|
|
}
|