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

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 1417983004: [turbofan] Add unit tests for ReduceJSCreateArguments. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 MachineOperatorBuilder machine(zone()); 82 MachineOperatorBuilder machine(zone());
83 SimplifiedOperatorBuilder simplified(zone()); 83 SimplifiedOperatorBuilder simplified(zone());
84 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, 84 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
85 &machine); 85 &machine);
86 // TODO(titzer): mock the GraphReducer here for better unit testing. 86 // TODO(titzer): mock the GraphReducer here for better unit testing.
87 GraphReducer graph_reducer(zone(), graph()); 87 GraphReducer graph_reducer(zone(), graph());
88 JSTypedLowering reducer(&graph_reducer, &jsgraph, zone()); 88 JSTypedLowering reducer(&graph_reducer, &jsgraph, zone());
89 return reducer.Reduce(node); 89 return reducer.Reduce(node);
90 } 90 }
91 91
92 Node* FrameState(Handle<SharedFunctionInfo> shared, Node* outer_frame_state) {
93 Node* state_values = graph()->NewNode(common()->StateValues(0));
94 return graph()->NewNode(
95 common()->FrameState(BailoutId::None(),
96 OutputFrameStateCombine::Ignore(),
97 common()->CreateFrameStateFunctionInfo(
98 FrameStateType::kJavaScriptFunction, 1, 0,
99 shared, CALL_MAINTAINS_NATIVE_CONTEXT)),
100 state_values, state_values, state_values, NumberConstant(0),
101 UndefinedConstant(), outer_frame_state);
102 }
103
92 Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) { 104 Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) {
93 Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer(); 105 Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer();
94 JSArrayBuffer::Setup(buffer, isolate(), true, bytes, byte_length); 106 JSArrayBuffer::Setup(buffer, isolate(), true, bytes, byte_length);
95 return buffer; 107 return buffer;
96 } 108 }
97 109
98 Matcher<Node*> IsIntPtrConstant(intptr_t value) { 110 Matcher<Node*> IsIntPtrConstant(intptr_t value) {
99 return sizeof(value) == 4 ? IsInt32Constant(static_cast<int32_t>(value)) 111 return sizeof(value) == 4 ? IsInt32Constant(static_cast<int32_t>(value))
100 : IsInt64Constant(static_cast<int64_t>(value)); 112 : IsInt64Constant(static_cast<int64_t>(value));
101 } 113 }
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 EXPECT_THAT(r.replacement(), 990 EXPECT_THAT(r.replacement(),
979 IsCall(_, IsHeapConstant(CodeFactory::StringAdd( 991 IsCall(_, IsHeapConstant(CodeFactory::StringAdd(
980 isolate(), STRING_ADD_CHECK_NONE, 992 isolate(), STRING_ADD_CHECK_NONE,
981 NOT_TENURED).code()), 993 NOT_TENURED).code()),
982 lhs, rhs, context, frame_state0, effect, control)); 994 lhs, rhs, context, frame_state0, effect, control));
983 } 995 }
984 } 996 }
985 997
986 998
987 // ----------------------------------------------------------------------------- 999 // -----------------------------------------------------------------------------
1000 // JSCreateArguments
1001
1002
1003 TEST_F(JSTypedLoweringTest, JSCreateArgumentsViaStub) {
1004 Node* const closure = Parameter(Type::Any());
1005 Node* const context = UndefinedConstant();
1006 Node* const effect = graph()->start();
1007 Node* const control = graph()->start();
1008 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
1009 Node* const frame_state = FrameState(shared, graph()->start());
1010 Reduction r = Reduce(
1011 graph()->NewNode(javascript()->CreateArguments(
1012 CreateArgumentsParameters::kMappedArguments, 0),
1013 closure, context, frame_state, effect, control));
1014 ASSERT_TRUE(r.Changed());
1015 EXPECT_THAT(r.replacement(),
1016 IsCall(_, IsHeapConstant(CodeFactory::ArgumentsAccess(
1017 isolate(), false, false)
1018 .code()),
1019 closure, IsNumberConstant(0), _, effect, control));
1020 }
1021
1022
1023 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedMapped) {
1024 Node* const closure = Parameter(Type::Any());
1025 Node* const context = UndefinedConstant();
1026 Node* const effect = graph()->start();
1027 Node* const control = graph()->start();
1028 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
1029 Node* const frame_state_outer = FrameState(shared, graph()->start());
1030 Node* const frame_state_inner = FrameState(shared, frame_state_outer);
1031 Reduction r = Reduce(
1032 graph()->NewNode(javascript()->CreateArguments(
1033 CreateArgumentsParameters::kMappedArguments, 0),
1034 closure, context, frame_state_inner, effect, control));
1035 ASSERT_TRUE(r.Changed());
1036 EXPECT_THAT(r.replacement(),
1037 IsFinishRegion(
1038 IsAllocate(IsNumberConstant(Heap::kSloppyArgumentsObjectSize),
1039 IsBeginRegion(effect), control),
1040 _));
1041 }
1042
1043
1044 TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedUnmapped) {
1045 Node* const closure = Parameter(Type::Any());
1046 Node* const context = UndefinedConstant();
1047 Node* const effect = graph()->start();
1048 Node* const control = graph()->start();
1049 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
1050 Node* const frame_state_outer = FrameState(shared, graph()->start());
1051 Node* const frame_state_inner = FrameState(shared, frame_state_outer);
1052 Reduction r = Reduce(
1053 graph()->NewNode(javascript()->CreateArguments(
1054 CreateArgumentsParameters::kUnmappedArguments, 0),
1055 closure, context, frame_state_inner, effect, control));
1056 ASSERT_TRUE(r.Changed());
1057 EXPECT_THAT(r.replacement(),
1058 IsFinishRegion(
1059 IsAllocate(IsNumberConstant(Heap::kStrictArgumentsObjectSize),
1060 IsBeginRegion(effect), control),
1061 _));
1062 }
1063
1064
1065 // -----------------------------------------------------------------------------
988 // JSCreateClosure 1066 // JSCreateClosure
989 1067
990 1068
991 TEST_F(JSTypedLoweringTest, JSCreateClosure) { 1069 TEST_F(JSTypedLoweringTest, JSCreateClosure) {
992 Node* const context = UndefinedConstant(); 1070 Node* const context = UndefinedConstant();
993 Node* const effect = graph()->start(); 1071 Node* const effect = graph()->start();
994 Node* const control = graph()->start(); 1072 Node* const control = graph()->start();
995 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); 1073 Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
996 Reduction r = 1074 Reduction r =
997 Reduce(graph()->NewNode(javascript()->CreateClosure(shared, NOT_TENURED), 1075 Reduce(graph()->NewNode(javascript()->CreateClosure(shared, NOT_TENURED),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 EXPECT_THAT(r.replacement(), 1186 EXPECT_THAT(r.replacement(),
1109 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( 1187 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor(
1110 Context::MIN_CONTEXT_SLOTS)), 1188 Context::MIN_CONTEXT_SLOTS)),
1111 IsBeginRegion(effect), control), 1189 IsBeginRegion(effect), control),
1112 _)); 1190 _));
1113 } 1191 }
1114 1192
1115 } // namespace compiler 1193 } // namespace compiler
1116 } // namespace internal 1194 } // namespace internal
1117 } // namespace v8 1195 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698