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

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1413703007: [Interpreter] Fix a register allocation bug and add a DCHECK. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename function 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 | « src/interpreter/bytecode-generator.cc ('k') | 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 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 2970 matching lines...) Expand 10 before | Expand all | Expand 10 after
2981 2981
2982 2982
2983 TEST(CountOperators) { 2983 TEST(CountOperators) {
2984 InitializedHandleScope handle_scope; 2984 InitializedHandleScope handle_scope;
2985 BytecodeGeneratorHelper helper; 2985 BytecodeGeneratorHelper helper;
2986 Zone zone; 2986 Zone zone;
2987 2987
2988 FeedbackVectorSpec feedback_spec(&zone); 2988 FeedbackVectorSpec feedback_spec(&zone);
2989 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); 2989 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot();
2990 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); 2990 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot();
2991
2992 Handle<i::TypeFeedbackVector> vector = 2991 Handle<i::TypeFeedbackVector> vector =
2993 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 2992 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2994 2993
2994 FeedbackVectorSpec store_feedback_spec(&zone);
2995 FeedbackVectorSlot store_slot = store_feedback_spec.AddStoreICSlot();
2996 Handle<i::TypeFeedbackVector> store_vector =
2997 i::NewTypeFeedbackVector(helper.isolate(), &store_feedback_spec);
2998
2995 int closure = Register::function_closure().index(); 2999 int closure = Register::function_closure().index();
2996 int first_context_slot = Context::MIN_CONTEXT_SLOTS; 3000 int first_context_slot = Context::MIN_CONTEXT_SLOTS;
2997 3001
2998 int object_literal_flags = 3002 int object_literal_flags =
2999 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; 3003 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
3004 int array_literal_flags =
3005 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements;
3000 3006
3001 ExpectedSnippet<InstanceType> snippets[] = { 3007 ExpectedSnippet<InstanceType> snippets[] = {
3002 {"var a = 1; return ++a;", 3008 {"var a = 1; return ++a;",
3003 1 * kPointerSize, 3009 1 * kPointerSize,
3004 1, 3010 1,
3005 11, 3011 11,
3006 { 3012 {
3007 B(LdaSmi8), U8(1), // 3013 B(LdaSmi8), U8(1), //
3008 B(Star), R(0), // 3014 B(Star), R(0), //
3009 B(Ldar), R(0), // 3015 B(Ldar), R(0), //
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3172 B(LdaContextSlot), R(1), U8(first_context_slot), // 3178 B(LdaContextSlot), R(1), U8(first_context_slot), //
3173 B(ToNumber), // 3179 B(ToNumber), //
3174 B(Star), R(2), // 3180 B(Star), R(2), //
3175 B(Dec), // 3181 B(Dec), //
3176 B(StaContextSlot), R(1), U8(first_context_slot), // 3182 B(StaContextSlot), R(1), U8(first_context_slot), //
3177 B(Ldar), R(2), // 3183 B(Ldar), R(2), //
3178 B(Return), // 3184 B(Return), //
3179 }, 3185 },
3180 1, 3186 1,
3181 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3187 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3188 {"var idx = 1; var a = [1, 2]; return a[idx++] = 2;",
3189 3 * kPointerSize,
3190 1,
3191 26,
3192 {
3193 B(LdaSmi8), U8(1), //
3194 B(Star), R(0), //
3195 B(LdaConstant), U8(0), //
3196 B(CreateArrayLiteral), U8(0), U8(array_literal_flags), //
3197 B(Star), R(1), //
3198 B(Ldar), R(0), //
3199 B(ToNumber), //
3200 B(Star), R(2), //
3201 B(Inc), //
3202 B(Star), R(0), //
3203 B(LdaSmi8), U8(2), //
3204 B(KeyedStoreICSloppy), R(1), R(2), //
3205 U8(store_vector->GetIndex(store_slot)), //
3206 B(Return), //
3207 },
3208 1,
3209 {InstanceType::FIXED_ARRAY_TYPE}},
3182 }; 3210 };
3183 3211
3184 for (size_t i = 0; i < arraysize(snippets); i++) { 3212 for (size_t i = 0; i < arraysize(snippets); i++) {
3185 Handle<BytecodeArray> bytecode_array = 3213 Handle<BytecodeArray> bytecode_array =
3186 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 3214 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3187 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3215 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3188 } 3216 }
3189 } 3217 }
3190 3218
3191 3219
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3606 for (size_t i = 0; i < arraysize(snippets); i++) { 3634 for (size_t i = 0; i < arraysize(snippets); i++) {
3607 Handle<BytecodeArray> bytecode_array = 3635 Handle<BytecodeArray> bytecode_array =
3608 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 3636 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3609 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3637 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3610 } 3638 }
3611 } 3639 }
3612 3640
3613 } // namespace interpreter 3641 } // namespace interpreter
3614 } // namespace internal 3642 } // namespace internal
3615 } // namespace v8 3643 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698