Index: test/unittests/compiler/js-typed-lowering-unittest.cc |
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc |
index 2015c7edf033181fedf3ef537915eeea32f06f6a..30b6a3b8eeb1ee80564a13788fb35bc212ce9e7c 100644 |
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc |
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc |
@@ -89,6 +89,18 @@ class JSTypedLoweringTest : public TypedGraphTest { |
return reducer.Reduce(node); |
} |
+ Node* FrameState(Handle<SharedFunctionInfo> shared, Node* outer_frame_state) { |
+ Node* state_values = graph()->NewNode(common()->StateValues(0)); |
+ return graph()->NewNode( |
+ common()->FrameState(BailoutId::None(), |
+ OutputFrameStateCombine::Ignore(), |
+ common()->CreateFrameStateFunctionInfo( |
+ FrameStateType::kJavaScriptFunction, 1, 0, |
+ shared, CALL_MAINTAINS_NATIVE_CONTEXT)), |
+ state_values, state_values, state_values, NumberConstant(0), |
+ UndefinedConstant(), outer_frame_state); |
+ } |
+ |
Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) { |
Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer(); |
JSArrayBuffer::Setup(buffer, isolate(), true, bytes, byte_length); |
@@ -985,6 +997,72 @@ TEST_F(JSTypedLoweringTest, JSAddWithString) { |
// ----------------------------------------------------------------------------- |
+// JSCreateArguments |
+ |
+ |
+TEST_F(JSTypedLoweringTest, JSCreateArgumentsViaStub) { |
+ Node* const closure = Parameter(Type::Any()); |
+ Node* const context = UndefinedConstant(); |
+ Node* const effect = graph()->start(); |
+ Node* const control = graph()->start(); |
+ Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
+ Node* const frame_state = FrameState(shared, graph()->start()); |
+ Reduction r = Reduce( |
+ graph()->NewNode(javascript()->CreateArguments( |
+ CreateArgumentsParameters::kMappedArguments, 0), |
+ closure, context, frame_state, effect, control)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsCall(_, IsHeapConstant(CodeFactory::ArgumentsAccess( |
+ isolate(), false, false) |
+ .code()), |
+ closure, IsNumberConstant(0), _, effect, control)); |
+} |
+ |
+ |
+TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedMapped) { |
+ Node* const closure = Parameter(Type::Any()); |
+ Node* const context = UndefinedConstant(); |
+ Node* const effect = graph()->start(); |
+ Node* const control = graph()->start(); |
+ Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
+ Node* const frame_state_outer = FrameState(shared, graph()->start()); |
+ Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
+ Reduction r = Reduce( |
+ graph()->NewNode(javascript()->CreateArguments( |
+ CreateArgumentsParameters::kMappedArguments, 0), |
+ closure, context, frame_state_inner, effect, control)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsFinishRegion( |
+ IsAllocate(IsNumberConstant(Heap::kSloppyArgumentsObjectSize), |
+ IsBeginRegion(effect), control), |
+ _)); |
+} |
+ |
+ |
+TEST_F(JSTypedLoweringTest, JSCreateArgumentsInlinedUnmapped) { |
+ Node* const closure = Parameter(Type::Any()); |
+ Node* const context = UndefinedConstant(); |
+ Node* const effect = graph()->start(); |
+ Node* const control = graph()->start(); |
+ Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared()); |
+ Node* const frame_state_outer = FrameState(shared, graph()->start()); |
+ Node* const frame_state_inner = FrameState(shared, frame_state_outer); |
+ Reduction r = Reduce( |
+ graph()->NewNode(javascript()->CreateArguments( |
+ CreateArgumentsParameters::kUnmappedArguments, 0), |
+ closure, context, frame_state_inner, effect, control)); |
+ ASSERT_TRUE(r.Changed()); |
+ EXPECT_THAT(r.replacement(), |
+ IsFinishRegion( |
+ IsAllocate(IsNumberConstant(Heap::kStrictArgumentsObjectSize), |
+ IsBeginRegion(effect), control), |
+ _)); |
+} |
+ |
+ |
+// ----------------------------------------------------------------------------- |
// JSCreateClosure |