OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/interpreter/bytecode-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" |
9 #include "src/interpreter/bytecode-generator.h" | 9 #include "src/interpreter/bytecode-generator.h" |
10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 5984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5995 }; | 5995 }; |
5996 // clang-format on | 5996 // clang-format on |
5997 | 5997 |
5998 for (size_t i = 0; i < arraysize(snippets); i++) { | 5998 for (size_t i = 0; i < arraysize(snippets); i++) { |
5999 Handle<BytecodeArray> bytecode_array = | 5999 Handle<BytecodeArray> bytecode_array = |
6000 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 6000 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
6001 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6001 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
6002 } | 6002 } |
6003 } | 6003 } |
6004 | 6004 |
6005 TEST(CreateRestArguments) { | 6005 TEST(CreateRestParameter) { |
6006 InitializedHandleScope handle_scope; | 6006 InitializedHandleScope handle_scope; |
6007 BytecodeGeneratorHelper helper; | 6007 BytecodeGeneratorHelper helper; |
6008 Zone zone; | 6008 Zone zone; |
6009 | 6009 |
6010 FeedbackVectorSpec feedback_spec(&zone); | 6010 FeedbackVectorSpec feedback_spec(&zone); |
6011 FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); | 6011 FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); |
6012 FeedbackVectorSlot slot1 = feedback_spec.AddKeyedLoadICSlot(); | 6012 FeedbackVectorSlot slot1 = feedback_spec.AddKeyedLoadICSlot(); |
6013 | 6013 |
6014 Handle<i::TypeFeedbackVector> vector = | 6014 Handle<i::TypeFeedbackVector> vector = |
6015 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 6015 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
6016 | 6016 |
6017 // clang-format off | 6017 // clang-format off |
6018 ExpectedSnippet<int> snippets[] = { | 6018 ExpectedSnippet<int> snippets[] = { |
6019 {"function f(...restArgs) { return restArgs; }", | 6019 {"function f(...restArgs) { return restArgs; }", |
6020 1 * kPointerSize, | 6020 1 * kPointerSize, |
6021 2, | 6021 1, |
6022 8, | 6022 7, |
6023 { | 6023 { |
6024 B(CreateRestArguments), U8(0), // | 6024 B(CreateRestParameter), // |
6025 B(Star), R(0), // | 6025 B(Star), R(0), // |
6026 B(StackCheck), // | 6026 B(StackCheck), // |
6027 B(Ldar), R(0), // | 6027 B(Ldar), R(0), // |
6028 B(Return), // | 6028 B(Return), // |
6029 }, | 6029 }, |
6030 1, | 6030 0, |
6031 {0}}, | 6031 {}}, |
6032 {"function f(a, ...restArgs) { return restArgs; }", | 6032 {"function f(a, ...restArgs) { return restArgs; }", |
6033 2 * kPointerSize, | 6033 2 * kPointerSize, |
6034 3, | 6034 2, |
6035 15, | 6035 14, |
6036 { | 6036 { |
6037 B(CreateRestArguments), U8(0), // | 6037 B(CreateRestParameter), // |
6038 B(Star), R(0), // | 6038 B(Star), R(0), // |
6039 B(LdaTheHole), // | 6039 B(LdaTheHole), // |
6040 B(Star), R(1), // | 6040 B(Star), R(1), // |
6041 B(StackCheck), // | 6041 B(StackCheck), // |
6042 B(Ldar), A(1, 3), // | 6042 B(Ldar), A(1, 2), // |
6043 B(Star), R(1), // | 6043 B(Star), R(1), // |
6044 B(Ldar), R(0), // | 6044 B(Ldar), R(0), // |
6045 B(Return), // | 6045 B(Return), // |
6046 }, | 6046 }, |
6047 1, | 6047 0, |
6048 {1}}, | 6048 {}}, |
6049 {"function f(a, ...restArgs) { return restArgs[0]; }", | 6049 {"function f(a, ...restArgs) { return restArgs[0]; }", |
6050 3 * kPointerSize, | 6050 3 * kPointerSize, |
6051 3, | 6051 2, |
6052 21, | 6052 20, |
6053 { | 6053 { |
6054 B(CreateRestArguments), U8(0), // | 6054 B(CreateRestParameter), // |
6055 B(Star), R(0), // | 6055 B(Star), R(0), // |
6056 B(LdaTheHole), // | 6056 B(LdaTheHole), // |
6057 B(Star), R(1), // | 6057 B(Star), R(1), // |
6058 B(StackCheck), // | 6058 B(StackCheck), // |
6059 B(Ldar), A(1, 3), // | 6059 B(Ldar), A(1, 2), // |
6060 B(Star), R(1), // | 6060 B(Star), R(1), // |
6061 B(Ldar), R(0), // | 6061 B(Ldar), R(0), // |
6062 B(Star), R(2), // | 6062 B(Star), R(2), // |
6063 B(LdaZero), // | 6063 B(LdaZero), // |
6064 B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot)), // | 6064 B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot)), // |
6065 B(Return), // | 6065 B(Return), // |
6066 }, | 6066 }, |
6067 1, | 6067 0, |
6068 {1}}, | 6068 {}}, |
6069 {"function f(a, ...restArgs) { return restArgs[0] + arguments[0]; }", | 6069 {"function f(a, ...restArgs) { return restArgs[0] + arguments[0]; }", |
6070 5 * kPointerSize, | 6070 5 * kPointerSize, |
6071 3, | 6071 2, |
6072 36, | 6072 35, |
6073 { | 6073 { |
6074 B(CreateUnmappedArguments), // | 6074 B(CreateUnmappedArguments), // |
6075 B(Star), R(0), // | 6075 B(Star), R(0), // |
6076 B(CreateRestArguments), U8(0), // | 6076 B(CreateRestParameter), // |
6077 B(Star), R(1), // | 6077 B(Star), R(1), // |
6078 B(LdaTheHole), // | 6078 B(LdaTheHole), // |
6079 B(Star), R(2), // | 6079 B(Star), R(2), // |
6080 B(StackCheck), // | 6080 B(StackCheck), // |
6081 B(Ldar), A(1, 3), // | 6081 B(Ldar), A(1, 2), // |
6082 B(Star), R(2), // | 6082 B(Star), R(2), // |
6083 B(Ldar), R(1), // | 6083 B(Ldar), R(1), // |
6084 B(Star), R(3), // | 6084 B(Star), R(3), // |
6085 B(LdaZero), // | 6085 B(LdaZero), // |
6086 B(KeyedLoadICSloppy), R(3), U8(vector->GetIndex(slot)), // | 6086 B(KeyedLoadICSloppy), R(3), U8(vector->GetIndex(slot)), // |
6087 B(Star), R(4), // | 6087 B(Star), R(4), // |
6088 B(Ldar), R(0), // | 6088 B(Ldar), R(0), // |
6089 B(Star), R(3), // | 6089 B(Star), R(3), // |
6090 B(LdaZero), // | 6090 B(LdaZero), // |
6091 B(KeyedLoadICSloppy), R(3), U8(vector->GetIndex(slot1)), // | 6091 B(KeyedLoadICSloppy), R(3), U8(vector->GetIndex(slot1)), // |
6092 B(Add), R(4), // | 6092 B(Add), R(4), // |
6093 B(Return), // | 6093 B(Return), // |
6094 }, | 6094 }, |
6095 1, | 6095 0, |
6096 {1}}, | 6096 {}}, |
6097 }; | 6097 }; |
6098 // clang-format on | 6098 // clang-format on |
6099 | 6099 |
6100 for (size_t i = 0; i < arraysize(snippets); i++) { | 6100 for (size_t i = 0; i < arraysize(snippets); i++) { |
6101 Handle<BytecodeArray> bytecode_array = | 6101 Handle<BytecodeArray> bytecode_array = |
6102 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 6102 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
6103 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6103 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
6104 } | 6104 } |
6105 } | 6105 } |
6106 | 6106 |
(...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8592 for (size_t i = 0; i < arraysize(snippets); i++) { | 8592 for (size_t i = 0; i < arraysize(snippets); i++) { |
8593 Handle<BytecodeArray> bytecode_array = | 8593 Handle<BytecodeArray> bytecode_array = |
8594 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 8594 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
8595 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 8595 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
8596 } | 8596 } |
8597 } | 8597 } |
8598 | 8598 |
8599 } // namespace interpreter | 8599 } // namespace interpreter |
8600 } // namespace internal | 8600 } // namespace internal |
8601 } // namespace v8 | 8601 } // namespace v8 |
OLD | NEW |