Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1358)

Unified Diff: test/cctest/compiler/test-run-machops.cc

Issue 1423923003: Removed the dependency of the test RunComputedCodeObject from RawMachineAssemblerTester. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-machops.cc
diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc
index c7dbfb85a9866452b9302ba5063ec4f5c0fd6c2e..ceab0b42e6332805b394647953bf63a95976f2e8 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -1,6 +1,6 @@
-// Copyright 2014 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.
+// Copyright 2014 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>
#include <functional>
@@ -9,6 +9,8 @@
#include "src/base/bits.h"
#include "src/base/utils/random-number-generator.h"
#include "src/codegen.h"
+#include "src/compiler/raw-machine-assembler.h"
+#include "src/simulator.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/codegen-tester.h"
#include "test/cctest/compiler/value-helper.h"
@@ -5505,25 +5507,101 @@ TEST(RunBitcastInt32ToFloat32) {
}
+Handle<Code> GenerateCode(RawMachineAssembler* r) {
titzer 2015/10/26 21:58:30 You shouldn't need to duplicate this code here. E.
ahaas 2015/10/27 00:13:39 Done.
+ Schedule* schedule = r->Export();
+ CallDescriptor* call_descriptor = r->call_descriptor();
+ Graph* graph = r->graph();
+ CompilationInfo info("testing", r->isolate(), r->zone());
+ MaybeHandle<Code> code =
+ Pipeline::GenerateCodeForTesting(&info, call_descriptor, graph, schedule);
+
+ return code.ToHandleChecked();
+}
+
+
+int32_t ExecuteCode(Handle<Code> code) {
titzer 2015/10/26 21:58:30 You shouldn't need to inline this code here. You c
ahaas 2015/10/27 00:13:39 Done.
+ typedef int32_t V8_CDECL FType();
+
+ FType* function = FUNCTION_CAST<FType*>(code->entry());
+
+
+#if USE_SIMULATOR && V8_TARGET_ARCH_ARM64
+ Simulator::CallArgument args[] = {Simulator::CallArgument::End()};
+ return CastReturnValue<int32_t>(CallSimulator(FUNCTION_ADDR(function), args));
+#elif USE_SIMULATOR && \
+ (V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_ARM || \
+ V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_PPC)
+ return CastReturnValue<int32_t>(CallSimulator(FUNCTION_ADDR(function)));
+#else
+ return function();
+#endif
+}
+
+
+int32_t ExecuteCode(Handle<Code> code, int32_t parameter) {
+ typedef int32_t V8_CDECL FType(int32_t);
+
+ FType* function = FUNCTION_CAST<FType*>(code->entry());
+
+#if USE_SIMULATOR && V8_TARGET_ARCH_ARM64
+ Simulator::CallArgument args[] = {Simulator::CallArgument(parameter),
+ Simulator::CallArgument::End()};
+ return CastReturnValue<int32_t>(CallSimulator(FUNCTION_ADDR(function), args));
+#elif USE_SIMULATOR && \
+ (V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_ARM || \
+ V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_PPC)
+ return CastReturnValue<int32_t>(CallSimulator(
+ FUNCTION_ADDR(function), ParameterTraits<int32_t>::Cast(parameter)));
+#else
+ return function(parameter);
+#endif
+}
+
+
TEST(RunComputedCodeObject) {
- RawMachineAssemblerTester<int32_t> a;
+ i::Isolate* main_isolate = CcTest::InitIsolateOnce();
+ i::HandleScope handle_scope(main_isolate);
+
+ i::Zone main_zone_a;
+ RawMachineAssembler a(
+ main_isolate, new (&main_zone_a) Graph(&main_zone_a),
+ Linkage::GetSimplifiedCDescriptor(
+ &main_zone_a, CSignature::New(&main_zone_a, kMachInt32)),
+ kMachPtr, InstructionSelector::SupportedMachineOperatorFlags());
+
a.Return(a.Int32Constant(33));
- CHECK_EQ(33, a.Call());
- RawMachineAssemblerTester<int32_t> b;
+ Handle<Code> code_a = GenerateCode(&a);
+ CHECK_EQ(33, ExecuteCode(code_a));
+
+ i::Zone main_zone_b;
+ RawMachineAssembler b(
+ main_isolate, new (&main_zone_b) Graph(&main_zone_b),
+ Linkage::GetSimplifiedCDescriptor(
+ &main_zone_b, CSignature::New(&main_zone_b, kMachInt32)),
+ kMachPtr, InstructionSelector::SupportedMachineOperatorFlags());
+
b.Return(b.Int32Constant(44));
- CHECK_EQ(44, b.Call());
- RawMachineAssemblerTester<int32_t> r(kMachInt32);
+ Handle<Code> code_b = GenerateCode(&b);
+ CHECK_EQ(44, ExecuteCode(code_b));
+
+ i::Zone main_zone_r;
+ RawMachineAssembler r(
+ main_isolate, new (&main_zone_r) Graph(&main_zone_r),
+ Linkage::GetSimplifiedCDescriptor(
+ &main_zone_r, CSignature::New(&main_zone_r, kMachInt32, kMachInt32)),
+ kMachPtr, InstructionSelector::SupportedMachineOperatorFlags());
+
RawMachineAssembler::Label tlabel;
RawMachineAssembler::Label flabel;
RawMachineAssembler::Label merge;
r.Branch(r.Parameter(0), &tlabel, &flabel);
r.Bind(&tlabel);
- Node* fa = r.HeapConstant(a.GetCode());
+ Node* fa = r.HeapConstant(code_a);
r.Goto(&merge);
r.Bind(&flabel);
- Node* fb = r.HeapConstant(b.GetCode());
+ Node* fb = r.HeapConstant(code_b);
r.Goto(&merge);
r.Bind(&merge);
Node* phi = r.Phi(kMachInt32, fa, fb);
@@ -5548,7 +5626,7 @@ TEST(RunComputedCodeObject) {
"c-call-as-code");
Node* call = r.AddNode(r.common()->Call(desc), phi);
r.Return(call);
-
- CHECK_EQ(33, r.Call(1));
- CHECK_EQ(44, r.Call(0));
+ Handle<Code> code_r = GenerateCode(&r);
+ CHECK_EQ(33, ExecuteCode(code_r, 1));
+ CHECK_EQ(44, ExecuteCode(code_r, 0));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698