diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2016-01-20 09:45:45 -0800 |
---|---|---|
committer | Ali Ijaz Sheikh <ofrobots@google.com> | 2016-01-21 16:53:58 -0800 |
commit | ef4170ea03a80b21b2d8a65ce432efaa370fe2fa (patch) | |
tree | e382b1b38b729cd8155b56b441c3a563914854a3 /deps/v8/test/cctest/compiler | |
parent | 5f6dfab832979999d2f806fc1a2f1c11a25b0f35 (diff) | |
download | node-new-ef4170ea03a80b21b2d8a65ce432efaa370fe2fa.tar.gz |
deps: upgrade to V8 4.8.271.17
Pick up V8 4.8 branch-head. This branch brings in @@isConcatSpreadable,
@@toPrimitive and ToLength ES6 changes. For full details see:
http://v8project.blogspot.de/2015/11/v8-release-48.html
https://github.com/v8/v8/commit/fa163e2
Ref: https://github.com/nodejs/node/pull/4399
PR-URL: https://github.com/nodejs/node/pull/4785
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/test/cctest/compiler')
43 files changed, 1787 insertions, 884 deletions
diff --git a/deps/v8/test/cctest/compiler/c-signature.h b/deps/v8/test/cctest/compiler/c-signature.h index 8eaf6325f2..5a72c551ab 100644 --- a/deps/v8/test/cctest/compiler/c-signature.h +++ b/deps/v8/test/cctest/compiler/c-signature.h @@ -13,7 +13,7 @@ namespace compiler { #define FOREACH_CTYPE_MACHINE_TYPE_MAPPING(V) \ V(void, kMachNone) \ - V(bool, kMachBool) \ + V(bool, kMachUint8) \ V(int8_t, kMachInt8) \ V(uint8_t, kMachUint8) \ V(int16_t, kMachInt16) \ @@ -159,8 +159,8 @@ typedef CSignature2<uint32_t, uint32_t, uint32_t> CSignature_u_uu; typedef CSignature2<float, float, float> CSignature_f_ff; typedef CSignature2<double, double, double> CSignature_d_dd; typedef CSignature2<Object*, Object*, Object*> CSignature_o_oo; -} -} -} // namespace v8::internal::compiler +} // namespace compiler +} // namespace internal +} // namespace v8 #endif // V8_COMPILER_C_SIGNATURE_H_ diff --git a/deps/v8/test/cctest/compiler/call-tester.h b/deps/v8/test/cctest/compiler/call-tester.h index 31a6d0f93b..e60f7172fa 100644 --- a/deps/v8/test/cctest/compiler/call-tester.h +++ b/deps/v8/test/cctest/compiler/call-tester.h @@ -5,10 +5,7 @@ #ifndef V8_CCTEST_COMPILER_CALL_TESTER_H_ #define V8_CCTEST_COMPILER_CALL_TESTER_H_ -#include "src/v8.h" - #include "src/simulator.h" - #include "test/cctest/compiler/c-signature.h" #if V8_TARGET_ARCH_IA32 @@ -162,6 +159,13 @@ class CallHelper { return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4); } + template <typename P1, typename P2, typename P3, typename P4, typename P5> + R Call(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { + typedef R V8_CDECL FType(P1, P2, P3, P4, P5); + csig_->VerifyParams<P1, P2, P3, P4, P5>(); + return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4, p5); + } + protected: CSignature* csig_; @@ -207,11 +211,20 @@ class CallHelper { Simulator::CallArgument::End()}; return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args)); } + template <typename F, typename P1, typename P2, typename P3, typename P4, + typename P5> + R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { + Simulator::CallArgument args[] = { + Simulator::CallArgument(p1), Simulator::CallArgument(p2), + Simulator::CallArgument(p3), Simulator::CallArgument(p4), + Simulator::CallArgument(p5), Simulator::CallArgument::End()}; + return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args)); + } #elif USE_SIMULATOR && (V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64) uintptr_t CallSimulator(byte* f, int64_t p1 = 0, int64_t p2 = 0, - int64_t p3 = 0, int64_t p4 = 0) { + int64_t p3 = 0, int64_t p4 = 0, int64_t p5 = 0) { Simulator* simulator = Simulator::current(isolate_); - return static_cast<uintptr_t>(simulator->Call(f, 4, p1, p2, p3, p4)); + return static_cast<uintptr_t>(simulator->Call(f, 5, p1, p2, p3, p4, p5)); } @@ -243,12 +256,20 @@ class CallHelper { ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3), ParameterTraits<P4>::Cast(p4))); } + template <typename F, typename P1, typename P2, typename P3, typename P4, + typename P5> + R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { + return CastReturnValue<R>(CallSimulator( + FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), + ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3), + ParameterTraits<P4>::Cast(p4), ParameterTraits<P5>::Cast(p5))); + } #elif USE_SIMULATOR && \ (V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_PPC) uintptr_t CallSimulator(byte* f, int32_t p1 = 0, int32_t p2 = 0, - int32_t p3 = 0, int32_t p4 = 0) { + int32_t p3 = 0, int32_t p4 = 0, int32_t p5 = 0) { Simulator* simulator = Simulator::current(isolate_); - return static_cast<uintptr_t>(simulator->Call(f, 4, p1, p2, p3, p4)); + return static_cast<uintptr_t>(simulator->Call(f, 5, p1, p2, p3, p4, p5)); } template <typename F> R DoCall(F* f) { @@ -278,6 +299,14 @@ class CallHelper { ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3), ParameterTraits<P4>::Cast(p4))); } + template <typename F, typename P1, typename P2, typename P3, typename P4, + typename P5> + R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { + return CastReturnValue<R>(CallSimulator( + FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), + ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3), + ParameterTraits<P4>::Cast(p4), ParameterTraits<P5>::Cast(p5))); + } #else template <typename F> R DoCall(F* f) { @@ -299,6 +328,11 @@ class CallHelper { R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { return f(p1, p2, p3, p4); } + template <typename F, typename P1, typename P2, typename P3, typename P4, + typename P5> + R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { + return f(p1, p2, p3, p4, p5); + } #endif Isolate* isolate_; diff --git a/deps/v8/test/cctest/compiler/codegen-tester.cc b/deps/v8/test/cctest/compiler/codegen-tester.cc index 98957c7f01..ba73822d32 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.cc +++ b/deps/v8/test/cctest/compiler/codegen-tester.cc @@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" - #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/value-helper.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(CompareWrapper) { // Who tests the testers? @@ -570,3 +569,146 @@ TEST(RunBinopTester) { FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, bt.call(-11.25, *i)); } } } + + +#if V8_TARGET_ARCH_64_BIT +// TODO(ahaas): run int64 tests on all platforms when supported. +TEST(RunBufferedRawMachineAssemblerTesterTester) { + { + BufferedRawMachineAssemblerTester<int64_t> m; + m.Return(m.Int64Constant(0x12500000000)); + CHECK_EQ(0x12500000000, m.Call()); + } + { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64); + m.Return(m.Parameter(0)); + FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, m.Call(*i)); } + } + { + BufferedRawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64); + m.Return(m.Int64Add(m.Parameter(0), m.Parameter(1))); + FOR_INT64_INPUTS(i) { + FOR_INT64_INPUTS(j) { + CHECK_EQ(*i + *j, m.Call(*i, *j)); + CHECK_EQ(*j + *i, m.Call(*j, *i)); + } + } + } + { + BufferedRawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64, + kMachInt64); + m.Return( + m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); + FOR_INT64_INPUTS(i) { + FOR_INT64_INPUTS(j) { + CHECK_EQ(*i + *i + *j, m.Call(*i, *i, *j)); + CHECK_EQ(*i + *j + *i, m.Call(*i, *j, *i)); + CHECK_EQ(*j + *i + *i, m.Call(*j, *i, *i)); + } + } + } + { + BufferedRawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64, + kMachInt64, kMachInt64); + m.Return(m.Int64Add( + m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)), + m.Parameter(3))); + FOR_INT64_INPUTS(i) { + FOR_INT64_INPUTS(j) { + CHECK_EQ(*i + *i + *i + *j, m.Call(*i, *i, *i, *j)); + CHECK_EQ(*i + *i + *j + *i, m.Call(*i, *i, *j, *i)); + CHECK_EQ(*i + *j + *i + *i, m.Call(*i, *j, *i, *i)); + CHECK_EQ(*j + *i + *i + *i, m.Call(*j, *i, *i, *i)); + } + } + } + { + BufferedRawMachineAssemblerTester<void> m; + int64_t result; + m.Store(MachineTypeForC<int64_t>(), m.PointerConstant(&result), + m.Int64Constant(0x12500000000), kNoWriteBarrier); + m.Return(m.Int32Constant(0)); + m.Call(); + CHECK_EQ(0x12500000000, result); + } + { + BufferedRawMachineAssemblerTester<void> m(kMachFloat64); + double result; + m.Store(MachineTypeForC<double>(), m.PointerConstant(&result), + m.Parameter(0), kNoWriteBarrier); + m.Return(m.Int32Constant(0)); + FOR_FLOAT64_INPUTS(i) { + m.Call(*i); + CheckDoubleEq(*i, result); + } + } + { + BufferedRawMachineAssemblerTester<void> m(kMachInt64, kMachInt64); + int64_t result; + m.Store(MachineTypeForC<int64_t>(), m.PointerConstant(&result), + m.Int64Add(m.Parameter(0), m.Parameter(1)), kNoWriteBarrier); + m.Return(m.Int32Constant(0)); + FOR_INT64_INPUTS(i) { + FOR_INT64_INPUTS(j) { + m.Call(*i, *j); + CHECK_EQ(*i + *j, result); + + m.Call(*j, *i); + CHECK_EQ(*j + *i, result); + } + } + } + { + BufferedRawMachineAssemblerTester<void> m(kMachInt64, kMachInt64, + kMachInt64); + int64_t result; + m.Store( + MachineTypeForC<int64_t>(), m.PointerConstant(&result), + m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)), + kNoWriteBarrier); + m.Return(m.Int32Constant(0)); + FOR_INT64_INPUTS(i) { + FOR_INT64_INPUTS(j) { + m.Call(*i, *i, *j); + CHECK_EQ(*i + *i + *j, result); + + m.Call(*i, *j, *i); + CHECK_EQ(*i + *j + *i, result); + + m.Call(*j, *i, *i); + CHECK_EQ(*j + *i + *i, result); + } + } + } + { + BufferedRawMachineAssemblerTester<void> m(kMachInt64, kMachInt64, + kMachInt64, kMachInt64); + int64_t result; + m.Store(MachineTypeForC<int64_t>(), m.PointerConstant(&result), + m.Int64Add(m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), + m.Parameter(2)), + m.Parameter(3)), + kNoWriteBarrier); + m.Return(m.Int32Constant(0)); + FOR_INT64_INPUTS(i) { + FOR_INT64_INPUTS(j) { + m.Call(*i, *i, *i, *j); + CHECK_EQ(*i + *i + *i + *j, result); + + m.Call(*i, *i, *j, *i); + CHECK_EQ(*i + *i + *j + *i, result); + + m.Call(*i, *j, *i, *i); + CHECK_EQ(*i + *j + *i + *i, result); + + m.Call(*j, *i, *i, *i); + CHECK_EQ(*j + *i + *i + *i, result); + } + } + } +} + +#endif +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/codegen-tester.h b/deps/v8/test/cctest/compiler/codegen-tester.h index 9ca1066ecd..55dbecdb9e 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.h +++ b/deps/v8/test/cctest/compiler/codegen-tester.h @@ -5,8 +5,6 @@ #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ -#include "src/v8.h" - #include "src/compiler/instruction-selector.h" #include "src/compiler/pipeline.h" #include "src/compiler/raw-machine-assembler.h" @@ -52,6 +50,11 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, void GenerateCode() { Generate(); } + Handle<Code> GetCode() { + Generate(); + return code_.ToHandleChecked(); + } + protected: virtual byte* Generate() { if (code_.is_null()) { @@ -70,6 +73,209 @@ class RawMachineAssemblerTester : public HandleAndZoneScope, }; +template <typename ReturnType> +class BufferedRawMachineAssemblerTester + : public RawMachineAssemblerTester<int32_t> { + public: + BufferedRawMachineAssemblerTester(MachineType p0 = kMachNone, + MachineType p1 = kMachNone, + MachineType p2 = kMachNone, + MachineType p3 = kMachNone) + : BufferedRawMachineAssemblerTester(ComputeParameterCount(p0, p1, p2, p3), + p0, p1, p2, p3) {} + + + // The BufferedRawMachineAssemblerTester does not pass parameters directly + // to the constructed IR graph. Instead it passes a pointer to the parameter + // to the IR graph, and adds Load nodes to the IR graph to load the + // parameters from memory. Thereby it is possible to pass 64 bit parameters + // to the IR graph. + Node* Parameter(size_t index) { + CHECK(index >= 0 && index < 4); + return parameter_nodes_[index]; + } + + + // The BufferedRawMachineAssemblerTester adds a Store node to the IR graph + // to store the graph's return value in memory. The memory address for the + // Store node is provided as a parameter. By storing the return value in + // memory it is possible to return 64 bit values. + void Return(Node* input) { + Store(MachineTypeForC<ReturnType>(), + RawMachineAssembler::Parameter(return_parameter_index_), input, + kNoWriteBarrier); + RawMachineAssembler::Return(Int32Constant(1234)); + } + + ReturnType Call() { + ReturnType return_value; + test_graph_signature_->VerifyParams(); + CallHelper<int32_t>::Call(reinterpret_cast<void*>(&return_value)); + return return_value; + } + + template <typename P0> + ReturnType Call(P0 p0) { + ReturnType return_value; + test_graph_signature_->VerifyParams<P0>(); + CallHelper<int32_t>::Call(reinterpret_cast<void*>(&p0), + reinterpret_cast<void*>(&return_value)); + return return_value; + } + + template <typename P0, typename P1> + ReturnType Call(P0 p0, P1 p1) { + ReturnType return_value; + test_graph_signature_->VerifyParams<P0, P1>(); + CallHelper<int32_t>::Call(reinterpret_cast<void*>(&p0), + reinterpret_cast<void*>(&p1), + reinterpret_cast<void*>(&return_value)); + return return_value; + } + + template <typename P0, typename P1, typename P2> + ReturnType Call(P0 p0, P1 p1, P2 p2) { + ReturnType return_value; + test_graph_signature_->VerifyParams<P0, P1, P2>(); + CallHelper<int32_t>::Call( + reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1), + reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&return_value)); + return return_value; + } + + template <typename P0, typename P1, typename P2, typename P3> + ReturnType Call(P0 p0, P1 p1, P2 p2, P3 p3) { + ReturnType return_value; + test_graph_signature_->VerifyParams<P0, P1, P2, P3>(); + CallHelper<int32_t>::Call( + reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1), + reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&p3), + reinterpret_cast<void*>(&return_value)); + return return_value; + } + + private: + BufferedRawMachineAssemblerTester(uint32_t return_parameter_index, + MachineType p0, MachineType p1, + MachineType p2, MachineType p3) + : RawMachineAssemblerTester<int32_t>( + kMachPtr, p0 == kMachNone ? kMachNone : kMachPtr, + p1 == kMachNone ? kMachNone : kMachPtr, + p2 == kMachNone ? kMachNone : kMachPtr, + p3 == kMachNone ? kMachNone : kMachPtr), + test_graph_signature_( + CSignature::New(main_zone(), kMachInt32, p0, p1, p2, p3)), + return_parameter_index_(return_parameter_index) { + parameter_nodes_[0] = + p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0)); + parameter_nodes_[1] = + p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1)); + parameter_nodes_[2] = + p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2)); + parameter_nodes_[3] = + p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3)); + } + + + static uint32_t ComputeParameterCount(MachineType p0, MachineType p1, + MachineType p2, MachineType p3) { + if (p0 == kMachNone) { + return 0; + } + if (p1 == kMachNone) { + return 1; + } + if (p2 == kMachNone) { + return 2; + } + if (p3 == kMachNone) { + return 3; + } + return 4; + } + + + CSignature* test_graph_signature_; + Node* parameter_nodes_[4]; + uint32_t return_parameter_index_; +}; + + +template <> +class BufferedRawMachineAssemblerTester<void> + : public RawMachineAssemblerTester<void> { + public: + BufferedRawMachineAssemblerTester(MachineType p0 = kMachNone, + MachineType p1 = kMachNone, + MachineType p2 = kMachNone, + MachineType p3 = kMachNone) + : RawMachineAssemblerTester<void>(p0 == kMachNone ? kMachNone : kMachPtr, + p1 == kMachNone ? kMachNone : kMachPtr, + p2 == kMachNone ? kMachNone : kMachPtr, + p3 == kMachNone ? kMachNone : kMachPtr), + test_graph_signature_( + CSignature::New(RawMachineAssemblerTester<void>::main_zone(), + kMachNone, p0, p1, p2, p3)) { + parameter_nodes_[0] = + p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0)); + parameter_nodes_[1] = + p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1)); + parameter_nodes_[2] = + p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2)); + parameter_nodes_[3] = + p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3)); + } + + + // The BufferedRawMachineAssemblerTester does not pass parameters directly + // to the constructed IR graph. Instead it passes a pointer to the parameter + // to the IR graph, and adds Load nodes to the IR graph to load the + // parameters from memory. Thereby it is possible to pass 64 bit parameters + // to the IR graph. + Node* Parameter(size_t index) { + CHECK(index >= 0 && index < 4); + return parameter_nodes_[index]; + } + + + void Call() { + test_graph_signature_->VerifyParams(); + CallHelper<void>::Call(); + } + + template <typename P0> + void Call(P0 p0) { + test_graph_signature_->VerifyParams<P0>(); + CallHelper<void>::Call(reinterpret_cast<void*>(&p0)); + } + + template <typename P0, typename P1> + void Call(P0 p0, P1 p1) { + test_graph_signature_->VerifyParams<P0, P1>(); + CallHelper<void>::Call(reinterpret_cast<void*>(&p0), + reinterpret_cast<void*>(&p1)); + } + + template <typename P0, typename P1, typename P2> + void Call(P0 p0, P1 p1, P2 p2) { + test_graph_signature_->VerifyParams<P0, P1, P2>(); + CallHelper<void>::Call(reinterpret_cast<void*>(&p0), + reinterpret_cast<void*>(&p1), + reinterpret_cast<void*>(&p2)); + } + + template <typename P0, typename P1, typename P2, typename P3> + void Call(P0 p0, P1 p1, P2 p2, P3 p3) { + test_graph_signature_->VerifyParams<P0, P1, P2, P3>(); + CallHelper<void>::Call( + reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1), + reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&p3)); + } + + private: + CSignature* test_graph_signature_; + Node* parameter_nodes_[4]; +}; static const bool USE_RESULT_BUFFER = true; static const bool USE_RETURN_REGISTER = false; static const int32_t CHECK_VALUE = 0x99BEEDCE; @@ -105,7 +311,8 @@ class BinopTester { void AddReturn(Node* val) { if (use_result_buffer) { - T->Store(rep, T->PointerConstant(&result), T->Int32Constant(0), val); + T->Store(rep, T->PointerConstant(&result), T->Int32Constant(0), val, + kNoWriteBarrier); T->Return(T->Int32Constant(CHECK_VALUE)); } else { T->Return(val); diff --git a/deps/v8/test/cctest/compiler/function-tester.h b/deps/v8/test/cctest/compiler/function-tester.h index c2b25e5547..8741808d82 100644 --- a/deps/v8/test/cctest/compiler/function-tester.h +++ b/deps/v8/test/cctest/compiler/function-tester.h @@ -5,9 +5,6 @@ #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ -#include "src/v8.h" -#include "test/cctest/cctest.h" - #include "src/ast-numbering.h" #include "src/compiler.h" #include "src/compiler/linkage.h" @@ -19,6 +16,7 @@ #include "src/parser.h" #include "src/rewriter.h" #include "src/scopes.h" +#include "test/cctest/cctest.h" namespace v8 { namespace internal { @@ -121,8 +119,8 @@ class FunctionTester : public InitializedHandleScope { } Handle<JSFunction> NewFunction(const char* source) { - return v8::Utils::OpenHandle( - *v8::Local<v8::Function>::Cast(CompileRun(source))); + return Handle<JSFunction>::cast(v8::Utils::OpenHandle( + *v8::Local<v8::Function>::Cast(CompileRun(source)))); } Handle<JSObject> NewObject(const char* source) { @@ -176,6 +174,7 @@ class FunctionTester : public InitializedHandleScope { Pipeline pipeline(&info); Handle<Code> code = pipeline.GenerateCode(); CHECK(!code.is_null()); + info.dependencies()->Commit(code); info.context()->native_context()->AddOptimizedCode(*code); function->ReplaceCode(*code); return function; @@ -212,8 +211,8 @@ class FunctionTester : public InitializedHandleScope { return function; } }; -} -} -} // namespace v8::internal::compiler +} // namespace compiler +} // namespace internal +} // namespace v8 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ diff --git a/deps/v8/test/cctest/compiler/graph-builder-tester.h b/deps/v8/test/cctest/compiler/graph-builder-tester.h index 077b71f17b..ea2c3ad139 100644 --- a/deps/v8/test/cctest/compiler/graph-builder-tester.h +++ b/deps/v8/test/cctest/compiler/graph-builder-tester.h @@ -5,15 +5,14 @@ #ifndef V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ #define V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ -#include "src/v8.h" -#include "test/cctest/cctest.h" - #include "src/compiler/common-operator.h" +#include "src/compiler/instruction-selector.h" #include "src/compiler/linkage.h" #include "src/compiler/machine-operator.h" #include "src/compiler/operator-properties.h" #include "src/compiler/pipeline.h" #include "src/compiler/simplified-operator.h" +#include "test/cctest/cctest.h" #include "test/cctest/compiler/call-tester.h" namespace v8 { @@ -25,7 +24,8 @@ class GraphAndBuilders { explicit GraphAndBuilders(Zone* zone) : main_graph_(new (zone) Graph(zone)), main_common_(zone), - main_machine_(zone), + main_machine_(zone, kMachPtr, + InstructionSelector::SupportedMachineOperatorFlags()), main_simplified_(zone) {} Graph* graph() const { return main_graph_; } @@ -227,6 +227,11 @@ class GraphBuilderTester : public HandleAndZoneScope, return MakeNode(op, value_input_count, value_inputs); } + Handle<Code> GetCode() { + Generate(); + return code_.ToHandleChecked(); + } + protected: Node* MakeNode(const Operator* op, int value_input_count, Node** value_inputs) { diff --git a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc index 7d7690bad6..1f4d87f18d 100644 --- a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc +++ b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/basic-block-profiler.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { typedef RawMachineAssembler::Label MLabel; @@ -108,3 +110,7 @@ TEST(ProfileLoop) { m.Expect(arraysize(expected), expected); } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-branch-combine.cc b/deps/v8/test/cctest/compiler/test-branch-combine.cc index 06d380a6a2..984c7130ba 100644 --- a/deps/v8/test/cctest/compiler/test-branch-combine.cc +++ b/deps/v8/test/cctest/compiler/test-branch-combine.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/value-helper.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { typedef RawMachineAssembler::Label MLabel; @@ -457,3 +459,7 @@ TEST(BranchCombineFloat64Compares) { } } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-changes-lowering.cc b/deps/v8/test/cctest/compiler/test-changes-lowering.cc index b6b48bdac4..028ac4b7c8 100644 --- a/deps/v8/test/cctest/compiler/test-changes-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-changes-lowering.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include <limits> #include "src/compiler/change-lowering.h" @@ -24,8 +27,9 @@ #include "test/cctest/compiler/graph-builder-tester.h" #include "test/cctest/compiler/value-helper.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { template <typename ReturnType> class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { @@ -34,7 +38,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { : GraphBuilderTester<ReturnType>(p0), javascript(this->zone()), jsgraph(this->isolate(), this->graph(), this->common(), &javascript, - this->machine()), + nullptr, this->machine()), function(Handle<JSFunction>::null()) {} JSOperatorBuilder javascript; @@ -283,3 +287,7 @@ TEST(RunChangeBitToBool) { CHECK_EQ(false_obj, result); } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-gap-resolver.cc b/deps/v8/test/cctest/compiler/test-gap-resolver.cc index a081ddb8fe..a0e1d6023b 100644 --- a/deps/v8/test/cctest/compiler/test-gap-resolver.cc +++ b/deps/v8/test/cctest/compiler/test-gap-resolver.cc @@ -2,13 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include "src/compiler/gap-resolver.h" #include "src/base/utils/random-number-generator.h" #include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { // The state of our move interpreter is the mapping of operands to values. Note // that the actual values don't really matter, all we care about is equality. @@ -32,13 +36,17 @@ class InterpreterState { private: struct Key { bool is_constant; - AllocatedOperand::AllocatedKind kind; + bool is_float; + LocationOperand::LocationKind kind; int index; bool operator<(const Key& other) const { if (this->is_constant != other.is_constant) { return this->is_constant; } + if (this->is_float != other.is_float) { + return this->is_float; + } if (this->kind != other.kind) { return this->kind < other.kind; } @@ -70,16 +78,24 @@ class InterpreterState { static Key KeyFor(const InstructionOperand& op) { bool is_constant = op.IsConstant(); - AllocatedOperand::AllocatedKind kind; + bool is_float = false; + LocationOperand::LocationKind kind; int index; if (!is_constant) { - index = AllocatedOperand::cast(op).index(); - kind = AllocatedOperand::cast(op).allocated_kind(); + if (op.IsRegister()) { + index = LocationOperand::cast(op).GetRegister().code(); + } else if (op.IsDoubleRegister()) { + index = LocationOperand::cast(op).GetDoubleRegister().code(); + } else { + index = LocationOperand::cast(op).index(); + } + is_float = IsFloatingPoint(LocationOperand::cast(op).machine_type()); + kind = LocationOperand::cast(op).location_kind(); } else { index = ConstantOperand::cast(op).virtual_register(); - kind = AllocatedOperand::REGISTER; + kind = LocationOperand::REGISTER; } - Key key = {is_constant, kind, index}; + Key key = {is_constant, is_float, kind, index}; return key; } @@ -90,7 +106,9 @@ class InterpreterState { return ConstantOperand(key.index); } return AllocatedOperand( - key.kind, InstructionSequence::DefaultRepresentation(), key.index); + key.kind, + v8::internal::compiler::InstructionSequence::DefaultRepresentation(), + key.index); } friend std::ostream& operator<<(std::ostream& os, @@ -101,7 +119,9 @@ class InterpreterState { InstructionOperand source = FromKey(it->first); InstructionOperand destination = FromKey(it->second); MoveOperands mo(source, destination); - PrintableMoveOperands pmo = {RegisterConfiguration::ArchDefault(), &mo}; + PrintableMoveOperands pmo = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), + &mo}; os << pmo; } return os; @@ -116,15 +136,15 @@ class MoveInterpreter : public GapResolver::Assembler { public: explicit MoveInterpreter(Zone* zone) : zone_(zone) {} - virtual void AssembleMove(InstructionOperand* source, - InstructionOperand* destination) override { + void AssembleMove(InstructionOperand* source, + InstructionOperand* destination) override { ParallelMove* moves = new (zone_) ParallelMove(zone_); moves->AddMove(*source, *destination); state_.ExecuteInParallel(moves); } - virtual void AssembleSwap(InstructionOperand* source, - InstructionOperand* destination) override { + void AssembleSwap(InstructionOperand* source, + InstructionOperand* destination) override { ParallelMove* moves = new (zone_) ParallelMove(zone_); moves->AddMove(*source, *destination); moves->AddMove(*destination, *source); @@ -182,18 +202,31 @@ class ParallelMoveCreator : public HandleAndZoneScope { } InstructionOperand CreateRandomOperand(bool is_source) { - int index = rng_->NextInt(6); + int index = rng_->NextInt(7); // destination can't be Constant. - switch (rng_->NextInt(is_source ? 5 : 4)) { + switch (rng_->NextInt(is_source ? 7 : 6)) { case 0: - return StackSlotOperand(RandomType(), index); + return AllocatedOperand(LocationOperand::STACK_SLOT, RandomType(), + index); case 1: - return DoubleStackSlotOperand(RandomDoubleType(), index); + return AllocatedOperand(LocationOperand::STACK_SLOT, RandomDoubleType(), + index); case 2: - return RegisterOperand(RandomType(), index); + return AllocatedOperand(LocationOperand::REGISTER, RandomType(), index); case 3: - return DoubleRegisterOperand(RandomDoubleType(), index); + return AllocatedOperand(LocationOperand::REGISTER, RandomDoubleType(), + index); case 4: + return ExplicitOperand( + LocationOperand::REGISTER, RandomType(), + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(1)); + case 5: + return ExplicitOperand( + LocationOperand::STACK_SLOT, RandomType(), + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(index)); + case 6: return ConstantOperand(index); } UNREACHABLE(); @@ -223,3 +256,7 @@ TEST(FuzzResolver) { } } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-graph-visualizer.cc b/deps/v8/test/cctest/compiler/test-graph-visualizer.cc index 19228fa2f0..9ce34cd64a 100644 --- a/deps/v8/test/cctest/compiler/test-graph-visualizer.cc +++ b/deps/v8/test/cctest/compiler/test-graph-visualizer.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" -#include "test/cctest/cctest.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/compiler/common-operator.h" #include "src/compiler/graph.h" @@ -16,9 +16,11 @@ #include "src/compiler/scheduler.h" #include "src/compiler/source-position.h" #include "src/compiler/verifier.h" +#include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { static Operator dummy_operator1(IrOpcode::kParameter, Operator::kNoWrite, "dummy", 1, 0, 0, 1, 0, 0); @@ -127,3 +129,7 @@ TEST(NodeNetworkOfDummiesReachableFromEnd) { SourcePositionTable table(&graph); os << AsJSON(graph, &table); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-instruction.cc b/deps/v8/test/cctest/compiler/test-instruction.cc index d3c4577588..53562953ee 100644 --- a/deps/v8/test/cctest/compiler/test-instruction.cc +++ b/deps/v8/test/cctest/compiler/test-instruction.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" -#include "test/cctest/cctest.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/compiler/code-generator.h" #include "src/compiler/common-operator.h" @@ -15,10 +15,11 @@ #include "src/compiler/operator.h" #include "src/compiler/schedule.h" #include "src/compiler/scheduler.h" -#include "src/lithium.h" +#include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { typedef v8::internal::compiler::Instruction TestInstr; typedef v8::internal::compiler::InstructionSequence TestInstrSeq; @@ -322,3 +323,7 @@ TEST(InstructionOperands) { } } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc index 9d5ff000b7..7559ecd16b 100644 --- a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc +++ b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/assembler.h" #include "src/compiler/js-graph.h" @@ -12,8 +13,9 @@ #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { class JSCacheTesterHelper { protected: @@ -39,7 +41,7 @@ class JSConstantCacheTester : public HandleAndZoneScope, JSConstantCacheTester() : JSCacheTesterHelper(main_isolate(), main_zone()), JSGraph(main_isolate(), &main_graph_, &main_common_, &main_javascript_, - &main_machine_) { + nullptr, &main_machine_) { main_graph_.SetStart(main_graph_.NewNode(common()->Start(0))); main_graph_.SetEnd( main_graph_.NewNode(common()->End(1), main_graph_.start())); @@ -473,3 +475,7 @@ TEST(JSGraph_GetCachedNodes_together) { CHECK(Contains(&nodes, constants[i])); } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc index 773d74170f..e2612e9ea8 100644 --- a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc +++ b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include "src/compiler/js-context-specialization.h" #include "src/compiler/js-graph.h" #include "src/compiler/js-operator.h" @@ -12,8 +15,9 @@ #include "test/cctest/compiler/function-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { class ContextSpecializationTester : public HandleAndZoneScope { public: @@ -23,7 +27,8 @@ class ContextSpecializationTester : public HandleAndZoneScope { javascript_(main_zone()), machine_(main_zone()), simplified_(main_zone()), - jsgraph_(main_isolate(), graph(), common(), &javascript_, &machine_), + jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_, + &machine_), reducer_(main_zone(), graph()), spec_(&reducer_, jsgraph(), MaybeHandle<Context>()) {} @@ -314,3 +319,7 @@ TEST(SpecializeJSFunction_ToConstant_uninit) { CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc index bac511dd2d..b22785207d 100644 --- a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc @@ -2,17 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + +#include "src/compilation-dependencies.h" #include "src/compiler/js-graph.h" #include "src/compiler/js-typed-lowering.h" #include "src/compiler/machine-operator.h" #include "src/compiler/node-properties.h" #include "src/compiler/opcodes.h" #include "src/compiler/operator-properties.h" +#include "src/compiler/simplified-operator.h" #include "src/compiler/typer.h" #include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { #ifndef TEST_WITH_STRONG #define TEST_WITH_STRONG(Name) \ @@ -37,6 +43,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { machine(main_zone()), simplified(main_zone()), common(main_zone()), + deps(main_isolate(), main_zone()), graph(main_zone()), typer(main_isolate(), &graph), context_node(NULL) { @@ -52,6 +59,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { MachineOperatorBuilder machine; SimplifiedOperatorBuilder simplified; CommonOperatorBuilder common; + CompilationDependencies deps; Graph graph; Typer typer; Node* context_node; @@ -85,10 +93,13 @@ class JSTypedLoweringTester : public HandleAndZoneScope { } Node* reduce(Node* node) { - JSGraph jsgraph(main_isolate(), &graph, &common, &javascript, &machine); + JSGraph jsgraph(main_isolate(), &graph, &common, &javascript, &simplified, + &machine); // TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(main_zone(), &graph); - JSTypedLowering reducer(&graph_reducer, &jsgraph, main_zone()); + JSTypedLowering reducer(&graph_reducer, &deps, + JSTypedLowering::kDeoptimizationEnabled, &jsgraph, + main_zone()); Reduction reduction = reducer.Reduce(node); if (reduction.Changed()) return reduction.replacement(); return node; @@ -219,10 +230,6 @@ static Type* kNumberTypes[] = { Type::OrderedNumber(), Type::PlainNumber(), Type::Number()}; -static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(), - Type::Number(), Type::String(), Type::Object()}; - - static Type* I32Type(bool is_signed) { return is_signed ? Type::Signed32() : Type::Unsigned32(); } @@ -380,11 +387,11 @@ class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { : JSTypedLoweringTester(), language_mode_(language_mode) { int i = 0; set(i++, javascript.BitwiseOr(language_mode_), true); - set(i++, machine.Word32Or(), true); + set(i++, simplified.NumberBitwiseOr(), true); set(i++, javascript.BitwiseXor(language_mode_), true); - set(i++, machine.Word32Xor(), true); + set(i++, simplified.NumberBitwiseXor(), true); set(i++, javascript.BitwiseAnd(language_mode_), true); - set(i++, machine.Word32And(), true); + set(i++, simplified.NumberBitwiseAnd(), true); } static const int kNumberOps = 6; const Operator* ops[kNumberOps]; @@ -542,8 +549,7 @@ TEST(JSToString1) { { // ToString(boolean) Node* r = R.ReduceUnop(op, Type::Boolean()); - // TODO(titzer): could be a branch - CHECK_EQ(IrOpcode::kJSToString, r->opcode()); + CHECK_EQ(IrOpcode::kSelect, r->opcode()); } { // ToString(number) @@ -571,8 +577,9 @@ TEST(JSToString_replacement) { for (size_t i = 0; i < arraysize(types); i++) { Node* n = R.Parameter(types[i]); - Node* c = R.graph.NewNode(R.javascript.ToString(), n, R.context(), - R.start(), R.start()); + Node* c = + R.graph.NewNode(R.javascript.ToString(), n, R.context(), + R.EmptyFrameState(R.context()), R.start(), R.start()); Node* effect_use = R.UseForEffect(c); Node* add = R.graph.NewNode(R.simplified.ReferenceEqual(Type::Any()), n, c); @@ -1261,3 +1268,7 @@ TEST_WITH_STRONG(Int32Comparisons) { } } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-jump-threading.cc b/deps/v8/test/cctest/compiler/test-jump-threading.cc index 9fa3c9f28a..00baca2c5b 100644 --- a/deps/v8/test/cctest/compiler/test-jump-threading.cc +++ b/deps/v8/test/cctest/compiler/test-jump-threading.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" -#include "test/cctest/cctest.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/compiler/instruction.h" #include "src/compiler/instruction-codes.h" #include "src/compiler/jump-threading.h" +#include "test/cctest/cctest.h" namespace v8 { namespace internal { @@ -59,14 +60,16 @@ class TestCode : public HandleAndZoneScope { Start(); sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); int index = static_cast<int>(sequence_.instructions().size()) - 1; - AddGapMove(index, RegisterOperand(kRepWord32, 13), - RegisterOperand(kRepWord32, 13)); + AddGapMove(index, + AllocatedOperand(LocationOperand::REGISTER, kRepWord32, 13), + AllocatedOperand(LocationOperand::REGISTER, kRepWord32, 13)); } void NonRedundantMoves() { Start(); sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); int index = static_cast<int>(sequence_.instructions().size()) - 1; - AddGapMove(index, ConstantOperand(11), RegisterOperand(kRepWord32, 11)); + AddGapMove(index, ConstantOperand(11), + AllocatedOperand(LocationOperand::REGISTER, kRepWord32, 11)); } void Other() { Start(); diff --git a/deps/v8/test/cctest/compiler/test-linkage.cc b/deps/v8/test/cctest/compiler/test-linkage.cc index 29da5890ea..2aaf8c766d 100644 --- a/deps/v8/test/cctest/compiler/test-linkage.cc +++ b/deps/v8/test/cctest/compiler/test-linkage.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/code-stubs.h" #include "src/compiler.h" @@ -19,8 +20,9 @@ #include "src/compiler/schedule.h" #include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { static Operator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite, "dummy", 0, 0, 0, 0, 0, 0); @@ -56,8 +58,9 @@ TEST(TestLinkageJSFunctionIncoming) { for (int i = 0; i < 3; i++) { HandleAndZoneScope handles; - Handle<JSFunction> function = v8::Utils::OpenHandle( - *v8::Handle<v8::Function>::Cast(CompileRun(sources[i]))); + Handle<JSFunction> function = + Handle<JSFunction>::cast(v8::Utils::OpenHandle( + *v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); ParseInfo parse_info(handles.main_zone(), function); CompilationInfo info(&parse_info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); @@ -111,3 +114,7 @@ TEST(TestLinkageRuntimeCall) { TEST(TestLinkageStubCall) { // TODO(titzer): test linkage creation for outgoing stub calls. } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-loop-analysis.cc b/deps/v8/test/cctest/compiler/test-loop-analysis.cc index 60e7657f2b..3862a647de 100644 --- a/deps/v8/test/cctest/compiler/test-loop-analysis.cc +++ b/deps/v8/test/cctest/compiler/test-loop-analysis.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/compiler/access-builder.h" #include "src/compiler/common-operator.h" @@ -20,8 +21,9 @@ #include "src/compiler/verifier.h" #include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { static Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0, 0, 1, 0, 0); @@ -39,7 +41,7 @@ class LoopFinderTester : HandleAndZoneScope { : isolate(main_isolate()), common(main_zone()), graph(main_zone()), - jsgraph(main_isolate(), &graph, &common, NULL, NULL), + jsgraph(main_isolate(), &graph, &common, nullptr, nullptr, nullptr), start(graph.NewNode(common.Start(1))), end(graph.NewNode(common.End(1), start)), p0(graph.NewNode(common.Parameter(0), start)), @@ -1012,3 +1014,7 @@ TEST(LaManyNested_64) { RunManyNestedLoops_i(64); } TEST(LaPhiTangle) { LoopFinderTester t; } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc b/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc index b59f181f5e..e1af1626e1 100644 --- a/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc +++ b/deps/v8/test/cctest/compiler/test-loop-assignment-analysis.cc @@ -2,14 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include "src/compiler/ast-loop-assignment-analyzer.h" #include "src/parser.h" #include "src/rewriter.h" #include "src/scopes.h" #include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { namespace { const int kBufferSize = 1024; @@ -59,7 +63,7 @@ struct TestHelper : public HandleAndZoneScope { } } }; -} +} // namespace TEST(SimpleLoop1) { @@ -293,3 +297,7 @@ TEST(NestedLoops3c) { f.CheckLoopAssignedCount(5, "z"); f.CheckLoopAssignedCount(0, "w"); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc b/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc index c02e7e5751..ca49369592 100644 --- a/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc +++ b/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "test/cctest/cctest.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/base/utils/random-number-generator.h" #include "src/codegen.h" @@ -10,10 +11,12 @@ #include "src/compiler/machine-operator-reducer.h" #include "src/compiler/operator-properties.h" #include "src/compiler/typer.h" +#include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { template <typename T> const Operator* NewConstantOperator(CommonOperatorBuilder* common, @@ -61,7 +64,7 @@ class ReducerTester : public HandleAndZoneScope { graph(main_zone()), javascript(main_zone()), typer(isolate, &graph), - jsgraph(isolate, &graph, &common, &javascript, &machine), + jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine), maxuint32(Constant<int32_t>(kMaxUInt32)) { Node* s = graph.NewNode(common.Start(num_parameters)); graph.SetStart(s); @@ -748,3 +751,7 @@ TEST(ReduceLoadStore) { // TODO(titzer): test MachineOperatorReducer for Float64Mul // TODO(titzer): test MachineOperatorReducer for Float64Div // TODO(titzer): test MachineOperatorReducer for Float64Mod + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-multiple-return.cc b/deps/v8/test/cctest/compiler/test-multiple-return.cc new file mode 100644 index 0000000000..00fcc5f814 --- /dev/null +++ b/deps/v8/test/cctest/compiler/test-multiple-return.cc @@ -0,0 +1,121 @@ +// 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. + +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + +#include <cmath> +#include <functional> +#include <limits> + +#include "src/assembler.h" +#include "src/base/bits.h" +#include "src/base/utils/random-number-generator.h" +#include "src/codegen.h" +#include "src/compiler.h" +#include "src/compiler/linkage.h" +#include "src/macro-assembler.h" +#include "test/cctest/cctest.h" +#include "test/cctest/compiler/codegen-tester.h" +#include "test/cctest/compiler/value-helper.h" + +namespace v8 { +namespace internal { +namespace compiler { + +namespace { + +CallDescriptor* GetCallDescriptor(Zone* zone, int return_count, + int param_count) { + MachineSignature::Builder msig(zone, return_count, param_count); + LocationSignature::Builder locations(zone, return_count, param_count); + const RegisterConfiguration* config = + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN); + + // Add return location(s). + DCHECK(return_count <= config->num_allocatable_general_registers()); + for (int i = 0; i < return_count; i++) { + msig.AddReturn(compiler::kMachInt32); + locations.AddReturn( + LinkageLocation::ForRegister(config->allocatable_general_codes()[i])); + } + + // Add register and/or stack parameter(s). + DCHECK(param_count <= config->num_allocatable_general_registers()); + for (int i = 0; i < param_count; i++) { + msig.AddParam(compiler::kMachInt32); + locations.AddParam( + LinkageLocation::ForRegister(config->allocatable_general_codes()[i])); + } + + const RegList kCalleeSaveRegisters = 0; + const RegList kCalleeSaveFPRegisters = 0; + + // The target for WASM calls is always a code object. + MachineType target_type = compiler::kMachAnyTagged; + LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); + return new (zone) CallDescriptor( // -- + CallDescriptor::kCallCodeObject, // kind + target_type, // target MachineType + target_loc, // target location + msig.Build(), // machine_sig + locations.Build(), // location_sig + 0, // js_parameter_count + compiler::Operator::kNoProperties, // properties + kCalleeSaveRegisters, // callee-saved registers + kCalleeSaveFPRegisters, // callee-saved fp regs + CallDescriptor::kNoFlags, // flags + "c-call"); +} +} // namespace + + +TEST(ReturnThreeValues) { + Zone zone; + CallDescriptor* desc = GetCallDescriptor(&zone, 3, 2); + HandleAndZoneScope handles; + RawMachineAssembler m(handles.main_isolate(), + new (handles.main_zone()) Graph(handles.main_zone()), + desc, kMachPtr, + InstructionSelector::SupportedMachineOperatorFlags()); + + Node* p0 = m.Parameter(0); + Node* p1 = m.Parameter(1); + Node* add = m.Int32Add(p0, p1); + Node* sub = m.Int32Sub(p0, p1); + Node* mul = m.Int32Mul(p0, p1); + m.Return(add, sub, mul); + + CompilationInfo info("testing", handles.main_isolate(), handles.main_zone()); + Handle<Code> code = + Pipeline::GenerateCodeForTesting(&info, desc, m.graph(), m.Export()); +#ifdef ENABLE_DISASSEMBLER + if (FLAG_print_code) { + OFStream os(stdout); + code->Disassemble("three_value", os); + } +#endif + + RawMachineAssemblerTester<int32_t> mt; + Node* a = mt.Int32Constant(123); + Node* b = mt.Int32Constant(456); + Node* ret3 = mt.AddNode(mt.common()->Call(desc), mt.HeapConstant(code), a, b); + Node* x = mt.AddNode(mt.common()->Projection(0), ret3); + Node* y = mt.AddNode(mt.common()->Projection(1), ret3); + Node* z = mt.AddNode(mt.common()->Projection(2), ret3); + Node* ret = mt.Int32Add(mt.Int32Add(x, y), z); + mt.Return(ret); +#ifdef ENABLE_DISASSEMBLER + Handle<Code> code2 = mt.GetCode(); + if (FLAG_print_code) { + OFStream os(stdout); + code2->Disassemble("three_value_call", os); + } +#endif + CHECK_EQ((123 + 456) + (123 - 456) + (123 * 456), mt.Call()); +} + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-node.cc b/deps/v8/test/cctest/compiler/test-node.cc index 8ac38274b6..fcd6b74c4b 100644 --- a/deps/v8/test/cctest/compiler/test-node.cc +++ b/deps/v8/test/cctest/compiler/test-node.cc @@ -2,17 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <functional> +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS -#include "src/v8.h" -#include "test/cctest/cctest.h" +#include <functional> #include "src/compiler/graph.h" #include "src/compiler/node.h" #include "src/compiler/operator.h" +#include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { #define NONE reinterpret_cast<Node*>(1) @@ -784,3 +786,7 @@ TEST(AppendAndTrim) { CHECK_USES(last, NONE); } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-operator.cc b/deps/v8/test/cctest/compiler/test-operator.cc index 0ac33637da..7d2dfdd469 100644 --- a/deps/v8/test/cctest/compiler/test-operator.cc +++ b/deps/v8/test/cctest/compiler/test-operator.cc @@ -2,15 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <sstream> +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS -#include "src/v8.h" +#include <sstream> #include "src/compiler/operator.h" #include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { #define NONE Operator::kNoProperties #define FOLD Operator::kFoldable @@ -281,3 +283,7 @@ TEST(Operator_CountsOrder) { CHECK_EQ(55, op.EffectOutputCount()); CHECK_EQ(66, op.ControlOutputCount()); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-osr.cc b/deps/v8/test/cctest/compiler/test-osr.cc index 356cbd24a7..7cc8fa6338 100644 --- a/deps/v8/test/cctest/compiler/test-osr.cc +++ b/deps/v8/test/cctest/compiler/test-osr.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include "src/codegen.h" #include "src/compiler/all-nodes.h" #include "src/compiler/common-operator.h" @@ -13,8 +16,9 @@ #include "src/compiler/osr.h" #include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { // TODO(titzer): move this method to a common testing place. @@ -48,7 +52,7 @@ class OsrDeconstructorTester : public HandleAndZoneScope { : isolate(main_isolate()), common(main_zone()), graph(main_zone()), - jsgraph(main_isolate(), &graph, &common, NULL, NULL), + jsgraph(main_isolate(), &graph, &common, nullptr, nullptr, nullptr), start(graph.NewNode(common.Start(1))), p0(graph.NewNode(common.Parameter(0), start)), end(graph.NewNode(common.End(1), start)), @@ -563,3 +567,7 @@ TEST(Deconstruct_osr_nested3) { // depends on the copy of the outer loop0. CheckInputs(new_ret, new_loop0_phi, T.graph.start(), new_loop0_exit); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-pipeline.cc b/deps/v8/test/cctest/compiler/test-pipeline.cc index b14e823ee7..c00fa6a331 100644 --- a/deps/v8/test/cctest/compiler/test-pipeline.cc +++ b/deps/v8/test/cctest/compiler/test-pipeline.cc @@ -2,20 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" -#include "test/cctest/cctest.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/compiler.h" #include "src/compiler/pipeline.h" #include "src/handles.h" #include "src/parser.h" +#include "test/cctest/cctest.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { static void RunPipeline(Zone* zone, const char* source) { - Handle<JSFunction> function = v8::Utils::OpenHandle( - *v8::Handle<v8::Function>::Cast(CompileRun(source))); + Handle<JSFunction> function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( + *v8::Local<v8::Function>::Cast(CompileRun(source)))); ParseInfo parse_info(zone, function); CHECK(Compiler::ParseAndAnalyze(&parse_info)); CompilationInfo info(&parse_info); @@ -39,3 +41,7 @@ TEST(PipelineGeneric) { FLAG_turbo_types = false; RunPipeline(handles.main_zone(), "(function(a,b) { return a + b; })"); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-representation-change.cc b/deps/v8/test/cctest/compiler/test-representation-change.cc index 913808f8bc..616c3736e1 100644 --- a/deps/v8/test/cctest/compiler/test-representation-change.cc +++ b/deps/v8/test/cctest/compiler/test-representation-change.cc @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include <limits> -#include "src/v8.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" @@ -13,10 +15,7 @@ #include "src/compiler/node-matchers.h" #include "src/compiler/representation-change.h" -using namespace v8::internal; -using namespace v8::internal::compiler; - -namespace v8 { // for friendiness. +namespace v8 { namespace internal { namespace compiler { @@ -27,8 +26,8 @@ class RepresentationChangerTester : public HandleAndZoneScope, : GraphAndBuilders(main_zone()), javascript_(main_zone()), jsgraph_(main_isolate(), main_graph_, &main_common_, &javascript_, - &main_machine_), - changer_(&jsgraph_, &main_simplified_, main_isolate()) { + &main_simplified_, &main_machine_), + changer_(&jsgraph_, main_isolate()) { Node* s = graph()->NewNode(common()->Start(num_parameters)); graph()->SetStart(s); } @@ -100,9 +99,6 @@ class RepresentationChangerTester : public HandleAndZoneScope, CHECK_EQ(n, c); } }; -} // namespace compiler -} // namespace internal -} // namespace v8 static const MachineType all_reps[] = {kRepBit, kRepWord32, kRepWord64, @@ -551,3 +547,7 @@ TEST(TypeErrors) { } } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc index 06cb2f754f..cadd436385 100644 --- a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc +++ b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <utility> +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS -#include "src/v8.h" +#include <utility> #include "src/compiler/pipeline.h" #include "src/execution.h" @@ -87,9 +88,12 @@ class BytecodeGraphTester { Handle<JSFunction> GetFunction() { CompileRun(script_); - Local<Function> api_function = - Local<Function>::Cast(CcTest::global()->Get(v8_str(kFunctionName))); - Handle<JSFunction> function = v8::Utils::OpenHandle(*api_function); + Local<Function> api_function = Local<Function>::Cast( + CcTest::global() + ->Get(CcTest::isolate()->GetCurrentContext(), v8_str(kFunctionName)) + .ToLocalChecked()); + Handle<JSFunction> function = + Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function)); CHECK(function->shared()->HasBytecodeArray()); ParseInfo parse_info(zone_, function); @@ -108,13 +112,6 @@ class BytecodeGraphTester { DISALLOW_COPY_AND_ASSIGN(BytecodeGraphTester); }; -} // namespace compiler -} // namespace internal -} // namespace v8 - - -using namespace v8::internal; -using namespace v8::internal::compiler; template <int N> struct ExpectedSnippet { @@ -256,3 +253,7 @@ TEST(BytecodeGraphBuilderTwoParameterTests) { CHECK(return_value->SameValue(*snippets[i].return_value())); } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-deopt.cc b/deps/v8/test/cctest/compiler/test-run-deopt.cc index 7d1ae4f471..458fcbb423 100644 --- a/deps/v8/test/cctest/compiler/test-run-deopt.cc +++ b/deps/v8/test/cctest/compiler/test-run-deopt.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/frames-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { static void IsOptimized(const v8::FunctionCallbackInfo<v8::Value>& args) { JavaScriptFrameIterator it(CcTest::i_isolate()); @@ -22,7 +24,10 @@ static void InstallIsOptimizedHelper(v8::Isolate* isolate) { v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate, IsOptimized); - context->Global()->Set(v8_str("IsOptimized"), t->GetFunction()); + CHECK(context->Global() + ->Set(context, v8_str("IsOptimized"), + t->GetFunction(context).ToLocalChecked()) + .FromJust()); } @@ -113,3 +118,7 @@ TEST(DeoptTrivial) { T.CheckCall(T.Val(1)); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-inlining.cc b/deps/v8/test/cctest/compiler/test-run-inlining.cc index 05fb6ad46d..9e82d550b1 100644 --- a/deps/v8/test/cctest/compiler/test-run-inlining.cc +++ b/deps/v8/test/cctest/compiler/test-run-inlining.cc @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "src/frames-inl.h" #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { namespace { @@ -30,7 +32,11 @@ void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { } List<JSFunction*> functions(2); topmost->GetFunctions(&functions); - CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(), functions.length()); + CHECK_EQ(args[0] + ->ToInt32(args.GetIsolate()->GetCurrentContext()) + .ToLocalChecked() + ->Value(), + functions.length()); } @@ -38,7 +44,10 @@ void InstallAssertInlineCountHelper(v8::Isolate* isolate) { v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate, AssertInlineCount); - context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); + CHECK(context->Global() + ->Set(context, v8_str("AssertInlineCount"), + t->GetFunction(context).ToLocalChecked()) + .FromJust()); } @@ -595,3 +604,7 @@ TEST(InlineMutuallyRecursive) { InstallAssertInlineCountHelper(CcTest::isolate()); T.CheckCall(T.Val(42), T.Val(1)); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-intrinsics.cc b/deps/v8/test/cctest/compiler/test-run-intrinsics.cc index e92d520a42..fd2b3e6d16 100644 --- a/deps/v8/test/cctest/compiler/test-run-intrinsics.cc +++ b/deps/v8/test/cctest/compiler/test-run-intrinsics.cc @@ -2,18 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { + uint32_t flags = CompilationInfo::kInliningEnabled; -TEST(CallFunction) { - FunctionTester T("(function(a,b) { return %_CallFunction(a, 1, 2, 3, b); })", - flags); +TEST(Call) { + FunctionTester T("(function(a,b) { return %_Call(b, a, 1, 2, 3); })", flags); CompileRun("function f(a,b,c) { return a + b + c + this.d; }"); T.CheckCall(T.Val(129), T.NewObject("({d:123})"), T.NewObject("f")); @@ -320,3 +322,7 @@ TEST(ValueOf) { T.CheckCall(T.Val(123), T.Val(123)); T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-jsbranches.cc b/deps/v8/test/cctest/compiler/test-run-jsbranches.cc index 5a7bdb9b4a..577a6d1dad 100644 --- a/deps/v8/test/cctest/compiler/test-run-jsbranches.cc +++ b/deps/v8/test/cctest/compiler/test-run-jsbranches.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(Conditional) { FunctionTester T("(function(a) { return a ? 23 : 42; })"); @@ -382,3 +384,7 @@ TEST(EmptyFor) { T.CheckCall(T.Val(8126.1), T.Val(0.0), T.Val(8126.1)); T.CheckCall(T.Val(1123.1), T.Val(0.0), T.Val(1123.1)); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-jscalls.cc b/deps/v8/test/cctest/compiler/test-run-jscalls.cc index 621c1c339f..2688c622e1 100644 --- a/deps/v8/test/cctest/compiler/test-run-jscalls.cc +++ b/deps/v8/test/cctest/compiler/test-run-jscalls.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(SimpleCall) { FunctionTester T("(function(foo,a) { return foo(a); })"); @@ -141,16 +143,6 @@ TEST(RuntimeCallCPP2) { } -TEST(RuntimeCallJS) { - FLAG_allow_natives_syntax = true; - FunctionTester T("(function(a) { return %to_number_fun(a); })"); - - T.CheckCall(T.Val(23), T.Val(23), T.undefined()); - T.CheckCall(T.Val(4.2), T.Val(4.2), T.undefined()); - T.CheckCall(T.Val(1), T.true_value(), T.undefined()); -} - - TEST(RuntimeCallInline) { FLAG_allow_natives_syntax = true; FunctionTester T("(function(a) { return %_IsSpecObject(a); })"); @@ -225,7 +217,9 @@ TEST(ContextLoadedFromActivation) { i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); jsfun->set_code(T.function->code()); jsfun->set_shared(T.function->shared()); - context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); + CHECK(context->Global() + ->Set(context, v8_str("foo"), v8::Utils::CallableToLocal(jsfun)) + .FromJust()); CompileRun("var x = 24;"); ExpectInt32("foo();", 24); } @@ -247,7 +241,13 @@ TEST(BuiltinLoadedFromActivation) { i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); jsfun->set_code(T.function->code()); jsfun->set_shared(T.function->shared()); - context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); + CHECK(context->Global() + ->Set(context, v8_str("foo"), v8::Utils::CallableToLocal(jsfun)) + .FromJust()); CompileRun("var x = 24;"); ExpectObject("foo()", context->Global()); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-jsexceptions.cc b/deps/v8/test/cctest/compiler/test-run-jsexceptions.cc index 2ba8fdfcc8..5c56b036ef 100644 --- a/deps/v8/test/cctest/compiler/test-run-jsexceptions.cc +++ b/deps/v8/test/cctest/compiler/test-run-jsexceptions.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(Throw) { FunctionTester T("(function(a,b) { if (a) { throw b; } else { return b; }})"); @@ -26,18 +28,19 @@ TEST(ThrowMessagePosition) { " throw 4; \n" "}) "; FunctionTester T(src); - v8::Handle<v8::Message> message; + v8::Local<v8::Message> message; + v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); message = T.CheckThrowsReturnMessage(T.Val(1), T.undefined()); - CHECK_EQ(2, message->GetLineNumber()); + CHECK_EQ(2, message->GetLineNumber(context).FromMaybe(-1)); CHECK_EQ(40, message->GetStartPosition()); message = T.CheckThrowsReturnMessage(T.Val(2), T.undefined()); - CHECK_EQ(3, message->GetLineNumber()); + CHECK_EQ(3, message->GetLineNumber(context).FromMaybe(-1)); CHECK_EQ(67, message->GetStartPosition()); message = T.CheckThrowsReturnMessage(T.Val(3), T.undefined()); - CHECK_EQ(4, message->GetLineNumber()); + CHECK_EQ(4, message->GetLineNumber(context).FromMaybe(-1)); CHECK_EQ(95, message->GetStartPosition()); } @@ -48,13 +51,15 @@ TEST(ThrowMessageDirectly) { " if (a) { throw b; } else { throw new Error(b); }" "})"; FunctionTester T(src); - v8::Handle<v8::Message> message; + v8::Local<v8::Message> message; + v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); + v8::Maybe<bool> t = v8::Just(true); message = T.CheckThrowsReturnMessage(T.false_value(), T.Val("Wat?")); - CHECK(message->Get()->Equals(v8_str("Uncaught Error: Wat?"))); + CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Error: Wat?"))); message = T.CheckThrowsReturnMessage(T.true_value(), T.Val("Kaboom!")); - CHECK(message->Get()->Equals(v8_str("Uncaught Kaboom!"))); + CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Kaboom!"))); } @@ -69,13 +74,15 @@ TEST(ThrowMessageIndirectly) { " }" "})"; FunctionTester T(src); - v8::Handle<v8::Message> message; + v8::Local<v8::Message> message; + v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); + v8::Maybe<bool> t = v8::Just(true); message = T.CheckThrowsReturnMessage(T.false_value(), T.Val("Wat?")); - CHECK(message->Get()->Equals(v8_str("Uncaught Error: Wat?"))); + CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Error: Wat?"))); message = T.CheckThrowsReturnMessage(T.true_value(), T.Val("Kaboom!")); - CHECK(message->Get()->Equals(v8_str("Uncaught Kaboom!"))); + CHECK(t == message->Get()->Equals(context, v8_str("Uncaught Kaboom!"))); } @@ -272,3 +279,7 @@ TEST(DeoptFinallyReThrow) { T.CheckThrows(T.NewObject("new Error"), T.Val(1)); #endif } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-jsobjects.cc b/deps/v8/test/cctest/compiler/test-run-jsobjects.cc index 242de4dbf7..5b0fd39283 100644 --- a/deps/v8/test/cctest/compiler/test-run-jsobjects.cc +++ b/deps/v8/test/cctest/compiler/test-run-jsobjects.cc @@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(ArgumentsMapped) { FunctionTester T("(function(a) { return arguments; })"); @@ -45,3 +49,7 @@ TEST(ArgumentsRest) { Handle<Object> length = JSObject::GetProperty(arguments, l).ToHandleChecked(); CHECK_EQ(3, length->Number()); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-jsops.cc b/deps/v8/test/cctest/compiler/test-run-jsops.cc index 56ac31cbc9..ff18613b10 100644 --- a/deps/v8/test/cctest/compiler/test-run-jsops.cc +++ b/deps/v8/test/cctest/compiler/test-run-jsops.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(BinopAdd) { FunctionTester T("(function(a,b) { return a + b; })"); @@ -539,3 +541,7 @@ TEST(ClassLiteral) { T.CheckCall(T.Val(65), T.Val(23), T.Val(42)); T.CheckCall(T.Val("ab"), T.Val("a"), T.Val("b")); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-machops.cc b/deps/v8/test/cctest/compiler/test-run-machops.cc index 078b8c25cd..038fe241eb 100644 --- a/deps/v8/test/cctest/compiler/test-run-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-machops.cc @@ -1,6 +1,9 @@ -// 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. + +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include <cmath> #include <functional> @@ -11,14 +14,18 @@ #include "src/codegen.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" +#include "test/cctest/compiler/graph-builder-tester.h" #include "test/cctest/compiler/value-helper.h" using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; + +namespace v8 { +namespace internal { +namespace compiler { typedef RawMachineAssembler::Label MLabel; + TEST(RunInt32Add) { RawMachineAssemblerTester<int32_t> m; Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); @@ -27,6 +34,278 @@ TEST(RunInt32Add) { } +TEST(RunWord32Ctz) { + BufferedRawMachineAssemblerTester<int32_t> m(kMachUint32); + if (!m.machine()->Word32Ctz().IsSupported()) { + // We can only test the operator if it exists on the testing platform. + return; + } + m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0))); + + CHECK_EQ(32, m.Call(uint32_t(0x00000000))); + CHECK_EQ(31, m.Call(uint32_t(0x80000000))); + CHECK_EQ(30, m.Call(uint32_t(0x40000000))); + CHECK_EQ(29, m.Call(uint32_t(0x20000000))); + CHECK_EQ(28, m.Call(uint32_t(0x10000000))); + CHECK_EQ(27, m.Call(uint32_t(0xa8000000))); + CHECK_EQ(26, m.Call(uint32_t(0xf4000000))); + CHECK_EQ(25, m.Call(uint32_t(0x62000000))); + CHECK_EQ(24, m.Call(uint32_t(0x91000000))); + CHECK_EQ(23, m.Call(uint32_t(0xcd800000))); + CHECK_EQ(22, m.Call(uint32_t(0x09400000))); + CHECK_EQ(21, m.Call(uint32_t(0xaf200000))); + CHECK_EQ(20, m.Call(uint32_t(0xac100000))); + CHECK_EQ(19, m.Call(uint32_t(0xe0b80000))); + CHECK_EQ(18, m.Call(uint32_t(0x9ce40000))); + CHECK_EQ(17, m.Call(uint32_t(0xc7920000))); + CHECK_EQ(16, m.Call(uint32_t(0xb8f10000))); + CHECK_EQ(15, m.Call(uint32_t(0x3b9f8000))); + CHECK_EQ(14, m.Call(uint32_t(0xdb4c4000))); + CHECK_EQ(13, m.Call(uint32_t(0xe9a32000))); + CHECK_EQ(12, m.Call(uint32_t(0xfca61000))); + CHECK_EQ(11, m.Call(uint32_t(0x6c8a7800))); + CHECK_EQ(10, m.Call(uint32_t(0x8ce5a400))); + CHECK_EQ(9, m.Call(uint32_t(0xcb7d0200))); + CHECK_EQ(8, m.Call(uint32_t(0xcb4dc100))); + CHECK_EQ(7, m.Call(uint32_t(0xdfbec580))); + CHECK_EQ(6, m.Call(uint32_t(0x27a9db40))); + CHECK_EQ(5, m.Call(uint32_t(0xde3bcb20))); + CHECK_EQ(4, m.Call(uint32_t(0xd7e8a610))); + CHECK_EQ(3, m.Call(uint32_t(0x9afdbc88))); + CHECK_EQ(2, m.Call(uint32_t(0x9afdbc84))); + CHECK_EQ(1, m.Call(uint32_t(0x9afdbc82))); + CHECK_EQ(0, m.Call(uint32_t(0x9afdbc81))); +} + + +TEST(RunWord32Clz) { + BufferedRawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return(m.Word32Clz(m.Parameter(0))); + + CHECK_EQ(0, m.Call(uint32_t(0x80001000))); + CHECK_EQ(1, m.Call(uint32_t(0x40000500))); + CHECK_EQ(2, m.Call(uint32_t(0x20000300))); + CHECK_EQ(3, m.Call(uint32_t(0x10000003))); + CHECK_EQ(4, m.Call(uint32_t(0x08050000))); + CHECK_EQ(5, m.Call(uint32_t(0x04006000))); + CHECK_EQ(6, m.Call(uint32_t(0x02000000))); + CHECK_EQ(7, m.Call(uint32_t(0x010000a0))); + CHECK_EQ(8, m.Call(uint32_t(0x00800c00))); + CHECK_EQ(9, m.Call(uint32_t(0x00400000))); + CHECK_EQ(10, m.Call(uint32_t(0x0020000d))); + CHECK_EQ(11, m.Call(uint32_t(0x00100f00))); + CHECK_EQ(12, m.Call(uint32_t(0x00080000))); + CHECK_EQ(13, m.Call(uint32_t(0x00041000))); + CHECK_EQ(14, m.Call(uint32_t(0x00020020))); + CHECK_EQ(15, m.Call(uint32_t(0x00010300))); + CHECK_EQ(16, m.Call(uint32_t(0x00008040))); + CHECK_EQ(17, m.Call(uint32_t(0x00004005))); + CHECK_EQ(18, m.Call(uint32_t(0x00002050))); + CHECK_EQ(19, m.Call(uint32_t(0x00001700))); + CHECK_EQ(20, m.Call(uint32_t(0x00000870))); + CHECK_EQ(21, m.Call(uint32_t(0x00000405))); + CHECK_EQ(22, m.Call(uint32_t(0x00000203))); + CHECK_EQ(23, m.Call(uint32_t(0x00000101))); + CHECK_EQ(24, m.Call(uint32_t(0x00000089))); + CHECK_EQ(25, m.Call(uint32_t(0x00000041))); + CHECK_EQ(26, m.Call(uint32_t(0x00000022))); + CHECK_EQ(27, m.Call(uint32_t(0x00000013))); + CHECK_EQ(28, m.Call(uint32_t(0x00000008))); + CHECK_EQ(29, m.Call(uint32_t(0x00000004))); + CHECK_EQ(30, m.Call(uint32_t(0x00000002))); + CHECK_EQ(31, m.Call(uint32_t(0x00000001))); + CHECK_EQ(32, m.Call(uint32_t(0x00000000))); +} + + +TEST(RunWord32Popcnt) { + BufferedRawMachineAssemblerTester<int32_t> m(kMachUint32); + if (!m.machine()->Word32Popcnt().IsSupported()) { + // We can only test the operator if it exists on the testing platform. + return; + } + m.Return(m.AddNode(m.machine()->Word32Popcnt().op(), m.Parameter(0))); + + CHECK_EQ(0, m.Call(uint32_t(0x00000000))); + CHECK_EQ(1, m.Call(uint32_t(0x00000001))); + CHECK_EQ(1, m.Call(uint32_t(0x80000000))); + CHECK_EQ(32, m.Call(uint32_t(0xffffffff))); + CHECK_EQ(6, m.Call(uint32_t(0x000dc100))); + CHECK_EQ(9, m.Call(uint32_t(0xe00dc100))); + CHECK_EQ(11, m.Call(uint32_t(0xe00dc103))); + CHECK_EQ(9, m.Call(uint32_t(0x000dc107))); +} + + +#if V8_TARGET_ARCH_64_BIT +TEST(RunWord64Clz) { + BufferedRawMachineAssemblerTester<int32_t> m(kMachUint64); + m.Return(m.Word64Clz(m.Parameter(0))); + + CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000))); + CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000))); + CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000))); + CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000))); + CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000))); + CHECK_EQ(5, m.Call(uint64_t(0x0400600000000000))); + CHECK_EQ(6, m.Call(uint64_t(0x0200000000000000))); + CHECK_EQ(7, m.Call(uint64_t(0x010000a000000000))); + CHECK_EQ(8, m.Call(uint64_t(0x00800c0000000000))); + CHECK_EQ(9, m.Call(uint64_t(0x0040000000000000))); + CHECK_EQ(10, m.Call(uint64_t(0x0020000d00000000))); + CHECK_EQ(11, m.Call(uint64_t(0x00100f0000000000))); + CHECK_EQ(12, m.Call(uint64_t(0x0008000000000000))); + CHECK_EQ(13, m.Call(uint64_t(0x0004100000000000))); + CHECK_EQ(14, m.Call(uint64_t(0x0002002000000000))); + CHECK_EQ(15, m.Call(uint64_t(0x0001030000000000))); + CHECK_EQ(16, m.Call(uint64_t(0x0000804000000000))); + CHECK_EQ(17, m.Call(uint64_t(0x0000400500000000))); + CHECK_EQ(18, m.Call(uint64_t(0x0000205000000000))); + CHECK_EQ(19, m.Call(uint64_t(0x0000170000000000))); + CHECK_EQ(20, m.Call(uint64_t(0x0000087000000000))); + CHECK_EQ(21, m.Call(uint64_t(0x0000040500000000))); + CHECK_EQ(22, m.Call(uint64_t(0x0000020300000000))); + CHECK_EQ(23, m.Call(uint64_t(0x0000010100000000))); + CHECK_EQ(24, m.Call(uint64_t(0x0000008900000000))); + CHECK_EQ(25, m.Call(uint64_t(0x0000004100000000))); + CHECK_EQ(26, m.Call(uint64_t(0x0000002200000000))); + CHECK_EQ(27, m.Call(uint64_t(0x0000001300000000))); + CHECK_EQ(28, m.Call(uint64_t(0x0000000800000000))); + CHECK_EQ(29, m.Call(uint64_t(0x0000000400000000))); + CHECK_EQ(30, m.Call(uint64_t(0x0000000200000000))); + CHECK_EQ(31, m.Call(uint64_t(0x0000000100000000))); + CHECK_EQ(32, m.Call(uint64_t(0x0000000080001000))); + CHECK_EQ(33, m.Call(uint64_t(0x0000000040000500))); + CHECK_EQ(34, m.Call(uint64_t(0x0000000020000300))); + CHECK_EQ(35, m.Call(uint64_t(0x0000000010000003))); + CHECK_EQ(36, m.Call(uint64_t(0x0000000008050000))); + CHECK_EQ(37, m.Call(uint64_t(0x0000000004006000))); + CHECK_EQ(38, m.Call(uint64_t(0x0000000002000000))); + CHECK_EQ(39, m.Call(uint64_t(0x00000000010000a0))); + CHECK_EQ(40, m.Call(uint64_t(0x0000000000800c00))); + CHECK_EQ(41, m.Call(uint64_t(0x0000000000400000))); + CHECK_EQ(42, m.Call(uint64_t(0x000000000020000d))); + CHECK_EQ(43, m.Call(uint64_t(0x0000000000100f00))); + CHECK_EQ(44, m.Call(uint64_t(0x0000000000080000))); + CHECK_EQ(45, m.Call(uint64_t(0x0000000000041000))); + CHECK_EQ(46, m.Call(uint64_t(0x0000000000020020))); + CHECK_EQ(47, m.Call(uint64_t(0x0000000000010300))); + CHECK_EQ(48, m.Call(uint64_t(0x0000000000008040))); + CHECK_EQ(49, m.Call(uint64_t(0x0000000000004005))); + CHECK_EQ(50, m.Call(uint64_t(0x0000000000002050))); + CHECK_EQ(51, m.Call(uint64_t(0x0000000000001700))); + CHECK_EQ(52, m.Call(uint64_t(0x0000000000000870))); + CHECK_EQ(53, m.Call(uint64_t(0x0000000000000405))); + CHECK_EQ(54, m.Call(uint64_t(0x0000000000000203))); + CHECK_EQ(55, m.Call(uint64_t(0x0000000000000101))); + CHECK_EQ(56, m.Call(uint64_t(0x0000000000000089))); + CHECK_EQ(57, m.Call(uint64_t(0x0000000000000041))); + CHECK_EQ(58, m.Call(uint64_t(0x0000000000000022))); + CHECK_EQ(59, m.Call(uint64_t(0x0000000000000013))); + CHECK_EQ(60, m.Call(uint64_t(0x0000000000000008))); + CHECK_EQ(61, m.Call(uint64_t(0x0000000000000004))); + CHECK_EQ(62, m.Call(uint64_t(0x0000000000000002))); + CHECK_EQ(63, m.Call(uint64_t(0x0000000000000001))); + CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000))); +} + + +TEST(RunWord64Ctz) { + RawMachineAssemblerTester<int32_t> m(kMachUint64); + if (!m.machine()->Word64Ctz().IsSupported()) { + return; + } + + m.Return(m.AddNode(m.machine()->Word64Ctz().op(), m.Parameter(0))); + + CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000))); + CHECK_EQ(63, m.Call(uint64_t(0x8000000000000000))); + CHECK_EQ(62, m.Call(uint64_t(0x4000000000000000))); + CHECK_EQ(61, m.Call(uint64_t(0x2000000000000000))); + CHECK_EQ(60, m.Call(uint64_t(0x1000000000000000))); + CHECK_EQ(59, m.Call(uint64_t(0xa800000000000000))); + CHECK_EQ(58, m.Call(uint64_t(0xf400000000000000))); + CHECK_EQ(57, m.Call(uint64_t(0x6200000000000000))); + CHECK_EQ(56, m.Call(uint64_t(0x9100000000000000))); + CHECK_EQ(55, m.Call(uint64_t(0xcd80000000000000))); + CHECK_EQ(54, m.Call(uint64_t(0x0940000000000000))); + CHECK_EQ(53, m.Call(uint64_t(0xaf20000000000000))); + CHECK_EQ(52, m.Call(uint64_t(0xac10000000000000))); + CHECK_EQ(51, m.Call(uint64_t(0xe0b8000000000000))); + CHECK_EQ(50, m.Call(uint64_t(0x9ce4000000000000))); + CHECK_EQ(49, m.Call(uint64_t(0xc792000000000000))); + CHECK_EQ(48, m.Call(uint64_t(0xb8f1000000000000))); + CHECK_EQ(47, m.Call(uint64_t(0x3b9f800000000000))); + CHECK_EQ(46, m.Call(uint64_t(0xdb4c400000000000))); + CHECK_EQ(45, m.Call(uint64_t(0xe9a3200000000000))); + CHECK_EQ(44, m.Call(uint64_t(0xfca6100000000000))); + CHECK_EQ(43, m.Call(uint64_t(0x6c8a780000000000))); + CHECK_EQ(42, m.Call(uint64_t(0x8ce5a40000000000))); + CHECK_EQ(41, m.Call(uint64_t(0xcb7d020000000000))); + CHECK_EQ(40, m.Call(uint64_t(0xcb4dc10000000000))); + CHECK_EQ(39, m.Call(uint64_t(0xdfbec58000000000))); + CHECK_EQ(38, m.Call(uint64_t(0x27a9db4000000000))); + CHECK_EQ(37, m.Call(uint64_t(0xde3bcb2000000000))); + CHECK_EQ(36, m.Call(uint64_t(0xd7e8a61000000000))); + CHECK_EQ(35, m.Call(uint64_t(0x9afdbc8800000000))); + CHECK_EQ(34, m.Call(uint64_t(0x9afdbc8400000000))); + CHECK_EQ(33, m.Call(uint64_t(0x9afdbc8200000000))); + CHECK_EQ(32, m.Call(uint64_t(0x9afdbc8100000000))); + CHECK_EQ(31, m.Call(uint64_t(0x0000000080000000))); + CHECK_EQ(30, m.Call(uint64_t(0x0000000040000000))); + CHECK_EQ(29, m.Call(uint64_t(0x0000000020000000))); + CHECK_EQ(28, m.Call(uint64_t(0x0000000010000000))); + CHECK_EQ(27, m.Call(uint64_t(0x00000000a8000000))); + CHECK_EQ(26, m.Call(uint64_t(0x00000000f4000000))); + CHECK_EQ(25, m.Call(uint64_t(0x0000000062000000))); + CHECK_EQ(24, m.Call(uint64_t(0x0000000091000000))); + CHECK_EQ(23, m.Call(uint64_t(0x00000000cd800000))); + CHECK_EQ(22, m.Call(uint64_t(0x0000000009400000))); + CHECK_EQ(21, m.Call(uint64_t(0x00000000af200000))); + CHECK_EQ(20, m.Call(uint64_t(0x00000000ac100000))); + CHECK_EQ(19, m.Call(uint64_t(0x00000000e0b80000))); + CHECK_EQ(18, m.Call(uint64_t(0x000000009ce40000))); + CHECK_EQ(17, m.Call(uint64_t(0x00000000c7920000))); + CHECK_EQ(16, m.Call(uint64_t(0x00000000b8f10000))); + CHECK_EQ(15, m.Call(uint64_t(0x000000003b9f8000))); + CHECK_EQ(14, m.Call(uint64_t(0x00000000db4c4000))); + CHECK_EQ(13, m.Call(uint64_t(0x00000000e9a32000))); + CHECK_EQ(12, m.Call(uint64_t(0x00000000fca61000))); + CHECK_EQ(11, m.Call(uint64_t(0x000000006c8a7800))); + CHECK_EQ(10, m.Call(uint64_t(0x000000008ce5a400))); + CHECK_EQ(9, m.Call(uint64_t(0x00000000cb7d0200))); + CHECK_EQ(8, m.Call(uint64_t(0x00000000cb4dc100))); + CHECK_EQ(7, m.Call(uint64_t(0x00000000dfbec580))); + CHECK_EQ(6, m.Call(uint64_t(0x0000000027a9db40))); + CHECK_EQ(5, m.Call(uint64_t(0x00000000de3bcb20))); + CHECK_EQ(4, m.Call(uint64_t(0x00000000d7e8a610))); + CHECK_EQ(3, m.Call(uint64_t(0x000000009afdbc88))); + CHECK_EQ(2, m.Call(uint64_t(0x000000009afdbc84))); + CHECK_EQ(1, m.Call(uint64_t(0x000000009afdbc82))); + CHECK_EQ(0, m.Call(uint64_t(0x000000009afdbc81))); +} + + +TEST(RunWord64Popcnt) { + BufferedRawMachineAssemblerTester<int32_t> m(kMachUint64); + if (!m.machine()->Word64Popcnt().IsSupported()) { + return; + } + + m.Return(m.AddNode(m.machine()->Word64Popcnt().op(), m.Parameter(0))); + + CHECK_EQ(0, m.Call(uint64_t(0x0000000000000000))); + CHECK_EQ(1, m.Call(uint64_t(0x0000000000000001))); + CHECK_EQ(1, m.Call(uint64_t(0x8000000000000000))); + CHECK_EQ(64, m.Call(uint64_t(0xffffffffffffffff))); + CHECK_EQ(12, m.Call(uint64_t(0x000dc100000dc100))); + CHECK_EQ(18, m.Call(uint64_t(0xe00dc100e00dc100))); + CHECK_EQ(22, m.Call(uint64_t(0xe00dc103e00dc103))); + CHECK_EQ(18, m.Call(uint64_t(0x000dc107000dc107))); +} +#endif // V8_TARGET_ARCH_64_BIT + + static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { switch (index) { case 0: @@ -682,8 +961,8 @@ TEST(RunLoadStoreFloat32Offset) { // generate load [#base + #index] Node* load = m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset)); - m.Store(kMachFloat32, m.PointerConstant(to), m.IntPtrConstant(offset), - load); + m.Store(kMachFloat32, m.PointerConstant(to), m.IntPtrConstant(offset), load, + kNoWriteBarrier); m.Return(m.Int32Constant(magic)); FOR_FLOAT32_INPUTS(j) { @@ -709,8 +988,8 @@ TEST(RunLoadStoreFloat64Offset) { // generate load [#base + #index] Node* load = m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset)); - m.Store(kMachFloat64, m.PointerConstant(to), m.IntPtrConstant(offset), - load); + m.Store(kMachFloat64, m.PointerConstant(to), m.IntPtrConstant(offset), load, + kNoWriteBarrier); m.Return(m.Int32Constant(magic)); FOR_FLOAT64_INPUTS(j) { @@ -3091,7 +3370,7 @@ static void RunLoadStore(MachineType rep) { Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0])); Node* load = m.Load(rep, base, index0); Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0])); - m.Store(rep, base, index1, load); + m.Store(rep, base, index1, load, kNoWriteBarrier); m.Return(m.Int32Constant(OK)); CHECK(buffer[x] != buffer[y]); @@ -3114,78 +3393,114 @@ TEST(RunLoadStore) { } -TEST(RunFloat32Binop) { - RawMachineAssemblerTester<int32_t> m; - float result; +TEST(RunFloat32Add) { + BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); + m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1))); - const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(), - m.machine()->Float32Mul(), m.machine()->Float32Div(), - NULL}; + FOR_FLOAT32_INPUTS(i) { + FOR_FLOAT32_INPUTS(j) { + volatile float expected = *i + *j; + CheckFloatEq(expected, m.Call(*i, *j)); + } + } +} - float inf = std::numeric_limits<float>::infinity(); - const Operator* inputs[] = { - m.common()->Float32Constant(0.0f), m.common()->Float32Constant(1.0f), - m.common()->Float32Constant(1.0f), m.common()->Float32Constant(0.0f), - m.common()->Float32Constant(0.0f), m.common()->Float32Constant(-1.0f), - m.common()->Float32Constant(-1.0f), m.common()->Float32Constant(0.0f), - m.common()->Float32Constant(0.22f), m.common()->Float32Constant(-1.22f), - m.common()->Float32Constant(-1.22f), m.common()->Float32Constant(0.22f), - m.common()->Float32Constant(inf), m.common()->Float32Constant(0.22f), - m.common()->Float32Constant(inf), m.common()->Float32Constant(-inf), - NULL}; - for (int i = 0; ops[i] != NULL; i++) { - for (int j = 0; inputs[j] != NULL; j += 2) { - RawMachineAssemblerTester<int32_t> m; - Node* a = m.AddNode(inputs[j]); - Node* b = m.AddNode(inputs[j + 1]); - Node* binop = m.AddNode(ops[i], a, b); - Node* base = m.PointerConstant(&result); - Node* zero = m.IntPtrConstant(0); - m.Store(kMachFloat32, base, zero, binop); - m.Return(m.Int32Constant(i + j)); - CHECK_EQ(i + j, m.Call()); +TEST(RunFloat32Sub) { + BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); + m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1))); + + FOR_FLOAT32_INPUTS(i) { + FOR_FLOAT32_INPUTS(j) { + volatile float expected = *i - *j; + CheckFloatEq(expected, m.Call(*i, *j)); } } } -TEST(RunFloat64Binop) { - RawMachineAssemblerTester<int32_t> m; - double result; +TEST(RunFloat32Mul) { + BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); + m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1))); - const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), - m.machine()->Float64Mul(), m.machine()->Float64Div(), - m.machine()->Float64Mod(), NULL}; + FOR_FLOAT32_INPUTS(i) { + FOR_FLOAT32_INPUTS(j) { + volatile float expected = *i * *j; + CheckFloatEq(expected, m.Call(*i, *j)); + } + } +} - double inf = V8_INFINITY; - const Operator* inputs[] = { - m.common()->Float64Constant(0), m.common()->Float64Constant(1), - m.common()->Float64Constant(1), m.common()->Float64Constant(0), - m.common()->Float64Constant(0), m.common()->Float64Constant(-1), - m.common()->Float64Constant(-1), m.common()->Float64Constant(0), - m.common()->Float64Constant(0.22), m.common()->Float64Constant(-1.22), - m.common()->Float64Constant(-1.22), m.common()->Float64Constant(0.22), - m.common()->Float64Constant(inf), m.common()->Float64Constant(0.22), - m.common()->Float64Constant(inf), m.common()->Float64Constant(-inf), - NULL}; - for (int i = 0; ops[i] != NULL; i++) { - for (int j = 0; inputs[j] != NULL; j += 2) { - RawMachineAssemblerTester<int32_t> m; - Node* a = m.AddNode(inputs[j]); - Node* b = m.AddNode(inputs[j + 1]); - Node* binop = m.AddNode(ops[i], a, b); - Node* base = m.PointerConstant(&result); - Node* zero = m.Int32Constant(0); - m.Store(kMachFloat64, base, zero, binop); - m.Return(m.Int32Constant(i + j)); - CHECK_EQ(i + j, m.Call()); +TEST(RunFloat32Div) { + BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); + m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1))); + + FOR_FLOAT32_INPUTS(i) { + FOR_FLOAT32_INPUTS(j) { + volatile float expected = *i / *j; + CheckFloatEq(expected, m.Call(*i, *j)); + } + } +} + + +TEST(RunFloat64Add) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); + m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1))); + + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i + *j, m.Call(*i, *j)); } + } +} + + +TEST(RunFloat64Sub) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); + m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1))); + + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i - *j, m.Call(*i, *j)); } + } +} + + +TEST(RunFloat64Mul) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); + m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1))); + + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { + volatile double expected = *i * *j; + CheckDoubleEq(expected, m.Call(*i, *j)); + } + } +} + + +TEST(RunFloat64Div) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); + m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1))); + + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { + volatile double expected = *i / *j; + CheckDoubleEq(expected, m.Call(*i, *j)); } } } +TEST(RunFloat64Mod) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); + m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1))); + + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(modulo(*i, *j), m.Call(*i, *j)); } + } +} + + TEST(RunDeadFloat32Binops) { RawMachineAssemblerTester<int32_t> m; @@ -3250,111 +3565,141 @@ TEST(RunFloat64AddP) { } -TEST(RunFloat32SubP) { +TEST(RunFloa32MaxP) { RawMachineAssemblerTester<int32_t> m; Float32BinopTester bt(&m); + if (!m.machine()->Float32Max().IsSupported()) return; - bt.AddReturn(m.Float32Sub(bt.param0, bt.param1)); + bt.AddReturn(m.Float32Max(bt.param0, bt.param1)); FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pr) { - float expected = *pl - *pr; - CheckFloatEq(expected, bt.call(*pl, *pr)); + double expected = *pl > *pr ? *pl : *pr; + CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } -TEST(RunFloat32SubImm1) { - float input = 0.0f; - float output = 0.0f; +TEST(RunFloat64MaxP) { + RawMachineAssemblerTester<int32_t> m; + Float64BinopTester bt(&m); + if (!m.machine()->Float64Max().IsSupported()) return; - FOR_FLOAT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachFloat32); - Node* t1 = m.Float32Sub(m.Float32Constant(*i), t0); - m.StoreToPointer(&output, kMachFloat32, t1); - m.Return(m.Int32Constant(0)); - FOR_FLOAT32_INPUTS(j) { - input = *j; - float expected = *i - input; - CHECK_EQ(0, m.Call()); - CheckFloatEq(expected, output); + bt.AddReturn(m.Float64Max(bt.param0, bt.param1)); + + FOR_FLOAT64_INPUTS(pl) { + FOR_FLOAT64_INPUTS(pr) { + double expected = *pl > *pr ? *pl : *pr; + CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } -TEST(RunFloat32SubImm2) { - float input = 0.0f; - float output = 0.0f; +TEST(RunFloat32MinP) { + RawMachineAssemblerTester<int32_t> m; + Float32BinopTester bt(&m); + if (!m.machine()->Float32Min().IsSupported()) return; - FOR_FLOAT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachFloat32); - Node* t1 = m.Float32Sub(t0, m.Float32Constant(*i)); - m.StoreToPointer(&output, kMachFloat32, t1); - m.Return(m.Int32Constant(0)); - FOR_FLOAT32_INPUTS(j) { - input = *j; - float expected = input - *i; - CHECK_EQ(0, m.Call()); - CheckFloatEq(expected, output); + bt.AddReturn(m.Float32Min(bt.param0, bt.param1)); + + FOR_FLOAT32_INPUTS(pl) { + FOR_FLOAT32_INPUTS(pr) { + double expected = *pl < *pr ? *pl : *pr; + CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } -TEST(RunFloat64SubP) { +TEST(RunFloat64MinP) { RawMachineAssemblerTester<int32_t> m; Float64BinopTester bt(&m); + if (!m.machine()->Float64Min().IsSupported()) return; - bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); + bt.AddReturn(m.Float64Min(bt.param0, bt.param1)); FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pr) { - double expected = *pl - *pr; + double expected = *pl < *pr ? *pl : *pr; CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } -TEST(RunFloat64SubImm1) { - double input = 0.0; - double output = 0.0; +TEST(RunFloat32SubP) { + RawMachineAssemblerTester<int32_t> m; + Float32BinopTester bt(&m); - FOR_FLOAT64_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachFloat64); - Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0); - m.StoreToPointer(&output, kMachFloat64, t1); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(j) { - input = *j; - double expected = *i - input; - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, output); + bt.AddReturn(m.Float32Sub(bt.param0, bt.param1)); + + FOR_FLOAT32_INPUTS(pl) { + FOR_FLOAT32_INPUTS(pr) { + float expected = *pl - *pr; + CheckFloatEq(expected, bt.call(*pl, *pr)); } } } -TEST(RunFloat64SubImm2) { - double input = 0.0; - double output = 0.0; +TEST(RunFloat32SubImm1) { + FOR_FLOAT32_INPUTS(i) { + BufferedRawMachineAssemblerTester<float> m(kMachFloat32); + m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0))); + FOR_FLOAT32_INPUTS(j) { + volatile float expected = *i - *j; + CheckFloatEq(expected, m.Call(*j)); + } + } +} + + +TEST(RunFloat32SubImm2) { + FOR_FLOAT32_INPUTS(i) { + BufferedRawMachineAssemblerTester<float> m(kMachFloat32); + m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i))); + + FOR_FLOAT32_INPUTS(j) { + volatile float expected = *j - *i; + CheckFloatEq(expected, m.Call(*j)); + } + } +} + + +TEST(RunFloat64SubImm1) { FOR_FLOAT64_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachFloat64); - Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i)); - m.StoreToPointer(&output, kMachFloat64, t1); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(j) { - input = *j; - double expected = input - *i; - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, output); + BufferedRawMachineAssemblerTester<double> m(kMachFloat64); + m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0))); + + FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i - *j, m.Call(*j)); } + } +} + + +TEST(RunFloat64SubImm2) { + FOR_FLOAT64_INPUTS(i) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64); + m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i))); + + FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j - *i, m.Call(*j)); } + } +} + + +TEST(RunFloat64SubP) { + RawMachineAssemblerTester<int32_t> m; + Float64BinopTester bt(&m); + + bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); + + FOR_FLOAT64_INPUTS(pl) { + FOR_FLOAT64_INPUTS(pr) { + double expected = *pl - *pr; + CheckDoubleEq(expected, bt.call(*pl, *pr)); } } } @@ -3390,121 +3735,86 @@ TEST(RunFloat64MulP) { } -TEST(RunFloat64MulAndFloat64AddP) { - double input_a = 0.0; - double input_b = 0.0; - double input_c = 0.0; - double output = 0.0; +TEST(RunFloat64MulAndFloat64Add1) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, + kMachFloat64); + m.Return(m.Float64Add(m.Float64Mul(m.Parameter(0), m.Parameter(1)), + m.Parameter(2))); - { - RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachFloat64); - Node* c = m.LoadFromPointer(&input_c, kMachFloat64); - m.StoreToPointer(&output, kMachFloat64, - m.Float64Add(m.Float64Mul(a, b), c)); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(i) { - FOR_FLOAT64_INPUTS(j) { - FOR_FLOAT64_INPUTS(k) { - input_a = *i; - input_b = *j; - input_c = *k; - volatile double temp = input_a * input_b; - volatile double expected = temp + input_c; - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, output); - } + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { + FOR_FLOAT64_INPUTS(k) { + CheckDoubleEq((*i * *j) + *k, m.Call(*i, *j, *k)); } } } - { - RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachFloat64); - Node* c = m.LoadFromPointer(&input_c, kMachFloat64); - m.StoreToPointer(&output, kMachFloat64, - m.Float64Add(a, m.Float64Mul(b, c))); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(i) { - FOR_FLOAT64_INPUTS(j) { - FOR_FLOAT64_INPUTS(k) { - input_a = *i; - input_b = *j; - input_c = *k; - volatile double temp = input_b * input_c; - volatile double expected = input_a + temp; - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, output); - } +} + + +TEST(RunFloat64MulAndFloat64Add2) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, + kMachFloat64); + m.Return(m.Float64Add(m.Parameter(0), + m.Float64Mul(m.Parameter(1), m.Parameter(2)))); + + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { + FOR_FLOAT64_INPUTS(k) { + CheckDoubleEq(*i + (*j * *k), m.Call(*i, *j, *k)); } } } } -TEST(RunFloat64MulAndFloat64SubP) { - double input_a = 0.0; - double input_b = 0.0; - double input_c = 0.0; - double output = 0.0; - - RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachFloat64); - Node* c = m.LoadFromPointer(&input_c, kMachFloat64); - m.StoreToPointer(&output, kMachFloat64, m.Float64Sub(a, m.Float64Mul(b, c))); - m.Return(m.Int32Constant(0)); +TEST(RunFloat64MulAndFloat64Sub1) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, + kMachFloat64); + m.Return(m.Float64Sub(m.Float64Mul(m.Parameter(0), m.Parameter(1)), + m.Parameter(2))); FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(k) { - input_a = *i; - input_b = *j; - input_c = *k; - volatile double temp = input_b * input_c; - volatile double expected = input_a - temp; - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, output); + CheckDoubleEq((*i * *j) - *k, m.Call(*i, *j, *k)); } } } } -TEST(RunFloat64MulImm) { - double input = 0.0; - double output = 0.0; +TEST(RunFloat64MulAndFloat64Sub2) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, + kMachFloat64); + m.Return(m.Float64Sub(m.Parameter(0), + m.Float64Mul(m.Parameter(1), m.Parameter(2)))); - { - FOR_FLOAT64_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachFloat64); - Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0); - m.StoreToPointer(&output, kMachFloat64, t1); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(j) { - input = *j; - double expected = *i * input; - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, output); + FOR_FLOAT64_INPUTS(i) { + FOR_FLOAT64_INPUTS(j) { + FOR_FLOAT64_INPUTS(k) { + CheckDoubleEq(*i - (*j * *k), m.Call(*i, *j, *k)); } } } - { - FOR_FLOAT64_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachFloat64); - Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i)); - m.StoreToPointer(&output, kMachFloat64, t1); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(j) { - input = *j; - double expected = input * *i; - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, output); - } - } +} + + +TEST(RunFloat64MulImm1) { + FOR_FLOAT64_INPUTS(i) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64); + m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0))); + + FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i * *j, m.Call(*j)); } + } +} + + +TEST(RunFloat64MulImm2) { + FOR_FLOAT64_INPUTS(i) { + BufferedRawMachineAssemblerTester<double> m(kMachFloat64); + m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i))); + + FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j * *i, m.Call(*j)); } } } @@ -3556,285 +3866,80 @@ TEST(RunFloat64ModP) { TEST(RunChangeInt32ToFloat64_A) { - RawMachineAssemblerTester<int32_t> m; int32_t magic = 0x986234; - double result = 0; - - Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic)); - m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(0), - convert); - m.Return(m.Int32Constant(magic)); - - CHECK_EQ(magic, m.Call()); - CHECK_EQ(static_cast<double>(magic), result); + BufferedRawMachineAssemblerTester<double> m; + m.Return(m.ChangeInt32ToFloat64(m.Int32Constant(magic))); + CheckDoubleEq(static_cast<double>(magic), m.Call()); } TEST(RunChangeInt32ToFloat64_B) { - RawMachineAssemblerTester<int32_t> m(kMachInt32); - double output = 0; + BufferedRawMachineAssemblerTester<double> m(kMachInt32); + m.Return(m.ChangeInt32ToFloat64(m.Parameter(0))); - Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0)); - m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), - convert); - m.Return(m.Parameter(0)); - - FOR_INT32_INPUTS(i) { - int32_t expect = *i; - CHECK_EQ(expect, m.Call(expect)); - CHECK_EQ(static_cast<double>(expect), output); - } + FOR_INT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } } -TEST(RunChangeUint32ToFloat64_B) { - RawMachineAssemblerTester<uint32_t> m(kMachUint32); - double output = 0; - - Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0)); - m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), - convert); - m.Return(m.Parameter(0)); +TEST(RunChangeUint32ToFloat64) { + BufferedRawMachineAssemblerTester<double> m(kMachUint32); + m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); - FOR_UINT32_INPUTS(i) { - uint32_t expect = *i; - CHECK_EQ(expect, m.Call(expect)); - CHECK_EQ(static_cast<double>(expect), output); - } -} - - -TEST(RunChangeUint32ToFloat64_spilled) { - RawMachineAssemblerTester<int32_t> m; - const int kNumInputs = 32; - int32_t magic = 0x786234; - uint32_t input[kNumInputs]; - double result[kNumInputs]; - Node* input_node[kNumInputs]; - - for (int i = 0; i < kNumInputs; i++) { - input_node[i] = - m.Load(kMachUint32, m.PointerConstant(&input), m.Int32Constant(i * 4)); - } - - for (int i = 0; i < kNumInputs; i++) { - m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(i * 8), - m.ChangeUint32ToFloat64(input_node[i])); - } - - m.Return(m.Int32Constant(magic)); - - for (int i = 0; i < kNumInputs; i++) { - input[i] = 100 + i; - } - - CHECK_EQ(magic, m.Call()); - - for (int i = 0; i < kNumInputs; i++) { - CHECK_EQ(result[i], static_cast<double>(100 + i)); - } + FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } } TEST(RunChangeFloat64ToInt32_A) { - RawMachineAssemblerTester<int32_t> m; - int32_t magic = 0x786234; - double input = 11.1; - int32_t result = 0; - - m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(0), - m.ChangeFloat64ToInt32(m.Float64Constant(input))); - m.Return(m.Int32Constant(magic)); - - CHECK_EQ(magic, m.Call()); - CHECK_EQ(static_cast<int32_t>(input), result); + BufferedRawMachineAssemblerTester<int32_t> m; + double magic = 11.1; + m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); + CHECK_EQ(static_cast<int32_t>(magic), m.Call()); } TEST(RunChangeFloat64ToInt32_B) { - RawMachineAssemblerTester<int32_t> m; - double input = 0; - int32_t output = 0; + BufferedRawMachineAssemblerTester<int32_t> m(kMachFloat64); + m.Return(m.ChangeFloat64ToInt32(m.Parameter(0))); - Node* load = - m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); - Node* convert = m.ChangeFloat64ToInt32(load); - m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert); - m.Return(convert); + // Note we don't check fractional inputs, or inputs outside the range of + // int32, because these Convert operators really should be Change operators. + FOR_INT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); } - { - FOR_INT32_INPUTS(i) { - input = *i; - int32_t expect = *i; - CHECK_EQ(expect, m.Call()); - CHECK_EQ(expect, output); - } + for (int32_t n = 1; n < 31; ++n) { + CHECK_EQ(1 << n, m.Call(static_cast<double>(1 << n))); } - // Check various powers of 2. for (int32_t n = 1; n < 31; ++n) { - { - input = 1 << n; - int32_t expect = static_cast<int32_t>(input); - CHECK_EQ(expect, m.Call()); - CHECK_EQ(expect, output); - } - - { - input = 3 << n; - int32_t expect = static_cast<int32_t>(input); - CHECK_EQ(expect, m.Call()); - CHECK_EQ(expect, output); - } + CHECK_EQ(3 << n, m.Call(static_cast<double>(3 << n))); } - // Note we don't check fractional inputs, because these Convert operators - // really should be Change operators. } -TEST(RunChangeFloat64ToUint32_B) { - RawMachineAssemblerTester<int32_t> m; - double input = 0; - int32_t output = 0; - - Node* load = - m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); - Node* convert = m.ChangeFloat64ToUint32(load); - m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert); - m.Return(convert); +TEST(RunChangeFloat64ToUint32) { + BufferedRawMachineAssemblerTester<uint32_t> m(kMachFloat64); + m.Return(m.ChangeFloat64ToUint32(m.Parameter(0))); { - FOR_UINT32_INPUTS(i) { - input = *i; - // TODO(titzer): add a CheckEqualsHelper overload for uint32_t. - int32_t expect = static_cast<int32_t>(*i); - CHECK_EQ(expect, m.Call()); - CHECK_EQ(expect, output); - } + FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); } } // Check various powers of 2. for (int32_t n = 1; n < 31; ++n) { - { - input = 1u << n; - int32_t expect = static_cast<int32_t>(static_cast<uint32_t>(input)); - CHECK_EQ(expect, m.Call()); - CHECK_EQ(expect, output); - } + { CHECK_EQ(1u << n, m.Call(static_cast<double>(1u << n))); } - { - input = 3u << n; - int32_t expect = static_cast<int32_t>(static_cast<uint32_t>(input)); - CHECK_EQ(expect, m.Call()); - CHECK_EQ(expect, output); - } + { CHECK_EQ(3u << n, m.Call(static_cast<double>(3u << n))); } } // Note we don't check fractional inputs, because these Convert operators // really should be Change operators. } -TEST(RunChangeFloat64ToInt32_spilled) { - RawMachineAssemblerTester<int32_t> m; - const int kNumInputs = 32; - int32_t magic = 0x786234; - double input[kNumInputs]; - int32_t result[kNumInputs]; - Node* input_node[kNumInputs]; - - for (int i = 0; i < kNumInputs; i++) { - input_node[i] = - m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); - } - - for (int i = 0; i < kNumInputs; i++) { - m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(i * 4), - m.ChangeFloat64ToInt32(input_node[i])); - } - - m.Return(m.Int32Constant(magic)); - - for (int i = 0; i < kNumInputs; i++) { - input[i] = 100.9 + i; - } - - CHECK_EQ(magic, m.Call()); - - for (int i = 0; i < kNumInputs; i++) { - CHECK_EQ(result[i], 100 + i); - } -} - - -TEST(RunChangeFloat64ToUint32_spilled) { - RawMachineAssemblerTester<uint32_t> m; - const int kNumInputs = 32; - uint32_t magic = 0x786234; - double input[kNumInputs]; - uint32_t result[kNumInputs]; - Node* input_node[kNumInputs]; - - for (int i = 0; i < kNumInputs; i++) { - input_node[i] = - m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); - } - - for (int i = 0; i < kNumInputs; i++) { - m.Store(kMachUint32, m.PointerConstant(&result), m.Int32Constant(i * 4), - m.ChangeFloat64ToUint32(input_node[i])); - } - - m.Return(m.Int32Constant(magic)); - - for (int i = 0; i < kNumInputs; i++) { - if (i % 2) { - input[i] = 100 + i + 2147483648u; - } else { - input[i] = 100 + i; - } - } - - CHECK_EQ(magic, m.Call()); - - for (int i = 0; i < kNumInputs; i++) { - if (i % 2) { - CHECK_EQ(result[i], static_cast<uint32_t>(100 + i + 2147483648u)); - } else { - CHECK_EQ(result[i], static_cast<uint32_t>(100 + i)); - } - } -} - - -TEST(RunTruncateFloat64ToFloat32_spilled) { - RawMachineAssemblerTester<uint32_t> m; - const int kNumInputs = 32; - uint32_t magic = 0x786234; - double input[kNumInputs]; - float result[kNumInputs]; - Node* input_node[kNumInputs]; - - for (int i = 0; i < kNumInputs; i++) { - input_node[i] = - m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); - } - - for (int i = 0; i < kNumInputs; i++) { - m.Store(kMachFloat32, m.PointerConstant(&result), m.Int32Constant(i * 4), - m.TruncateFloat64ToFloat32(input_node[i])); - } - - m.Return(m.Int32Constant(magic)); - - for (int i = 0; i < kNumInputs; i++) { - input[i] = 0.1 + i; - } +TEST(RunTruncateFloat64ToFloat32) { + BufferedRawMachineAssemblerTester<float> m(kMachFloat64); - CHECK_EQ(magic, m.Call()); + m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); - for (int i = 0; i < kNumInputs; i++) { - CHECK_EQ(result[i], DoubleToFloat32(input[i])); - } + FOR_FLOAT64_INPUTS(i) { CheckFloatEq(DoubleToFloat32(*i), m.Call(*i)); } } @@ -3896,7 +4001,8 @@ TEST(RunFloatDiamond) { m.Goto(&end); m.Bind(&end); Node* phi = m.Phi(kMachFloat32, k2, k1); - m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi); + m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi, + kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -3921,7 +4027,8 @@ TEST(RunDoubleDiamond) { m.Goto(&end); m.Bind(&end); Node* phi = m.Phi(kMachFloat64, k2, k1); - m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); + m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, + kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -3947,7 +4054,8 @@ TEST(RunRefDiamond) { m.Goto(&end); m.Bind(&end); Node* phi = m.Phi(kMachAnyTagged, k2, k1); - m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi); + m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi, + kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -3978,9 +4086,10 @@ TEST(RunDoubleRefDiamond) { m.Bind(&end); Node* dphi = m.Phi(kMachFloat64, d2, d1); Node* rphi = m.Phi(kMachAnyTagged, r2, r1); - m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi); - m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), - rphi); + m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi, + kNoWriteBarrier); + m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi, + kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4022,9 +4131,10 @@ TEST(RunDoubleRefDoubleDiamond) { Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1); Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1); - m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2); + m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2, + kNoWriteBarrier); m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), - rphi2); + rphi2, kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4052,7 +4162,8 @@ TEST(RunDoubleLoopPhi) { m.Bind(&body); m.Goto(&header); m.Bind(&end); - m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); + m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, + kNoWriteBarrier); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -4449,7 +4560,7 @@ TEST(RunTestIntPtrArithmetic) { Node* output = m.PointerConstant(&outputs[kInputSize - 1]); Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); for (int i = 0; i < kInputSize; i++) { - m.Store(kMachInt32, output, m.Load(kMachInt32, input)); + m.Store(kMachInt32, output, m.Load(kMachInt32, input), kNoWriteBarrier); input = m.IntPtrAdd(input, elem_size); output = m.IntPtrSub(output, elem_size); } @@ -4856,178 +4967,82 @@ TEST(RunTruncateFloat64ToInt32P) { TEST(RunChangeFloat32ToFloat64) { - double actual = 0.0f; - float expected = 0.0; - RawMachineAssemblerTester<int32_t> m; - m.StoreToPointer( - &actual, kMachFloat64, - m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32))); - m.Return(m.Int32Constant(0)); - FOR_FLOAT32_INPUTS(i) { - expected = *i; - CHECK_EQ(0, m.Call()); - CHECK_EQ(expected, actual); - } -} + BufferedRawMachineAssemblerTester<double> m(kMachFloat32); + m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); -TEST(RunChangeFloat32ToFloat64_spilled) { - RawMachineAssemblerTester<int32_t> m; - const int kNumInputs = 32; - int32_t magic = 0x786234; - float input[kNumInputs]; - double result[kNumInputs]; - Node* input_node[kNumInputs]; - - for (int i = 0; i < kNumInputs; i++) { - input_node[i] = - m.Load(kMachFloat32, m.PointerConstant(&input), m.Int32Constant(i * 4)); - } - - for (int i = 0; i < kNumInputs; i++) { - m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(i * 8), - m.ChangeFloat32ToFloat64(input_node[i])); - } - - m.Return(m.Int32Constant(magic)); - - for (int i = 0; i < kNumInputs; i++) { - input[i] = 100.9f + i; - } - - CHECK_EQ(magic, m.Call()); - - for (int i = 0; i < kNumInputs; i++) { - CHECK_EQ(result[i], static_cast<double>(input[i])); - } -} - - -TEST(RunTruncateFloat64ToFloat32) { - float actual = 0.0f; - double input = 0.0; - RawMachineAssemblerTester<int32_t> m; - m.StoreToPointer( - &actual, kMachFloat32, - m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(i) { - input = *i; - volatile double expected = DoubleToFloat32(input); - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, actual); - } + FOR_FLOAT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } } TEST(RunFloat32Constant) { FOR_FLOAT32_INPUTS(i) { - float expected = *i; - float actual = *i; - RawMachineAssemblerTester<int32_t> m; - m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); - m.Return(m.Int32Constant(0)); - CHECK_EQ(0, m.Call()); - CHECK_EQ(expected, actual); + BufferedRawMachineAssemblerTester<float> m; + m.Return(m.Float32Constant(*i)); + CheckFloatEq(*i, m.Call()); } } TEST(RunFloat64ExtractLowWord32) { - uint64_t input = 0; - RawMachineAssemblerTester<int32_t> m; - m.Return(m.Float64ExtractLowWord32(m.LoadFromPointer(&input, kMachFloat64))); + BufferedRawMachineAssemblerTester<uint32_t> m(kMachFloat64); + m.Return(m.Float64ExtractLowWord32(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { - input = bit_cast<uint64_t>(*i); - int32_t expected = bit_cast<int32_t>(static_cast<uint32_t>(input)); - CHECK_EQ(expected, m.Call()); + uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i)); + CHECK_EQ(expected, m.Call(*i)); } } TEST(RunFloat64ExtractHighWord32) { - uint64_t input = 0; - RawMachineAssemblerTester<int32_t> m; - m.Return(m.Float64ExtractHighWord32(m.LoadFromPointer(&input, kMachFloat64))); + BufferedRawMachineAssemblerTester<uint32_t> m(kMachFloat64); + m.Return(m.Float64ExtractHighWord32(m.Parameter(0))); FOR_FLOAT64_INPUTS(i) { - input = bit_cast<uint64_t>(*i); - int32_t expected = bit_cast<int32_t>(static_cast<uint32_t>(input >> 32)); - CHECK_EQ(expected, m.Call()); + uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i) >> 32); + CHECK_EQ(expected, m.Call(*i)); } } TEST(RunFloat64InsertLowWord32) { - uint64_t input = 0; - uint64_t result = 0; - RawMachineAssemblerTester<int32_t> m(kMachInt32); - m.StoreToPointer( - &result, kMachFloat64, - m.Float64InsertLowWord32(m.LoadFromPointer(&input, kMachFloat64), - m.Parameter(0))); - m.Return(m.Int32Constant(0)); + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachInt32); + m.Return(m.Float64InsertLowWord32(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { FOR_INT32_INPUTS(j) { - input = bit_cast<uint64_t>(*i); - uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF))) | - (static_cast<uint64_t>(bit_cast<uint32_t>(*j))); - CHECK_EQ(0, m.Call(*j)); - CHECK_EQ(expected, result); + double expected = bit_cast<double>( + (bit_cast<uint64_t>(*i) & ~(V8_UINT64_C(0xFFFFFFFF))) | + (static_cast<uint64_t>(bit_cast<uint32_t>(*j)))); + CheckDoubleEq(expected, m.Call(*i, *j)); } } } TEST(RunFloat64InsertHighWord32) { - uint64_t input = 0; - uint64_t result = 0; - RawMachineAssemblerTester<int32_t> m(kMachInt32); - m.StoreToPointer( - &result, kMachFloat64, - m.Float64InsertHighWord32(m.LoadFromPointer(&input, kMachFloat64), - m.Parameter(0))); - m.Return(m.Int32Constant(0)); + BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachUint32); + m.Return(m.Float64InsertHighWord32(m.Parameter(0), m.Parameter(1))); FOR_FLOAT64_INPUTS(i) { - FOR_INT32_INPUTS(j) { - input = bit_cast<uint64_t>(*i); - uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF) << 32)) | - (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << 32); - CHECK_EQ(0, m.Call(*j)); - CHECK_EQ(expected, result); + FOR_UINT32_INPUTS(j) { + uint64_t expected = (bit_cast<uint64_t>(*i) & 0xFFFFFFFF) | + (static_cast<uint64_t>(*j) << 32); + + CheckDoubleEq(bit_cast<double>(expected), m.Call(*i, *j)); } } } TEST(RunFloat32Abs) { - float input = -1.0; - float result = 0.0; - RawMachineAssemblerTester<int32_t> m; - m.StoreToPointer(&result, kMachFloat32, - m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32))); - m.Return(m.Int32Constant(0)); - FOR_FLOAT32_INPUTS(i) { - input = *i; - float expected = std::abs(input); - CHECK_EQ(0, m.Call()); - CheckFloatEq(expected, result); - } + BufferedRawMachineAssemblerTester<float> m(kMachFloat32); + m.Return(m.Float32Abs(m.Parameter(0))); + FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::abs(*i), m.Call(*i)); } } TEST(RunFloat64Abs) { - double input = -1.0; - double result = 0.0; - RawMachineAssemblerTester<int32_t> m; - m.StoreToPointer(&result, kMachFloat64, - m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64))); - m.Return(m.Int32Constant(0)); - FOR_FLOAT64_INPUTS(i) { - input = *i; - double expected = std::abs(input); - CHECK_EQ(0, m.Call()); - CheckDoubleEq(expected, result); - } + BufferedRawMachineAssemblerTester<double> m(kMachFloat64); + m.Return(m.Float64Abs(m.Parameter(0))); + FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::abs(*i), m.Call(*i)); } } @@ -5130,19 +5145,12 @@ static double kValues[] = {0.1, TEST(RunFloat64RoundDown1) { - double input = -1.0; - double result = 0.0; - RawMachineAssemblerTester<int32_t> m; + BufferedRawMachineAssemblerTester<double> m(kMachFloat64); if (!m.machine()->Float64RoundDown().IsSupported()) return; - m.StoreToPointer(&result, kMachFloat64, - m.Float64RoundDown(m.LoadFromPointer(&input, kMachFloat64))); - m.Return(m.Int32Constant(0)); - for (size_t i = 0; i < arraysize(kValues); ++i) { - input = kValues[i]; - CHECK_EQ(0, m.Call()); - double expected = std::floor(kValues[i]); - CHECK_EQ(expected, result); - } + + m.Return(m.Float64RoundDown(m.Parameter(0))); + + FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::floor(*i), m.Call(*i)); } } @@ -5357,6 +5365,22 @@ TEST(RunBitcastFloat64ToInt64) { CHECK_EQ(expected, output); } } + + +TEST(RunRoundInt64ToFloat32) { + BufferedRawMachineAssemblerTester<float> m(kMachInt64); + m.Return(m.RoundInt64ToFloat32(m.Parameter(0))); + FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); } +} + + +TEST(RunRoundInt64ToFloat64) { + BufferedRawMachineAssemblerTester<double> m(kMachInt64); + m.Return(m.RoundInt64ToFloat64(m.Parameter(0))); + FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), m.Call(*i)); } +} + + #endif @@ -5387,3 +5411,58 @@ TEST(RunBitcastInt32ToFloat32) { CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); } } + + +TEST(RunComputedCodeObject) { + GraphBuilderTester<int32_t> a; + a.Return(a.Int32Constant(33)); + a.End(); + Handle<Code> code_a = a.GetCode(); + + GraphBuilderTester<int32_t> b; + b.Return(b.Int32Constant(44)); + b.End(); + Handle<Code> code_b = b.GetCode(); + + RawMachineAssemblerTester<int32_t> r(kMachInt32); + RawMachineAssembler::Label tlabel; + RawMachineAssembler::Label flabel; + RawMachineAssembler::Label merge; + r.Branch(r.Parameter(0), &tlabel, &flabel); + r.Bind(&tlabel); + Node* fa = r.HeapConstant(code_a); + r.Goto(&merge); + r.Bind(&flabel); + Node* fb = r.HeapConstant(code_b); + r.Goto(&merge); + r.Bind(&merge); + Node* phi = r.Phi(kMachInt32, fa, fb); + + // TODO(titzer): all this descriptor hackery is just to call the above + // functions as code objects instead of direct addresses. + CSignature0<int32_t> sig; + CallDescriptor* c = Linkage::GetSimplifiedCDescriptor(r.zone(), &sig); + LinkageLocation ret[] = {c->GetReturnLocation(0)}; + Signature<LinkageLocation> loc(1, 0, ret); + CallDescriptor* desc = new (r.zone()) CallDescriptor( // -- + CallDescriptor::kCallCodeObject, // kind + kMachAnyTagged, // target_type + c->GetInputLocation(0), // target_loc + &sig, // machine_sig + &loc, // location_sig + 0, // stack count + Operator::kNoProperties, // properties + c->CalleeSavedRegisters(), // callee saved + c->CalleeSavedFPRegisters(), // callee saved FP + CallDescriptor::kNoFlags, // flags + "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)); +} + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-native-calls.cc b/deps/v8/test/cctest/compiler/test-run-native-calls.cc index bc6acf1bc9..3c64bc1295 100644 --- a/deps/v8/test/cctest/compiler/test-run-native-calls.cc +++ b/deps/v8/test/cctest/compiler/test-run-native-calls.cc @@ -2,20 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include "src/assembler.h" #include "src/codegen.h" #include "src/compiler/linkage.h" #include "src/compiler/machine-type.h" #include "src/compiler/raw-machine-assembler.h" +#include "src/register-configuration.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/graph-builder-tester.h" #include "test/cctest/compiler/value-helper.h" -using namespace v8::base; -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { typedef RawMachineAssembler::Label MLabel; @@ -35,8 +39,9 @@ typedef double float64; // to select a representative set. class Pairs { public: - Pairs(int max_pairs, int range) + Pairs(int max_pairs, int range, const int* codes) : range_(range), + codes_(codes), max_pairs_(std::min(max_pairs, range_ * range_)), counter_(0) {} @@ -46,37 +51,33 @@ class Pairs { do { // Find the next pair. if (exhaustive()) { - *r0 = counter_ % range_; - *r1 = counter_ / range_; + *r0 = codes_[counter_ % range_]; + *r1 = codes_[counter_ / range_]; } else { // Try each integer at least once for both r0 and r1. int index = counter_ / 2; if (counter_ & 1) { - *r0 = index % range_; - *r1 = index / range_; + *r0 = codes_[index % range_]; + *r1 = codes_[index / range_]; } else { - *r1 = index % range_; - *r0 = index / range_; + *r1 = codes_[index % range_]; + *r0 = codes_[index / range_]; } } counter_++; - if (same_is_ok) break; - if (*r0 == *r1) { - if (counter_ >= max_pairs_) { - // For the last hurrah, reg#0 with reg#n-1 - *r0 = 0; - *r1 = range_ - 1; - break; - } + if ((same_is_ok) || (*r0 != *r1)) break; + if (counter_ == max_pairs_) { + // For the last hurrah, reg#0 with reg#n-1 + *r0 = codes_[0]; + *r1 = codes_[range_ - 1]; + break; } } while (true); - - DCHECK(*r0 >= 0 && *r0 < range_); - DCHECK(*r1 >= 0 && *r1 < range_); } private: int range_; + const int* codes_; int max_pairs_; int counter_; bool exhaustive() { return max_pairs_ == (range_ * range_); } @@ -86,7 +87,13 @@ class Pairs { // Pairs of general purpose registers. class RegisterPairs : public Pairs { public: - RegisterPairs() : Pairs(100, Register::kMaxNumAllocatableRegisters) {} + RegisterPairs() + : Pairs( + 100, + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_allocatable_general_registers(), + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->allocatable_general_codes()) {} }; @@ -94,7 +101,12 @@ class RegisterPairs : public Pairs { class Float32RegisterPairs : public Pairs { public: Float32RegisterPairs() - : Pairs(100, DoubleRegister::NumAllocatableAliasedRegisters()) {} + : Pairs( + 100, + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_allocatable_aliased_double_registers(), + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->allocatable_double_codes()) {} }; @@ -102,7 +114,12 @@ class Float32RegisterPairs : public Pairs { class Float64RegisterPairs : public Pairs { public: Float64RegisterPairs() - : Pairs(100, DoubleRegister::NumAllocatableAliasedRegisters()) {} + : Pairs( + 100, + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_allocatable_aliased_double_registers(), + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->allocatable_double_codes()) {} }; @@ -347,7 +364,8 @@ class ArgsBuffer { Node* StoreOutput(RawMachineAssembler& raw, Node* value) { Node* base = raw.PointerConstant(&output); Node* offset = raw.Int32Constant(0); - return raw.Store(MachineTypeForC<CType>(), base, offset, value); + return raw.Store(MachineTypeForC<CType>(), base, offset, value, + kNoWriteBarrier); } // Computes the next set of inputs by updating the {input} array. @@ -559,7 +577,7 @@ static void CopyTwentyInt32(CallDescriptor* desc) { Node* base = raw.PointerConstant(output); for (int i = 0; i < kNumParams; i++) { Node* offset = raw.Int32Constant(i * sizeof(int32_t)); - raw.Store(kMachInt32, base, offset, raw.Parameter(i)); + raw.Store(kMachInt32, base, offset, raw.Parameter(i), kNoWriteBarrier); } raw.Return(raw.Int32Constant(42)); inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.Export()); @@ -624,9 +642,12 @@ static void Test_RunInt32SubWithRet(int retreg) { // Separate tests for parallelization. -#define TEST_INT32_SUB_WITH_RET(x) \ - TEST(Run_Int32Sub_all_allocatable_pairs_##x) { \ - if (Register::kMaxNumAllocatableRegisters > x) Test_RunInt32SubWithRet(x); \ +#define TEST_INT32_SUB_WITH_RET(x) \ + TEST(Run_Int32Sub_all_allocatable_pairs_##x) { \ + if (x < Register::kNumRegisters && \ + Register::from_code(x).IsAllocatable()) { \ + Test_RunInt32SubWithRet(x); \ + } \ } @@ -677,7 +698,9 @@ TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { while (pairs.More()) { Zone zone; int parray[2]; - int rarray[] = {0}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(0)}; pairs.Next(&parray[0], &parray[1], false); Allocator params(parray, 2, nullptr, 0); Allocator rets(rarray, 1, nullptr, 0); @@ -724,17 +747,21 @@ static int32_t Compute_Int32_WeightedSum(CallDescriptor* desc, int32_t* input) { static void Test_Int32_WeightedSum_of_size(int count) { if (DISABLE_NATIVE_STACK_PARAMS) return; Int32Signature sig(count); - for (int p0 = 0; p0 < Register::kMaxNumAllocatableRegisters; p0++) { - Zone zone; + for (int p0 = 0; p0 < Register::kNumRegisters; p0++) { + if (Register::from_code(p0).IsAllocatable()) { + Zone zone; - int parray[] = {p0}; - int rarray[] = {0}; - Allocator params(parray, 1, nullptr, 0); - Allocator rets(rarray, 1, nullptr, 0); - RegisterConfig config(params, rets); - CallDescriptor* desc = config.Create(&zone, &sig); - Run_Computation<int32_t>(desc, Build_Int32_WeightedSum, - Compute_Int32_WeightedSum, 257 + count); + int parray[] = {p0}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(0)}; + Allocator params(parray, 1, nullptr, 0); + Allocator rets(rarray, 1, nullptr, 0); + RegisterConfig config(params, rets); + CallDescriptor* desc = config.Create(&zone, &sig); + Run_Computation<int32_t>(desc, Build_Int32_WeightedSum, + Compute_Int32_WeightedSum, 257 + count); + } } } @@ -782,8 +809,12 @@ template <int which> void Test_Int32_Select() { if (DISABLE_NATIVE_STACK_PARAMS) return; - int parray[] = {0}; - int rarray[] = {0}; + int parray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(0)}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(0)}; Allocator params(parray, 1, nullptr, 0); Allocator rets(rarray, 1, nullptr, 0); RegisterConfig config(params, rets); @@ -819,10 +850,14 @@ TEST_INT32_SELECT(63) TEST(Int64Select_registers) { - if (Register::kMaxNumAllocatableRegisters < 2) return; + if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_allocatable_general_registers() < 2) + return; if (kPointerSize < 8) return; // TODO(titzer): int64 on 32-bit platforms - int rarray[] = {0}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(0)}; ArgsBuffer<int64_t>::Sig sig(2); RegisterPairs pairs; @@ -842,9 +877,14 @@ TEST(Int64Select_registers) { TEST(Float32Select_registers) { - if (RegisterConfiguration::ArchDefault()->num_double_registers() < 2) return; + if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_allocatable_double_registers() < 2) { + return; + } - int rarray[] = {0}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(0)}; ArgsBuffer<float32>::Sig sig(2); Float32RegisterPairs pairs; @@ -864,9 +904,15 @@ TEST(Float32Select_registers) { TEST(Float64Select_registers) { - if (RegisterConfiguration::ArchDefault()->num_double_registers() < 2) return; - - int rarray[] = {0}; + if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_allocatable_double_registers() < 2) + return; + if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_allocatable_general_registers() < 2) + return; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(0)}; ArgsBuffer<float64>::Sig sig(2); Float64RegisterPairs pairs; @@ -887,7 +933,9 @@ TEST(Float64Select_registers) { TEST(Float32Select_stack_params_return_reg) { if (DISABLE_NATIVE_STACK_PARAMS) return; - int rarray[] = {0}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(0)}; Allocator params(nullptr, 0, nullptr, 0); Allocator rets(nullptr, 0, rarray, 1); RegisterConfig config(params, rets); @@ -908,7 +956,9 @@ TEST(Float32Select_stack_params_return_reg) { TEST(Float64Select_stack_params_return_reg) { if (DISABLE_NATIVE_STACK_PARAMS) return; - int rarray[] = {0}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(0)}; Allocator params(nullptr, 0, nullptr, 0); Allocator rets(nullptr, 0, rarray, 1); RegisterConfig config(params, rets); @@ -962,7 +1012,9 @@ static void Build_Select_With_Call(CallDescriptor* desc, TEST(Float64StackParamsToStackParams) { if (DISABLE_NATIVE_STACK_PARAMS) return; - int rarray[] = {0}; + int rarray[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(0)}; Allocator params(nullptr, 0, nullptr, 0); Allocator rets(nullptr, 0, rarray, 1); @@ -981,7 +1033,9 @@ TEST(Float64StackParamsToStackParams) { void MixedParamTest(int start) { if (DISABLE_NATIVE_STACK_PARAMS) return; - if (RegisterConfiguration::ArchDefault()->num_double_registers() < 2) return; + if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->num_double_registers() < 2) + return; // TODO(titzer): mix in 64-bit types on all platforms when supported. #if V8_TARGET_ARCH_32_BIT @@ -1005,10 +1059,24 @@ void MixedParamTest(int start) { const int num_params = static_cast<int>(arraysize(types) - start); // Build call descriptor - int parray[] = {0, 1}; - int rarray[] = {0}; - Allocator palloc(parray, 2, parray, 2); - Allocator ralloc(rarray, 1, rarray, 1); + int parray_gp[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(0), + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(1)}; + int rarray_gp[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableGeneralCode(0)}; + int parray_fp[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(0), + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(1)}; + int rarray_fp[] = { + RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) + ->GetAllocatableDoubleCode(0)}; + Allocator palloc(parray_gp, 2, parray_fp, 2); + Allocator ralloc(rarray_gp, 1, rarray_fp, 1); RegisterConfig config(palloc, ralloc); for (int which = 0; which < num_params; which++) { @@ -1099,3 +1167,7 @@ TEST(MixedParams_0) { MixedParamTest(0); } TEST(MixedParams_1) { MixedParamTest(1); } TEST(MixedParams_2) { MixedParamTest(2); } TEST(MixedParams_3) { MixedParamTest(3); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-properties.cc b/deps/v8/test/cctest/compiler/test-run-properties.cc index f2d72e4c4e..2a592300e7 100644 --- a/deps/v8/test/cctest/compiler/test-run-properties.cc +++ b/deps/v8/test/cctest/compiler/test-run-properties.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { template <typename U> static void TypedArrayLoadHelper(const char* array_type) { @@ -137,3 +139,7 @@ TEST(TypedArrayStore) { TypedArrayStoreHelper<double>("Float64"); // TODO(mstarzinger): Add tests for ClampedUint8. } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-stackcheck.cc b/deps/v8/test/cctest/compiler/test-run-stackcheck.cc index 8c1664bc83..bba411d283 100644 --- a/deps/v8/test/cctest/compiler/test-run-stackcheck.cc +++ b/deps/v8/test/cctest/compiler/test-run-stackcheck.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(TerminateAtMethodEntry) { FunctionTester T("(function(a,b) { return 23; })"); @@ -16,3 +18,7 @@ TEST(TerminateAtMethodEntry) { T.isolate->stack_guard()->RequestTerminateExecution(); T.CheckThrows(T.undefined(), T.undefined()); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-stubs.cc b/deps/v8/test/cctest/compiler/test-run-stubs.cc index ca7155f5cf..c4751c0e28 100644 --- a/deps/v8/test/cctest/compiler/test-run-stubs.cc +++ b/deps/v8/test/cctest/compiler/test-run-stubs.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include "src/bootstrapper.h" #include "src/code-stubs.h" #include "src/compiler/common-operator.h" @@ -14,8 +17,9 @@ #include "src/parser.h" #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { TEST(RunOptimizedMathFloorStub) { @@ -35,7 +39,7 @@ TEST(RunOptimizedMathFloorStub) { CommonOperatorBuilder common(zone); JSOperatorBuilder javascript(zone); MachineOperatorBuilder machine(zone); - JSGraph js(isolate, &graph, &common, &javascript, &machine); + JSGraph js(isolate, &graph, &common, &javascript, nullptr, &machine); // FunctionTester (ab)uses a 2-argument function Node* start = graph.NewNode(common.Start(4)); @@ -140,3 +144,7 @@ TEST(RunStringAddTFStub) { Handle<Object> result = ft.Call(leftArg, rightArg).ToHandleChecked(); CHECK(String::Equals(ft.Val("linksrechts"), Handle<String>::cast(result))); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-run-variables.cc b/deps/v8/test/cctest/compiler/test-run-variables.cc index 4e5fd181f4..4f587ef085 100644 --- a/deps/v8/test/cctest/compiler/test-run-variables.cc +++ b/deps/v8/test/cctest/compiler/test-run-variables.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS #include "test/cctest/compiler/function-tester.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { static const char* throws = NULL; @@ -118,3 +120,7 @@ TEST(SelfReferenceVariable) { CompileRun("var self = 'not a function'"); T.CheckCall(T.function); } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/test-simplified-lowering.cc b/deps/v8/test/cctest/compiler/test-simplified-lowering.cc index 54ffe85288..20bfc0f731 100644 --- a/deps/v8/test/cctest/compiler/test-simplified-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-simplified-lowering.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(jochen): Remove this after the setting is turned on globally. +#define V8_IMMINENT_DEPRECATION_WARNINGS + #include <limits> #include "src/compiler/access-builder.h" @@ -26,8 +29,9 @@ #include "test/cctest/compiler/graph-builder-tester.h" #include "test/cctest/compiler/value-helper.h" -using namespace v8::internal; -using namespace v8::internal::compiler; +namespace v8 { +namespace internal { +namespace compiler { template <typename ReturnType> class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { @@ -38,7 +42,7 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { typer(this->isolate(), this->graph()), javascript(this->zone()), jsgraph(this->isolate(), this->graph(), this->common(), &javascript, - this->machine()), + this->simplified(), this->machine()), source_positions(jsgraph.graph()), lowering(&jsgraph, this->zone(), &source_positions) {} @@ -676,7 +680,8 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { : GraphAndBuilders(main_zone()), typer(main_isolate(), graph()), javascript(main_zone()), - jsgraph(main_isolate(), graph(), common(), &javascript, machine()) { + jsgraph(main_isolate(), graph(), common(), &javascript, simplified(), + machine()) { start = graph()->NewNode(common()->Start(2)); graph()->SetStart(start); ret = @@ -2002,3 +2007,7 @@ TEST(PhiRepresentation) { CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); } } + +} // namespace compiler +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/compiler/value-helper.h b/deps/v8/test/cctest/compiler/value-helper.h index 5c0481fe18..20be67a975 100644 --- a/deps/v8/test/cctest/compiler/value-helper.h +++ b/deps/v8/test/cctest/compiler/value-helper.h @@ -5,8 +5,6 @@ #ifndef V8_CCTEST_COMPILER_VALUE_HELPER_H_ #define V8_CCTEST_COMPILER_VALUE_HELPER_H_ -#include "src/v8.h" - #include "src/compiler/common-operator.h" #include "src/compiler/node.h" #include "src/compiler/node-matchers.h" |