2018-05-13 10:10:44 +00:00
|
|
|
// Copyright 2015 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.
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
2019-05-17 12:13:44 +00:00
|
|
|
#include "src/api/api-inl.h"
|
2018-05-13 10:10:44 +00:00
|
|
|
#include "src/base/utils/random-number-generator.h"
|
|
|
|
#include "src/builtins/builtins-promise-gen.h"
|
|
|
|
#include "src/builtins/builtins-string-gen.h"
|
2019-05-21 09:30:15 +00:00
|
|
|
#include "src/codegen/code-factory.h"
|
|
|
|
#include "src/codegen/code-stub-assembler.h"
|
2018-05-13 10:10:44 +00:00
|
|
|
#include "src/compiler/node.h"
|
|
|
|
#include "src/debug/debug.h"
|
2019-05-22 07:55:37 +00:00
|
|
|
#include "src/execution/isolate.h"
|
2019-05-20 08:54:18 +00:00
|
|
|
#include "src/objects/elements-kind.h"
|
2019-05-23 08:51:46 +00:00
|
|
|
#include "src/objects/objects-inl.h"
|
2018-05-13 10:10:44 +00:00
|
|
|
#include "src/objects/promise-inl.h"
|
2020-10-28 16:09:52 +00:00
|
|
|
#include "src/objects/torque-defined-classes-inl.h"
|
2019-05-21 06:38:38 +00:00
|
|
|
#include "src/strings/char-predicates.h"
|
2018-05-13 10:10:44 +00:00
|
|
|
#include "test/cctest/compiler/code-assembler-tester.h"
|
|
|
|
#include "test/cctest/compiler/function-tester.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2019-05-27 19:25:38 +00:00
|
|
|
class TestTorqueAssembler : public CodeStubAssembler {
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
public:
|
|
|
|
explicit TestTorqueAssembler(CodeAssemblerState* state)
|
2019-05-27 19:25:38 +00:00
|
|
|
: CodeStubAssembler(state) {}
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
};
|
|
|
|
|
2018-05-13 10:10:44 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
TEST(TestConstexpr1) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-13 10:10:44 +00:00
|
|
|
{
|
|
|
|
m.TestConstexpr1();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
2018-05-22 12:48:29 +00:00
|
|
|
ft.Call();
|
2018-05-13 10:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestConstexprIf) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-13 10:10:44 +00:00
|
|
|
{
|
|
|
|
m.TestConstexprIf();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
2018-05-22 12:48:29 +00:00
|
|
|
ft.Call();
|
2018-05-13 10:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestConstexprReturn) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-13 10:10:44 +00:00
|
|
|
{
|
|
|
|
m.TestConstexprReturn();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
2018-05-22 12:48:29 +00:00
|
|
|
ft.Call();
|
2018-05-13 10:10:44 +00:00
|
|
|
}
|
|
|
|
|
2018-05-13 14:24:08 +00:00
|
|
|
TEST(TestGotoLabel) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-13 14:24:08 +00:00
|
|
|
{ m.Return(m.TestGotoLabel()); }
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.CheckCall(ft.true_value());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestGotoLabelWithOneParameter) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-13 14:24:08 +00:00
|
|
|
{ m.Return(m.TestGotoLabelWithOneParameter()); }
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.CheckCall(ft.true_value());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestGotoLabelWithTwoParameters) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-13 14:24:08 +00:00
|
|
|
{ m.Return(m.TestGotoLabelWithTwoParameters()); }
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.CheckCall(ft.true_value());
|
|
|
|
}
|
|
|
|
|
2018-05-14 10:53:04 +00:00
|
|
|
TEST(TestPartiallyUnusedLabel) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-14 10:53:04 +00:00
|
|
|
{ m.Return(m.TestPartiallyUnusedLabel()); }
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.CheckCall(ft.true_value());
|
|
|
|
}
|
|
|
|
|
2018-05-16 09:45:07 +00:00
|
|
|
TEST(TestBuiltinSpecialization) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-16 09:45:07 +00:00
|
|
|
{
|
2020-04-28 12:27:43 +00:00
|
|
|
m.TestBuiltinSpecialization();
|
2018-05-16 09:45:07 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
2018-05-22 12:48:29 +00:00
|
|
|
ft.Call();
|
2018-05-16 09:45:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestMacroSpecialization) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-16 09:45:07 +00:00
|
|
|
{
|
|
|
|
m.TestMacroSpecialization();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
2018-05-22 12:48:29 +00:00
|
|
|
ft.Call();
|
2018-05-16 09:45:07 +00:00
|
|
|
}
|
|
|
|
|
2018-05-16 14:00:35 +00:00
|
|
|
TEST(TestFunctionPointers) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
const int kNumParams = 0;
|
|
|
|
CodeAssemblerTester asm_tester(isolate, kNumParams);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-16 14:00:35 +00:00
|
|
|
{
|
2020-09-30 17:40:39 +00:00
|
|
|
TNode<Context> context = m.UncheckedParameter<Context>(kNumParams + 2);
|
2018-05-16 14:00:35 +00:00
|
|
|
m.Return(m.TestFunctionPointers(context));
|
|
|
|
}
|
2018-07-03 12:02:05 +00:00
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
2018-05-16 14:00:35 +00:00
|
|
|
ft.CheckCall(ft.true_value());
|
|
|
|
}
|
|
|
|
|
2018-07-03 12:02:05 +00:00
|
|
|
TEST(TestTernaryOperator) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
const int kNumParams = 1;
|
2020-07-16 11:57:03 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-07-03 12:02:05 +00:00
|
|
|
{
|
2020-09-30 17:40:39 +00:00
|
|
|
TNode<Smi> arg = m.UncheckedParameter<Smi>(1);
|
2018-07-03 12:02:05 +00:00
|
|
|
m.Return(m.TestTernaryOperator(arg));
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
|
|
|
Handle<Object> result1 =
|
|
|
|
ft.Call(Handle<Smi>(Smi::FromInt(-5), isolate)).ToHandleChecked();
|
|
|
|
CHECK_EQ(-15, Handle<Smi>::cast(result1)->value());
|
|
|
|
Handle<Object> result2 =
|
|
|
|
ft.Call(Handle<Smi>(Smi::FromInt(3), isolate)).ToHandleChecked();
|
|
|
|
CHECK_EQ(103, Handle<Smi>::cast(result2)->value());
|
|
|
|
}
|
|
|
|
|
2018-05-22 12:48:29 +00:00
|
|
|
TEST(TestFunctionPointerToGeneric) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-22 12:48:29 +00:00
|
|
|
{
|
2020-04-28 12:27:43 +00:00
|
|
|
m.TestFunctionPointerToGeneric();
|
2018-05-22 12:48:29 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-05-29 14:18:39 +00:00
|
|
|
TEST(TestUnsafeCast) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-05-29 14:18:39 +00:00
|
|
|
{
|
2019-08-22 09:56:32 +00:00
|
|
|
TNode<Object> temp = m.SmiConstant(0);
|
|
|
|
TNode<Smi> n = m.SmiConstant(10);
|
2018-05-29 14:18:39 +00:00
|
|
|
m.Return(m.TestUnsafeCast(m.UncheckedCast<Context>(temp),
|
|
|
|
m.UncheckedCast<Number>(n)));
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.CheckCall(ft.true_value());
|
|
|
|
}
|
|
|
|
|
2018-06-05 08:49:05 +00:00
|
|
|
TEST(TestHexLiteral) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-06-05 08:49:05 +00:00
|
|
|
{
|
|
|
|
m.TestHexLiteral();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-07-13 08:50:22 +00:00
|
|
|
TEST(TestModuleConstBindings) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-07-13 08:50:22 +00:00
|
|
|
{
|
|
|
|
m.TestModuleConstBindings();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-07-17 06:39:07 +00:00
|
|
|
TEST(TestLocalConstBindings) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-07-17 06:39:07 +00:00
|
|
|
{
|
|
|
|
m.TestLocalConstBindings();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-07-27 10:32:14 +00:00
|
|
|
TEST(TestForLoop) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-07-27 10:32:14 +00:00
|
|
|
{
|
|
|
|
m.TestForLoop();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-08-07 21:57:19 +00:00
|
|
|
TEST(TestTypeswitch) {
|
2018-11-26 15:14:25 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
2018-08-07 21:57:19 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-08-07 21:57:19 +00:00
|
|
|
{
|
2018-11-26 15:14:25 +00:00
|
|
|
m.TestTypeswitch(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
2018-08-07 21:57:19 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-08-07 14:06:18 +00:00
|
|
|
TEST(TestGenericOverload) {
|
2018-11-26 15:14:25 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
2018-08-07 14:06:18 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-08-07 14:06:18 +00:00
|
|
|
{
|
2018-11-26 15:14:25 +00:00
|
|
|
m.TestGenericOverload(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
2018-08-07 14:06:18 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
2019-02-06 15:17:35 +00:00
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestEquality) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestEquality(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
2018-08-07 14:06:18 +00:00
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
[torque] disallow using logical operators in value contexts
This CL makes sure, that logical operators (||, &&) always have return
type never. Together with a check that never is never passed as a
function argument, this prevents faulty evaluation as in !(x || y).
Before, the logical operators had a behavior similar to
(bool labels Taken, NotTaken), with a fast exit if the left-hand side
allowed shor-circuit evaluation, but returning the right-hand side
otherwise. Since we want to allow existing (a || b || c) patterns in
the codebase, this requires weakening the restriction that the left-
and right-hand side need to have the same type. Now the possibilites
are:
bool, never
never, bool
never, never
bool, bool
constexpr bool, constexpr bool
Bug: v8:8137
Change-Id: I9576b337dc4008ac58b4625e77fef4e73bcdd6e3
Reviewed-on: https://chromium-review.googlesource.com/1215162
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55750}
2018-09-08 16:16:08 +00:00
|
|
|
TEST(TestLogicalOperators) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
[torque] disallow using logical operators in value contexts
This CL makes sure, that logical operators (||, &&) always have return
type never. Together with a check that never is never passed as a
function argument, this prevents faulty evaluation as in !(x || y).
Before, the logical operators had a behavior similar to
(bool labels Taken, NotTaken), with a fast exit if the left-hand side
allowed shor-circuit evaluation, but returning the right-hand side
otherwise. Since we want to allow existing (a || b || c) patterns in
the codebase, this requires weakening the restriction that the left-
and right-hand side need to have the same type. Now the possibilites
are:
bool, never
never, bool
never, never
bool, bool
constexpr bool, constexpr bool
Bug: v8:8137
Change-Id: I9576b337dc4008ac58b4625e77fef4e73bcdd6e3
Reviewed-on: https://chromium-review.googlesource.com/1215162
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55750}
2018-09-08 16:16:08 +00:00
|
|
|
{
|
|
|
|
m.TestLogicalOperators();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-10-08 13:50:46 +00:00
|
|
|
TEST(TestOtherwiseAndLabels) {
|
|
|
|
Isolate* isolate(CcTest::InitIsolateOnce());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-10-08 13:50:46 +00:00
|
|
|
{
|
|
|
|
m.TestOtherwiseWithCode1();
|
|
|
|
m.TestOtherwiseWithCode2();
|
|
|
|
m.TestOtherwiseWithCode3();
|
|
|
|
m.TestForwardLabel();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-10-31 13:00:51 +00:00
|
|
|
TEST(TestCatch1) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-10-31 13:00:51 +00:00
|
|
|
{
|
|
|
|
TNode<Smi> result =
|
|
|
|
m.TestCatch1(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
USE(result);
|
2019-08-23 12:40:12 +00:00
|
|
|
CSA_ASSERT(&m, m.TaggedEqual(result, m.SmiConstant(1)));
|
2018-10-31 13:00:51 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestCatch2) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-10-31 13:00:51 +00:00
|
|
|
{
|
|
|
|
TNode<Smi> result =
|
|
|
|
m.TestCatch2(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
USE(result);
|
2019-08-23 12:40:12 +00:00
|
|
|
CSA_ASSERT(&m, m.TaggedEqual(result, m.SmiConstant(2)));
|
2018-10-31 13:00:51 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestCatch3) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-10-31 13:00:51 +00:00
|
|
|
{
|
|
|
|
TNode<Smi> result =
|
|
|
|
m.TestCatch3(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
USE(result);
|
2019-08-23 12:40:12 +00:00
|
|
|
CSA_ASSERT(&m, m.TaggedEqual(result, m.SmiConstant(2)));
|
2018-10-31 13:00:51 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-11-02 12:40:31 +00:00
|
|
|
TEST(TestLookup) {
|
2018-11-26 15:14:25 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
2018-11-02 12:40:31 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, 0);
|
[torque] enable multiple inheritance from Torque-generated assemblers
This enables more seamless interop between Torque and CSA:
Since CodeStubAssembler can now inherit from the Torque base namespace,
macros defined in the base namespace can be used in CodeStubAssembler
macros, even without qualification.
At the same time, macros in the base namespace can refer to
CodeStubAssembler macros. The only new limitation is that types defined
in code-stub-assembler.h cannot be referenced in the signature of macros
defined in the base namespace, since this would produce a cyclic header
dependency. A work-around for this woud be to put such types (like int31
in this CL) into a separate header included by both. I (mis-)used
code-assembler.h for that.
Another side-effec is that types and enums defined in CodeStubAssembler
have to be accessed in a qualified way from Torque.
Other assemblers can now inherit from their Torque equivalent, so
porting macros into the corresponding Torque namespace doesn't require
any change to the existing use-sites.
To avoid C++ ambiguities, the Torque-generated assemblers must not define
anything also defined in Code(Stub)Assembler. This includes the type
aliases for TNode, PLabel, ...
My workaround is to qualify everything in the generated C++.
As a drive-by fix, I had to change the formatter to avoid a situation
where it doesn't compute a fixed point: putting a keyword at the
beginning of a line removes the '\s' in front of it, so I replaced that
with '\b'.
Bug: v8:7793
Change-Id: If3b9e9ad967a181b380a10d5673615606abd1041
Reviewed-on: https://chromium-review.googlesource.com/c/1341955
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57645}
2018-11-20 10:17:24 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2018-11-02 12:40:31 +00:00
|
|
|
{
|
2018-11-26 15:14:25 +00:00
|
|
|
m.TestQualifiedAccess(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
2018-11-02 12:40:31 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-12-07 16:29:49 +00:00
|
|
|
TEST(TestFrame1) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestFrame1(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
[torque] Implement methods and constructors for structs and classes
With the changes in this patch, it is now possible to add methods to
both Torque's class and struct types. As a special case, "constructor"
methods are used to initialize the values of classes and structs when
they are constructed.
The functionality in this patch includes:
- The refactoring of class- and struct-handling code to share field
and method declaration code between both.
- Addition of the "%Allocate" intrinsic that allocates raw bytes to be
allocated from the V8 GC's NewSpace heap as the basis for freshly
created, initialized class objects.
- An implementation of a CallMethodExpression AST node that enables
calling methods and constructors, including special handling of
passing through the "this" pointer for method calls on structs by
reference. The syntax for struct construction using "{}" remains as
before, but now calls the struct's matching constructor rather than
implicitly initializing the struct fields with the initialization
arguments. A new syntax for allocation classes is introduced: "new
ClassName{constructor_param1, constructor_param1, ...}", which
de-sugars to an %Allocate call followed by a call to the matching
constructor.
- class constructors can use the "super" keyword to initialize their
super class.
- If classes and struct do not have a constructor, Torque creates a
default constructor for them based on their field declarations,
where each field's initial value is assigned to a same-typed
parameter to the the default constructor. The default constructor's
parameters are in field-declaration order, and for derived classes,
the default constructor automatically uses a "super" initialization
call to initialize inherited fields.
- Class field declarations now automatically create ".field" and
".field=" operators that create CSA-compatible object accessors.
- Addition of a no-argument constructor for JSArrays that creates an
empty, PACKED_SMI_ELEMENTS JSArray using the machinery added
elsewhere in this patch.
Bug: v8:7793
Change-Id: I31ce5f4b444656ab999555d780aeeba605666bfa
Reviewed-on: https://chromium-review.googlesource.com/c/1392192
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58860}
2019-01-16 16:25:29 +00:00
|
|
|
TEST(TestNew) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestNew(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestStructConstructor) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestStructConstructor(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2019-02-05 12:39:44 +00:00
|
|
|
TEST(TestInternalClass) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestInternalClass(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2019-04-04 17:23:05 +00:00
|
|
|
TEST(TestNewFixedArrayFromSpread) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestNewFixedArrayFromSpread(
|
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2019-04-11 13:36:05 +00:00
|
|
|
TEST(TestReferences) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestReferences();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
[torque] Add user-defined Slice struct
This CL consists of several preparatory steps for slices in Torque. Above all, it introduces a user-defined struct, torque_internal::Slice<T>, that performs bounds checking and returns references to elements in arrays. To enable this, several smaller changes were also made:
- Constructors of internal classes such as torque_internal::Reference<T> now require a special 'Unsafe' argument, making it clear that there be dragons.
- Struct methods are now declared during finalization. This allows instances of generic structs to have methods referring to the same struct. Previously, methods would be declared before the instance had been fully registered, leading to errors during type resolution. Furthermore, such methods were declared in a temporary namespace, that would then erroneously escape and lead to use-after-free issues.
- Instances of TypeArgumentInference were not running in the correct (Torque) scopes, leading to type resolution errors.
- The chain of ContextualVariable::Scope for any given ContextualVariable (such as CurrentScope) can now be walked, simplifying debugging.
R=jgruber@chromium.org, tebbi@chromium.org
Bug: v8:7793
Change-Id: I36f808f63cc3ce441062dfc56f511f24f1e3121e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1758322
Commit-Queue: Georg Schmid <gsps@google.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63314}
2019-08-21 11:47:44 +00:00
|
|
|
TEST(TestSlices) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestSlices();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2019-08-29 15:30:47 +00:00
|
|
|
TEST(TestSliceEnumeration) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestSliceEnumeration(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2019-05-21 14:59:31 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2019-06-17 15:10:03 +00:00
|
|
|
TEST(TestLoadEliminationFixed) {
|
2019-06-04 14:19:40 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
2019-06-17 15:10:03 +00:00
|
|
|
m.TestLoadEliminationFixed(
|
2019-06-12 11:30:05 +00:00
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
asm_tester.GenerateCode();
|
|
|
|
}
|
|
|
|
|
2019-06-17 15:10:03 +00:00
|
|
|
TEST(TestLoadEliminationVariable) {
|
2019-06-12 11:30:05 +00:00
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
2019-06-17 15:10:03 +00:00
|
|
|
m.TestLoadEliminationVariable(
|
2019-06-04 14:19:40 +00:00
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
asm_tester.GenerateCode();
|
|
|
|
}
|
|
|
|
|
2019-06-17 08:18:27 +00:00
|
|
|
TEST(TestRedundantArrayElementCheck) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.Return(m.TestRedundantArrayElementCheck(
|
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context))));
|
|
|
|
}
|
|
|
|
asm_tester.GenerateCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestRedundantSmiCheck) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.Return(m.TestRedundantSmiCheck(
|
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context))));
|
|
|
|
}
|
|
|
|
asm_tester.GenerateCode();
|
|
|
|
}
|
|
|
|
|
[torque] Add Generic Structs
This CL introduces generic Torque structs. Generics are grounded early in the Torque compilation pipeline, meaning that every instantiation of a generic struct with concrete types will be turned into a distinct StructType.
As an example, consider a Tuple of types T1, T2:
struct Tuple<T1: type, T2: type> {
const fst: T1;
const snd: T2;
}
which can be manipulated using generic macros, such as
macro Swap<T1: type, T2: type>(tuple: Tuple<T1, T2>): Tuple<T2, T1> {
return Tuple<T2, T1>{fst: tuple.snd, snd: tuple.fst};
}
Currently there is no type inference for struct instantiation sites, so type arguments have to be provided explicitly:
const intptrAndSmi = Tuple<intptr, Smi>{fst: 1, snd: 2};
R=sigurds@chromium.org, tebbi@chromium.org
Change-Id: I43111561cbe53144db473dc844a478045644ef6c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1714868
Commit-Queue: Georg Schmid <gsps@google.com>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62878}
2019-07-23 14:55:01 +00:00
|
|
|
TEST(TestGenericStruct1) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestGenericStruct1();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestGenericStruct2) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
2019-08-01 16:41:26 +00:00
|
|
|
{ m.Return(m.TestGenericStruct2().snd.fst); }
|
[torque] Add Generic Structs
This CL introduces generic Torque structs. Generics are grounded early in the Torque compilation pipeline, meaning that every instantiation of a generic struct with concrete types will be turned into a distinct StructType.
As an example, consider a Tuple of types T1, T2:
struct Tuple<T1: type, T2: type> {
const fst: T1;
const snd: T2;
}
which can be manipulated using generic macros, such as
macro Swap<T1: type, T2: type>(tuple: Tuple<T1, T2>): Tuple<T2, T1> {
return Tuple<T2, T1>{fst: tuple.snd, snd: tuple.fst};
}
Currently there is no type inference for struct instantiation sites, so type arguments have to be provided explicitly:
const intptrAndSmi = Tuple<intptr, Smi>{fst: 1, snd: 2};
R=sigurds@chromium.org, tebbi@chromium.org
Change-Id: I43111561cbe53144db473dc844a478045644ef6c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1714868
Commit-Queue: Georg Schmid <gsps@google.com>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62878}
2019-07-23 14:55:01 +00:00
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2019-07-29 17:29:29 +00:00
|
|
|
TEST(TestBranchOnBoolOptimization) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestBranchOnBoolOptimization(
|
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context)),
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedParameter<Smi>(0));
|
2019-07-29 17:29:29 +00:00
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
asm_tester.GenerateCode();
|
|
|
|
}
|
|
|
|
|
2019-12-12 20:49:36 +00:00
|
|
|
TEST(TestBitFieldLoad) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
const int kNumParams = 5;
|
2020-07-16 11:57:03 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
|
2019-12-12 20:49:36 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
// Untag all of the parameters to get plain integer values.
|
|
|
|
TNode<Uint8T> val =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<Uint8T>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(1))));
|
2019-12-12 20:49:36 +00:00
|
|
|
TNode<BoolT> expected_a =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<BoolT>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(2))));
|
2019-12-12 20:49:36 +00:00
|
|
|
TNode<Uint16T> expected_b =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<Uint16T>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(3))));
|
2019-12-12 20:49:36 +00:00
|
|
|
TNode<Uint32T> expected_c =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<Uint32T>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(4))));
|
2019-12-12 20:49:36 +00:00
|
|
|
TNode<BoolT> expected_d =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<BoolT>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(5))));
|
2019-12-12 20:49:36 +00:00
|
|
|
|
|
|
|
// Call the Torque-defined macro, which verifies that reading each bitfield
|
|
|
|
// out of val yields the correct result.
|
|
|
|
m.TestBitFieldLoad(val, expected_a, expected_b, expected_c, expected_d);
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
|
|
|
|
|
|
|
// Test every possible bit combination for this 8-bit value.
|
|
|
|
for (int a = 0; a <= 1; ++a) {
|
|
|
|
for (int b = 0; b <= 7; ++b) {
|
|
|
|
for (int c = 0; c <= 7; ++c) {
|
|
|
|
for (int d = 0; d <= 1; ++d) {
|
|
|
|
int val = a | ((b & 7) << 1) | (c << 4) | (d << 7);
|
|
|
|
ft.Call(ft.Val(val), ft.Val(a), ft.Val(b), ft.Val(c), ft.Val(d));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestBitFieldStore) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
const int kNumParams = 1;
|
2020-09-28 09:19:50 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
|
2019-12-12 20:49:36 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
// Untag the parameters to get a plain integer value.
|
2020-09-30 17:40:39 +00:00
|
|
|
TNode<Uint8T> val =
|
|
|
|
m.UncheckedCast<Uint8T>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(1))));
|
2019-12-12 20:49:36 +00:00
|
|
|
|
|
|
|
m.TestBitFieldStore(val);
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
|
|
|
|
|
|
|
// Test every possible bit combination for this 8-bit value.
|
|
|
|
for (int i = 0; i < 256; ++i) {
|
|
|
|
ft.Call(ft.Val(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-22 17:05:44 +00:00
|
|
|
TEST(TestBitFieldInit) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
const int kNumParams = 4;
|
2020-07-16 11:57:03 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
|
2020-04-22 17:05:44 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
// Untag all of the parameters to get plain integer values.
|
|
|
|
TNode<BoolT> a =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<BoolT>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(1))));
|
2020-04-22 17:05:44 +00:00
|
|
|
TNode<Uint16T> b =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<Uint16T>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(2))));
|
2020-04-22 17:05:44 +00:00
|
|
|
TNode<Uint32T> c =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<Uint32T>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(3))));
|
2020-04-22 17:05:44 +00:00
|
|
|
TNode<BoolT> d =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<BoolT>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(4))));
|
2020-04-22 17:05:44 +00:00
|
|
|
|
|
|
|
// Call the Torque-defined macro, which verifies that reading each bitfield
|
|
|
|
// out of val yields the correct result.
|
|
|
|
m.TestBitFieldInit(a, b, c, d);
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
|
|
|
|
|
|
|
// Test every possible bit combination for this 8-bit value.
|
|
|
|
for (int a = 0; a <= 1; ++a) {
|
|
|
|
for (int b = 0; b <= 7; ++b) {
|
|
|
|
for (int c = 0; c <= 7; ++c) {
|
|
|
|
for (int d = 0; d <= 1; ++d) {
|
|
|
|
ft.Call(ft.Val(a), ft.Val(b), ft.Val(c), ft.Val(d));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-12 20:49:36 +00:00
|
|
|
TEST(TestBitFieldUintptrOps) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
const int kNumParams = 2;
|
2020-07-16 11:57:03 +00:00
|
|
|
CodeAssemblerTester asm_tester(isolate, kNumParams + 1); // Include receiver.
|
2019-12-12 20:49:36 +00:00
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
// Untag the parameters to get a plain integer value.
|
|
|
|
TNode<Uint32T> val2 =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<Uint32T>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(1))));
|
2019-12-12 20:49:36 +00:00
|
|
|
TNode<UintPtrT> val3 = m.UncheckedCast<UintPtrT>(
|
2020-09-30 17:40:39 +00:00
|
|
|
m.ChangeUint32ToWord(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(2)))));
|
2019-12-12 20:49:36 +00:00
|
|
|
|
|
|
|
m.TestBitFieldUintptrOps(val2, val3);
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
|
|
|
|
|
|
|
// Construct the expected test values.
|
|
|
|
int val2 = 3 | (61 << 5);
|
|
|
|
int val3 = 1 | (500 << 1) | (0x1cc << 10);
|
|
|
|
|
|
|
|
ft.Call(ft.Val(val2), ft.Val(val3));
|
|
|
|
}
|
|
|
|
|
2020-05-19 17:58:18 +00:00
|
|
|
TEST(TestBitFieldMultipleFlags) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
const int kNumParams = 3;
|
|
|
|
CodeAssemblerTester asm_tester(isolate, kNumParams);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
TNode<BoolT> a =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<BoolT>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(0))));
|
|
|
|
TNode<Int32T> b = m.SmiToInt32(m.Parameter<Smi>(1));
|
2020-05-19 17:58:18 +00:00
|
|
|
TNode<BoolT> c =
|
2020-09-30 17:40:39 +00:00
|
|
|
m.UncheckedCast<BoolT>(m.Unsigned(m.SmiToInt32(m.Parameter<Smi>(2))));
|
2020-05-19 17:58:18 +00:00
|
|
|
m.TestBitFieldMultipleFlags(a, b, c);
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
|
|
|
|
// No need to call it; we just checked StaticAsserts during compilation.
|
|
|
|
}
|
|
|
|
|
2019-12-19 08:55:02 +00:00
|
|
|
TEST(TestTestParentFrameArguments) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestParentFrameArguments(
|
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
asm_tester.GenerateCode();
|
|
|
|
}
|
|
|
|
|
2020-03-03 15:53:40 +00:00
|
|
|
TEST(TestFullyGeneratedClassFromCpp) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{ m.Return(m.TestFullyGeneratedClassFromCpp()); }
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
Handle<ExportedSubClass> result =
|
|
|
|
Handle<ExportedSubClass>::cast(ft.Call().ToHandleChecked());
|
|
|
|
CHECK_EQ(result->c_field(), 7);
|
|
|
|
CHECK_EQ(result->d_field(), 8);
|
2020-03-17 17:14:51 +00:00
|
|
|
CHECK_EQ(result->e_field(), 9);
|
2020-03-03 15:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestFullyGeneratedClassWithElements) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestFullyGeneratedClassWithElements();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2020-06-23 07:08:51 +00:00
|
|
|
TEST(TestGeneratedCastOperators) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
m.TestGeneratedCastOperators(
|
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2020-07-10 14:36:04 +00:00
|
|
|
TEST(TestNewPretenured) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
m.TestNewPretenured(m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2020-08-05 13:43:04 +00:00
|
|
|
TEST(TestWord8Phi) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
m.TestWord8Phi();
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2020-11-13 10:43:07 +00:00
|
|
|
TEST(TestOffHeapSlice) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
std::string data = "Hello World!";
|
|
|
|
{
|
|
|
|
m.TestOffHeapSlice(m.PointerConstant(const_cast<char*>(data.data())),
|
|
|
|
m.IntPtrConstant(data.size()));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2021-01-15 18:23:49 +00:00
|
|
|
TEST(TestCallMultiReturnBuiltin) {
|
|
|
|
CcTest::InitializeVM();
|
|
|
|
Isolate* isolate(CcTest::i_isolate());
|
|
|
|
i::HandleScope scope(isolate);
|
|
|
|
CodeAssemblerTester asm_tester(isolate, 1);
|
|
|
|
TestTorqueAssembler m(asm_tester.state());
|
|
|
|
{
|
|
|
|
Handle<Context> context =
|
|
|
|
Utils::OpenHandle(*v8::Isolate::GetCurrent()->GetCurrentContext());
|
|
|
|
m.TestCallMultiReturnBuiltin(
|
|
|
|
m.UncheckedCast<Context>(m.HeapConstant(context)));
|
|
|
|
m.Return(m.UndefinedConstant());
|
|
|
|
}
|
|
|
|
FunctionTester ft(asm_tester.GenerateCode(), 0);
|
|
|
|
ft.Call();
|
|
|
|
}
|
|
|
|
|
2018-05-13 10:10:44 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|